Set multileader style

Set multileader style

jands
Explorer Explorer
3,641 Views
13 Replies
Message 1 of 14

Set multileader style

jands
Explorer
Explorer

Hello,

 

Is it possible to retrieve MLEADERSTYLE of selected Mleader, or/and set current mleaderstyle by selecting the existing mleader in drawing?

 

Thank you

 

0 Likes
Accepted solutions (1)
3,642 Views
13 Replies
Replies (13)
Message 2 of 14

ВeekeeCZ
Consultant
Consultant
Accepted solution

Hello and welcome to the community!

 

I believe it is. Just try and tell...

 

(vl-load-com)

(defun c:PickMLStyle ( / en mls)

  (if (and (setq en (car (entsel "\nSelect mleader: ")))
	   (= "MULTILEADER" (cdr (assoc 0 (entget en))))
	   (setq mls (vlax-get (vlax-ename->vla-object en) 'StyleName))
	   )
    (command "_.CMLEADERSTYLE" mls))
  (princ (strcat "\nCurrent MLEADERSTYLE: " mls))
  (princ)
)
Message 3 of 14

jands
Explorer
Explorer

Thank you very much, it works!

 

Happy New Year!

0 Likes
Message 4 of 14

Anonymous
Not applicable

I had a similar question as the OP but have no idea what the above answer is. Is that some sort of code? What is the AutoCAD tool or command to use this?

0 Likes
Message 5 of 14

ВeekeeCZ
Consultant
Consultant

It's AutoLISP program, read HERE how to run it.

0 Likes
Message 6 of 14

jands
Explorer
Explorer

Hello,

 

BeekeeCZ

 

Your routine worked, but now it doesn't work, returns "error: no function definition: VLAX-ENAME->VLA-OBJECT"

 

what can be the problem?

 

Thank you

0 Likes
Message 7 of 14

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

Hello,

 

@ВeekeeCZ

 

Your routine worked, but now it doesn't work, returns "error: no function definition: VLAX-ENAME->VLA-OBJECT"

 

what can be the problem?

 

Thank you


Hi,

first, make sure that following line is a part of your code. You can even try type in this line directly into command line.

 

(vl-load-com)

 

If that doesn't work... that's an issue that can lead you to reinstall autocad. Lately, especially with 2017, I remember here were 2-3 threads about this not working. I've found THIS and THIS, you may find some more... Good luck.

 

0 Likes
Message 8 of 14

jands
Explorer
Explorer

Hello,

Thank you for reply

 

The  (vl-load-com) line is there.

I'm using AutoCAD 2012 and 2016, so 2017 problems are not applicable for me.

 

The point is - this routine worked fine in both 2012 & 2016 after I copied it from here.

 

Looks like i need to reinstall AutoCAD. I will try it next week (too busy now).

 

Thank you anyway

 

 

0 Likes
Message 9 of 14

smallƑish
Advocate
Advocate

Is there any option that includes in a code?

Like when I run my lisp need to make my Mleader EP200ML(name of my Mleader) to be current. And later back to user Mleader at the end.

 

Any tips for that?

0 Likes
Message 10 of 14

Sea-Haven
Mentor
Mentor

Did you read post2 the answer is there, use setvar for the leader style.

0 Likes
Message 11 of 14

smallƑish
Advocate
Advocate
(setvar "MLEADERSTYLE" EP200ML)

Do you mean like this? 

0 Likes
Message 12 of 14

ВeekeeCZ
Consultant
Consultant

No, it's

 

(setvar 'cmleaderstyle "Standard")

Message 13 of 14

smallƑish
Advocate
Advocate

Wow, That's perfect!! Thank you.

What's the same for Dimension style?

If we don't have the dim or mleader in the current drawing, is there any option to bring from any previous drawing?

0 Likes
Message 14 of 14

ВeekeeCZ
Consultant
Consultant

No, that's a little bit complicated. 

 

(and
  (setq ent (car (entsel "Select dim: ")))
  (or (= "DIMENSION" (cdr (assoc 0 (entget ent))))
      (prompt "\nError: Selected object is not dimension!"))
  (setq obj (vlax-ename->vla-object ent))
  (vlax-property-available-p obj 'StyleName T)
  (setq val (vlax-get-property obj 'StyleName))
  (vl-cmdf "_.-DIMSTYLE" "_R" val)
  (princ (strcat "\nCurrent dimstyle: " val))
  )

 

If you want to bring some styles from different drawings, make some dwg with it and insert it as a block. Then remove it.