Saturday, November 21, 2009
Home   |   Search   |   About AUGI   |   My AUGI   |   Join Now

Go Back   AUGI Forums > AUGI Technical (English) > Programming > AutoLISP
 Welcome, Guest. 

Login

Join Now FAQ Members List Calendar Search Today's Posts Mark Forums Read

AutoLISP AutoLISP or Visual LISP, learn both here!

Reply
 
Thread Tools Display Modes
Old 2004-06-08, 12:06 PM   #1
Aubrey.kieren
Member
 
Aubrey.kieren's Avatar
 
Join Date: 2004-06
Location: Stafford, UK
Posts: 6
Aubrey.kieren is starting their journey
Question Move block to Z co-ord

Please help! I'm very new to lisp.
I found this routine a few days ago on the AutoDESK forums, it looks for the "top attribute"(?) I assume this means the first attribute in the list?
I cannot for the life of me work out how to change it to search for a "named" attribute in a block that I wish to use (attribute name is "INVERT").
I would be most grateful if someone could tell me how to to do this! It would save me SOOOO much time!

Thanks,
..::KIEREN::..



;;;C:bel changes a blocks z coordinate to the elevation listed in the top attribute ;
;;;----------------------------
(defun C:bel()
(setq ss (ssget)
ucsf (getvar "ucsfollow"))
(if (/= ss nil)
(progn
(setq ssl (sslength ss))
(setvar "ucsfollow" 0)
(if (/= 1 (getvar "worlducs"))(setq wucs 0)(setq wucs 1))
(command "ucs" "")
(setq numchg ssl
n ssl
newss (ssadd))
(while (> n 0)
(setq n (1- n)
blk (ssname ss n))
(setq ent (vlax-ename->vla-object blk))
(setq atts (vla-getattributes ent))
(setq temp (vlax-variant-value atts))
(setq elem1 (vlax-safearray-get-element temp 0))
(setq el (atof (vla-get-textstring elem1)))
(command "CHANGE" blk "" "P" "E" el "")

);end while
(setq ssl (sslength newss)
n ssl)
(setq txt "block(s) raised to elevation.")
(if (/= numchg 0)
(progn
(print numchg)
(princ txt))
(prompt "No blocks selected."))
)
(prompt "Empty selection set."))
(if (= 0 wucs)(command "ucs" "p"))
(setvar "ucsfollow" ucsf)
(princ)
);end defun
Aubrey.kieren is offline   Reply With Quote
Old 2004-06-08, 01:08 PM   #2
stig.madsen
100 Club
 
Join Date: 2000-12
Posts: 126
stig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightly
Default RE: Move block to Z co-ord

Something like this maybe?

Code:
(defun C:bel (/ att atts blk el ent n numchg ss ucsf wucs)
  ;; we want to make sure the selection holds blocks
  ;; with attributes as not to run into an empty safearray
  (setq ss   (ssget '((0 . "INSERT")(66 . 1)))
        n    0
        numchg 0
        ucsf (getvar "ucsfollow")
  )
  (if ss
    (progn
      (setvar "ucsfollow" 0)
      (if (/= 1 (getvar "worlducs"))
        (setq wucs 0)
        (setq wucs 1)
      )
      (command "ucs" "")
      (repeat (sslength ss)
        (setq blk (ssname ss n)
              n   (1+ n)
        )
        (setq ent (vlax-ename->vla-object blk)
              atts (vla-getattributes ent)
        )
        (foreach a (vlax-safearray->list (vlax-variant-value atts))
          (and (= (vla-get-tagstring a) "INVERT")
               (setq att a)
          )
        )
        (cond (att
               (setq el (atof (vla-get-textstring att)))
               (command "CHANGE" blk "" "P" "E" el "")
               ;; recording actual changes should happen
               ;; here - we just assume it went well
               (setq numchg (1+ numchg))
              )
        )
      ) ;_ end repeat
      ;; reporting 0 changes is also good information
      (princ (strcat (itoa numchg) "block(s) raised to elevation."))
    ) ;_ end progn
    (prompt "Empty selection set.")
  ) ;_ end if
  (if (= 0 wucs) (command "ucs" "p"))
  (setvar "ucsfollow" ucsf)
  (princ)
)
stig.madsen is offline   Reply With Quote
Old 2004-06-08, 01:33 PM   #3
Aubrey.kieren
Member
 
Aubrey.kieren's Avatar
 
Join Date: 2004-06
Location: Stafford, UK
Posts: 6
Aubrey.kieren is starting their journey
Smile RE: Move block to Z co-ord

Just like that!

Thank you,
..::KIEREN::..
Aubrey.kieren is offline   Reply With Quote
Old 2004-06-08, 07:36 PM   #4
stig.madsen
100 Club
 
Join Date: 2000-12
Posts: 126
stig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightly
Default

Darn it, just realized I made an all too common mistake .. please substitute the line

(setq numchg (1+ numchg))

with
(setq numchg (1+ numchg) att nil)
stig.madsen is offline   Reply With Quote
Old 2004-06-09, 09:47 AM   #5
Aubrey.kieren
Member
 
Aubrey.kieren's Avatar
 
Join Date: 2004-06
Location: Stafford, UK
Posts: 6
Aubrey.kieren is starting their journey
Lightbulb RE: Move block to Z co-ord

Thanks for that, but just for my info, what difference would that change make, and why should it need to be changed?

..::KIEREN::..
Aubrey.kieren is offline   Reply With Quote
Old 2004-06-09, 10:17 AM   #6
stig.madsen
100 Club
 
Join Date: 2000-12
Posts: 126
stig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightly
Default

If the loop finds an attribute with the tag "INVERT", it'll point the variable att to it. If it runs into a block that does not contain the attribute, it will already have att pointing at an attribute - a wrong attribute in a wrong insert. So it needs to be cleared before searching next insert.
stig.madsen is offline   Reply With Quote
Old 2004-06-09, 01:48 PM   #7
Aubrey.kieren
Member
 
Aubrey.kieren's Avatar
 
Join Date: 2004-06
Location: Stafford, UK
Posts: 6
Aubrey.kieren is starting their journey
Thumbs up RE: Move block to Z co-ord

Cheers! Thanks for the help!
Aubrey.kieren is offline   Reply With Quote
Reply


Go Back   AUGI Forums > AUGI Technical (English) > Programming > AutoLISP

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
glass block and view range sfaust Revit Architecture - Families 2 2004-04-09 03:18 AM
Move icon not wanted whilst adding to selection Martin P Revit Architecture "Original" Wish List (Archived) 0 2004-03-02 11:47 AM
Move Copy Memory Steve_Stafford Revit Architecture "Original" Wish List (Archived) 1 2003-10-10 01:41 AM
How to move a door from one wall to another jeanne d'arc Revit Architecture - Tips & Tricks 2 2003-08-25 12:53 PM
Move wall based families away from wall Martin P Revit Architecture - Tips & Tricks 0 2003-05-01 10:32 AM


All times are GMT +1. The time now is 02:59 PM.