Select all existing mleaders and change text height and arrow size

Select all existing mleaders and change text height and arrow size

Anonymous
Not applicable
2,621 Views
9 Replies
Message 1 of 10

Select all existing mleaders and change text height and arrow size

Anonymous
Not applicable

Is there a lisp that selects all existing leaders and overrides the text height and arrow size? If anyone can help, I would greatly appreciate it.

 

Thanks

0 Likes
Accepted solutions (1)
2,622 Views
9 Replies
Replies (9)
Message 2 of 10

Moshe-A
Mentor
Mentor

@Anonymous hi,

 

if the multileader are autocad objects (not simple pline with an arrow) then go to MLEADERSTYLE command and modify the style - no?

 

moshe

 

0 Likes
Message 3 of 10

ВeekeeCZ
Consultant
Consultant
(defun c:MleaderSizeChange ( / ss i textsize arrowsize)

  (if (and (setq textsize (getdist "\nText size: "))
           (setq arrowsize (getdist "\nArrow size: "))
           (setq ss (ssget "_A" (list '(0 . "MULTILEADER") (cons 410 (getvar 'CTAB)))))
           )
    (repeat (setq i (sslength ss))
      (setpropertyvalue (ssname ss (setq i (1- i))) "ArrowSize" arrowsize)
      (setpropertyvalue (ssname ss i) "MText/TextHeight" textsize)))
  (princ)
)

 

 

Edit: In case you have some Mleader with blocks instead of Mtext, the above will probably crash...


(vl-load-com) (defun c:MleaderSizeChange ( / ss i textsize arrowsize) (if (and (setq textsize (getdist "\nText size: ")) (setq arrowsize (getdist "\nArrow size: ")) (setq ss (ssget "_A" (list '(0 . "MULTILEADER") (cons 410 (getvar 'CTAB))))) ) (repeat (setq i (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-ArrowheadSize (list obj arrowsize))) (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-TextHeight (list obj textsize))))) (princ) )

 

0 Likes
Message 4 of 10

Anonymous
Not applicable

It worked but is there a way that I can predefine the arrow being 0.10 and the text height at 0.08 without entering it?  Thanks again for your help!

0 Likes
Message 5 of 10

Moshe-A
Mentor
Mentor

mleaderstyle works the same as dimension styles,  you can define your own multileader styles as many as you like and even import them to current drawing with Design Center (ctrl+2)

 

if you can accomplish a task with basic autocad commands you do not need automation.

 

cheers

moshe

 

0 Likes
Message 6 of 10

Anonymous
Not applicable

Thanks, I'm looking at replacing the part of the code above where you can predefine the arrow head and text size instead of manually everything it every time. I'm not familiar with coding, can any one help?

 

0 Likes
Message 7 of 10

pendean
Community Legend
Community Legend
Do it once, with MLEADERSTYLE command, save it as a new leader style and have more than one style for everything you need in your TEMPLATE file(s).

Template files are the way to go: they do require pre-planning, but its the correct way to do what you want.

PS: avoid calling any style STANDARD, that's for amateurs: give them all meaningful unique names.



0 Likes
Message 8 of 10

Anonymous
Not applicable

Thanks, what I am trying to do is replace the part below with code where  I don't need to manually type in the arrow and text height. The style is already set up but the leaders and text height are already set up but the existing leader and text aren't updated so I have to manually override them. This part of code works but I have to manually enter the arrow and text height so I want to predefine the size instead of entering it. Obviously, it prompts you to enter a size and I want it to be a set size. Hopefully that makes sense.

 

(if (and (setq textsize (getdist "\nText size: ")) (setq arrowsize (getdist "\nArrow size: ")) (setq ss (ssget "_A" (list '(0 . "MULTILEADER") (cons 410 (getvar 'CTAB))))) )

 

0 Likes
Message 9 of 10

ВeekeeCZ
Consultant
Consultant
Accepted solution

 


@Anonymous wrote:

It worked but is there a way that I can predefine the arrow being 0.10 and the text height at 0.08 without entering it?  Thanks again for your help!


 

(vl-load-com)

(defun c:MleaderSize ( / ss i)
  
  (if (setq ss (ssget "_A" (list '(0 . "MULTILEADER") (cons 410 (getvar 'CTAB)))))
    (repeat (setq i (sslength ss))
      (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
      (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-ArrowheadSize (list obj 0.1)))
      (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-TextHeight (list obj 0.08)))))
  (princ)
  )
Message 10 of 10

Anonymous
Not applicable

Perfect, thank you so much for your help!

0 Likes