- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone, s
I do have a Lisp from Lee Mac that display as field the ITEM attribute value when the associated block is pointed by a Leader.
I have customed a little bit the routine but for a reason i dont understand, the start point of the leader is not the center point of the block.
If someone could help me understand and try to fix it if i am not doing things well.
Thank you guys
(defun c:MLeader_ID ( / Attribute_ID block_ent enx ins lst mld pnt )
(defun CLEANROUTINE () ; Reset each liste each time
(setq lst nil)
)
(while
(progn
(setvar 'errno 0)
(setq block_ent (car (entsel "\nSelect block <exit>: ")))
(cond
( (= 7 (getvar 'errno))
(princ "\nMissed, try again.")
)
( (null block_ent)
nil
)
( (/= "INSERT" (cdr (assoc 0 (setq enx (entget block_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 block_ent) 'getattributes)
lst (mapcar '(lambda ( x ) (cons (strcase (vla-get-tagstring x)) x)) lst)
)
(setq Attribute_ID (cdr (assoc "ITEM" lst)))
)
)
)
( (setq ins (cdr (assoc 10 enx))
pnt (getpoint (trans ins block_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 block_ent 0) (trans pnt 1 0))
0
)
)
(vla-put-textstring mld
(strcat "%<\\AcObjProp Object(%<\\_ObjId " (LM:ObjectID Attribute_ID) ">%).TextString>%"
)
)
(vla-put-textrotation mld 0.0)
(if (<= (car pnt) (car (trans ins block_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 block_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)
Solved! Go to Solution.