Hi, Im bj. I need a help.
I just googled lisp for changing block reference, and most of them come from Lee_MAC programming. thanks again!
I want to change the reference of blocks only I selected, so I post my code. please check my error thanks.
I just started lisp yesterday, and I do not have any deep knowledge in lisp. thanks.
---------------------------------------------------------------------------------------------------
(defun c:wow ( / d n )
(if (ssget "X" '((0 . "INSERt") (410 . "MODEL")))
(vlax-for blk (vla-get-ActiveSelectionSet (setq d (vla-get-ActiveDocument (vlax-get-acad-object))))
(vlax-for b blk
(vlax-for a b
(setq n (vla-get-objectname a))
(cond
( (= "AcDbBlockReference" n)
(if (= :vlax-true (vla-get-hasattributes a))
(foreach x
(append
(vlax-invoke a 'getattributes)
(vlax-invoke a 'getconstantattributes)
)
(vl-catch-all-apply 'vla-put-layer (list x "0"))
)
)
)
( (= "AcDbAttributeDefinition" n)
(vl-catch-all-apply 'vla-put-layer (list a "0"))
)
)
)
)
)
)
(vla-regen d acallviewports)
(princ)
)
(vl-load-com) (princ)