Hello, I would like a lisp that extract "Handle" of a Block and put it in an atribute of the same block.
I have 2 problems:
First: I want to edit all blocks in drawing (include blocks in layouts)
Second: When I extract handle information its from atributes
I read this post https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/auto-number-lisp-based-on-layout-tab...
what else should i do, this is my code
(defun c:ASGHANDLE (/ bname ss1 ent entdata handle)
(setq bname (getstring"\nEnter block to give handle: "))
(if (setq ss1 (ssget "_x" (list '(0 . "INSERT") (cons 2 bname))))
(mapcar
'(lambda (x)
(setq ent (cadr x)
entdata (entget ent))
(while (/= (cdr (assoc 0 entdata)) "SEQEND")
(cond (
(= "HANDLE" (cdr (assoc 2 entdata)))
(entmod
(subst(
(vla-get-handle (vlax-ename->vla-object ent))
(assoc 1 entdata)
entdata)
)
)
)
)
(setq entdata (entget (setq ent (entnext ent))))))
(ssnamex ss1))
"No atributes found")
(princ))
Solved! Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
Perhaps like this. Hopefully, your blocks are not dynamic.
(defun c:HandleAssignment ( / e i e) (if (and (setq b (getstring t "Block name: ")) (setq s (ssget "_X" (list '(0 . "INSERT") (cons 2 b) '(66 . 1)))) ) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i)))) (setpropertyvalue e "HANDLE" (cdr (assoc 5 (entget e)))))) (princ) )
Just a side note: If a block has an attribute named HANDLE, we are not able to get a real handle (the property) by (getpropertyvalue e "Handle"). The attribute takes priority.
Can't find what you're looking for? Ask the community or share your knowledge.