|
Welcome, Guest.
|
||||||
| AutoLISP AutoLISP or Visual LISP, learn both here! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: 2004-06
Location: Stafford, UK
Posts: 6
![]() |
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 |
|
|
|
|
|
#2 |
|
100 Club
Join Date: 2000-12
Posts: 126
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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)
)
|
|
|
|
|
|
#3 |
|
Member
Join Date: 2004-06
Location: Stafford, UK
Posts: 6
![]() |
Just like that!
Thank you, ..::KIEREN::.. |
|
|
|
|
|
#4 |
|
100 Club
Join Date: 2000-12
Posts: 126
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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) |
|
|
|
|
|
#5 |
|
Member
Join Date: 2004-06
Location: Stafford, UK
Posts: 6
![]() |
Thanks for that, but just for my info, what difference would that change make, and why should it need to be changed?
..::KIEREN::.. |
|
|
|
|
|
#6 |
|
100 Club
Join Date: 2000-12
Posts: 126
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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.
|
|
|
|
|
|
#7 |
|
Member
Join Date: 2004-06
Location: Stafford, UK
Posts: 6
![]() |
Cheers! Thanks for the help!
|
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|
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 |