Please help! I'm very new to lisp. I found this routine a few days ago, but 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 the block. I would be most grateful if someone could tell me how to to do this! Thank you (original post from http://discussion.autodesk.com/thread.jspa?messageID=1184462) From: Kaai Date: Aug/08/03 - 10:32 (GMT) Re: changing point block to match elev of attribute ;;;---------------------------------------------------------- --------------- --------------; ;;;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
attribute"(?) I assume this means the first attribute in the list? "named" attribute in the block. for example: if the tag name of the attribute you want to change is "THISONE" ;;;---> here's where they pick the first tag (number 0) in the list of tags ;;;<-----comment out that line ;;;replace with ;;;(foreach att temp (if (= "THISONE"(vla-get-tagstring att)) (setq elem1 att))) ;;;now elem1 points to a tag named "THISONE" ;;; if more than one have the same tag, it will be the last one in the list due to the foreach loop above hopefully that won't be a problem