Originally Posted by
mmmm_standard666891
Is it possible to use a multileader to simply click on the block and have the text automatically change to the name of the block? (For example I click on the P100 block and the text in my leader now = P100)
Here's a quick LISP routine which prompt the user to select a single Block (dynamic or not), and single MLeader (on an unlocked layer), and proceeds to check for MTEXT ContentType, and the programmatically changes the MLeader Object's TextString Property accordingly... This routine also support 'undo' functionality:
Code:
(vl-load-com)
(defun c:LBML () (c:LableBlockByMLeader))
(defun c:LableBlockByMLeader (/ *error* block mleader oMLeader acDoc)
(defun *error* (msg)
(if acDoc
(vla-endundomark acDoc)
)
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it
)
(princ)
)
(if
(and (setq block (ssget ":S:E" '((0 . "INSERT"))))
(setq mleader (ssget ":S:E:L" '((0 . "MULTILEADER"))))
(= 2 ; mtext only, no blocks
(vla-get-contenttype
(setq oMLeader (vlax-ename->vla-object (ssname mleader 0)))
)
)
)
(progn
(vla-startundomark
(setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
)
(vla-put-textstring
oMLeader
(vla-get-effectivename
(vlax-ename->vla-object (ssname block 0))
)
)
)
)
(*error* nil)
)