Jump to content

Possible to create multileader with field linked to block attribute?


eyeofnewt555

Recommended Posts

Hey guys,

 

So, is it possible to have a lisp that automatically labels a block based on an attribute? Ideally, it would also be a field so that if the attribute changed, the mulitleader text would as well.

 

For example, let's say I have a dynamic block for an Oak Tree, which has three sizes: 2", 3", & 4".

 

It'd be great if I could run a LISP that would create a multileader that read " 2"-Oak Tree ". It'd be doubly great if the 2" part of that was a field that updated if the dynamic block was changed to its 4" state.

 

For reference, this wonderful Lee Mac LISP is what I currently use for my labeling and it's brilliant. Ideally, I'll end up combining the attribute/field labeling component with this lisp somehow.

 

Lastly, I'm not great at all with writing LISPs, but I'd like to figure out how this one would work so that I can modify it as need be on my own.

 

Thanks for any help!

Link to comment
Share on other sites

; Attribute to mleader with field
(defun C:test ( / p )
 (and
   (setq p (nentsel "\nSelect attribute: "))
   (= 2 (length p))
   (= "ATTRIB" (cdr (assoc 0 (entget (car p)))))
   (progn 
     (command "_.MLEADER")
     (while (= (logand (getvar 'cmdactive) 1) 1) (command pause)) ; this is required for multisegment mleader
     (vla-put-TextString (vlax-ename->vla-object (entlast))
       (strcat 
         "%<\\AcObjProp Object(%<\\_ObjId "
         (itoa (vla-get-ObjectId (vlax-ename->vla-object (car p))))
         ">%).TextString>%"
       )
     )
     (vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acActiveViewport)
   ); progn
 ); and
 (princ)
); defun 

Good luck!

Edited by Grrr
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...