I found this lisp by Lee Mac, from back in 2014.
Lisp work perfect. The only issue is, that i have 2 attributes inside my dynamic block and want lisp to read current viability state attribute. Hope this is possible.
Thank you for your time.
((defun c:mlb ( / at1 at2 ent enx ins lst mld pnt )
(while
(progn
(setvar 'errno 0)
(setq ent (car (entsel "\nSelect block <exit>: ")))
(cond
( (= 7 (getvar 'errno))
(princ "\nMissed, try again.")
)
( (null ent)
nil
)
( (/= "INSERT" (cdr (assoc 0 (setq enx (entget ent)))))
(princ "\nObject is not a block.")
)
( (/= 1 (cdr (assoc 66 enx)))
(princ "\nBlock is not attributed.")
)
( (not
(and
(setq lst (vlax-invoke (vlax-ename->vla-object ent) 'getattributes)
lst (mapcar '(lambda ( x ) (cons (strcase (vla-get-tagstring x)) x)) lst)
)
(setq at1 (cdr (assoc "STATE-1" lst)))
(setq at2 (cdr (assoc "STATE-2" lst)))
)
)
(princ "\nBlock does not contain "sate-1\" & \"sate-2\" attributes." at )
)
( (setq ins (cdr (assoc 10 enx))
pnt (getpoint (trans ins ent 1) "\nPick leader endpoint <exit>: ")
)
(setq mld
(vlax-invoke
(vlax-get-property (LM:acdoc)
(if (= 1 (getvar 'cvport))
'paperspace
'modelspace
)
)
'addmleader
(append (trans ins ent 0) (trans pnt 1 0))
0
)
)
(vla-put-textstring mld
(strcat
"%<\\AcObjProp Object(%<\\_ObjId "
(LM:ObjectID at1)
">%).TextString>% - %<\\AcObjProp Object(%<\\_ObjId "
(LM:ObjectID at2)
">%).TextString>%"
)
)
(vla-put-textrotation mld 0.0)
(if (<= (car pnt) (car (trans ins ent 1)))
(progn
(vla-setdoglegdirection mld 0 (vlax-3D-point (trans '(-1.0 0.0) 1 0 t)))
(vlax-invoke mld 'setleaderlinevertices 0 (append (trans ins ent 0) (trans pnt 1 0)))
)
(vla-setdoglegdirection mld 0 (vlax-3D-point (trans '(1.0 0.0) 1 0 t)))
)
(vla-regen (LM:acdoc) acactiveviewport)
t
)
)
)
)
(princ)
)
;; ObjectID - Lee Mac
;; Returns a string containing the ObjectID of a supplied VLA-Object
;; Compatible with 32-bit & 64-bit systems
(defun LM:ObjectID ( obj )
(eval
(list 'defun 'LM:ObjectID '( obj )
(if
(and
(vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))
(vlax-method-applicable-p (vla-get-utility (LM:acdoc)) 'getobjectidstring)
)
(list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false)
'(itoa (vla-get-objectid obj))
)
)
)
(LM:ObjectID obj)
)
;; Active Document - Lee Mac
;; Returns the VLA Active Document Object
(defun LM:acdoc nil
(eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
(LM:acdoc)
)
(vl-load-com) (princ)