Astro Posted September 28, 2009 Posted September 28, 2009 Hi all, hope somebody can help me with this lisp. I want to select one ore more blocks. Then the lisp scan the block for a list off attributes, TAG1" "TAG2" "TAG3". And if the rotation angle is not 0 it rotates it to 0, and after give me the option to move the attributes. (defun c:ROTATEMOVEATTRIBUTE1 (/ tag ss sel) (vl-load-com) (setq tag '("TAG1" "TAG2" "TAG3")) ;; <<-- Tag to be Searched (and (setq ss (ssget '((0 . "INSERT") (66 . 1)))) (vlax-for Obj (setq sel (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) (foreach att (append (vlax-invoke Obj 'GetAttributes) (vlax-invoke Obj 'GetConstantAttributes)) (if (vl-position (strcase (vla-get-TagString att)) tag) (vla-put-Rotation attVar 0 (cond ((eq :vlax-true (vla-put-Rotation attVar 90)) :vlax-false) (:vlax-true)))))) (vla-delete sel)) (princ)) Quote
Lee Mac Posted September 28, 2009 Posted September 28, 2009 There's the rotate part corrected - its not just as simple as replacing visibilty properties with rotation... check the arguments needed for vla-put-rotation (defun c:ROTATEMOVEATTRIBUTE1 (/ tag ss sel) (vl-load-com) (setq tag '("TAG1" "TAG2" "TAG3")) ;; <<-- Tag to be Searched (and (setq ss (ssget '((0 . "INSERT") (66 . 1)))) (vlax-for Obj (setq sel (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) (foreach att (append (vlax-invoke Obj 'GetAttributes) (vlax-invoke Obj 'GetConstantAttributes)) (if (vl-position (strcase (vla-get-TagString att)) tag) (vla-put-Rotation attVar 0)))) (vla-delete sel)) (princ)) Quote
Astro Posted September 30, 2009 Author Posted September 30, 2009 Hi thx for your help. I try it with the modified code but i got this message Select objects: ; error: bad argument type: VLA-OBJECT nil Quote
Astro Posted September 30, 2009 Author Posted September 30, 2009 i think i got it (defun c:ROTATEMOVEATTRIBUTE1( / ss obj) (vl-load-com) (setq tag '("TAG1" "TAG2" "TAG3")) (and (setq ss (ssget '((0 . "INSERT") (66 . 1)))) (vlax-for obj (setq ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))) (if (= (vla-get-HasAttributes obj) :vlax-true) (foreach attVar (vlax-invoke obj 'GetAttributes) (if (not (= (vla-get-TagString attVar) tag)) (vla-put-Rotation attVar 0))))) (vla-delete ss)) (princ)) can sombody help me now with the move command. I need to have the option to move the attributes after the rotation. Quote
Lee Mac Posted September 30, 2009 Posted September 30, 2009 Sorry my bad: (defun c:ROTATEMOVEATTRIBUTE1 (/ tag ss sel) (vl-load-com) (setq tag '("TAG1" "TAG2" "TAG3")) ;; <<-- Tag to be Searched (and (setq ss (ssget '((0 . "INSERT") (66 . 1)))) (vlax-for Obj (setq sel (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) (foreach att (append (vlax-invoke Obj 'GetAttributes) (vlax-invoke Obj 'GetConstantAttributes)) (if (vl-position (strcase (vla-get-TagString att)) tag) (vla-put-Rotation att 0)))) (vla-delete sel)) (princ)) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.