Multileader style Name

Multileader style Name

MShoesmith
Enthusiast Enthusiast
1,793 Views
14 Replies
Message 1 of 15

Multileader style Name

MShoesmith
Enthusiast
Enthusiast

Hi,

I would like to create a quick selection set of a Multi-leader style (named "ABC").

I am struggling to do this and i understand that you need to drill into the Dictionary to obtain the style name.

I am wanting to select the Multileader style in the current space and this is what i have so far...

(if (setq ss (ssget "_A" (list '(0 . "MULTILEADER")(if (= 1 (getvar 'cvport)) (cons 410 (getvar 'ctab)) '(410 . "Model")))))(sssetfirst nil ss))


 If there is a way of adding the Multileader style  name to this, i would be very grateful for any help.

 

Ta

Shoey

Shoey
0 Likes
Accepted solutions (2)
1,794 Views
14 Replies
Replies (14)
Message 2 of 15

Sea-Haven
Mentor
Mentor
0 Likes
Message 3 of 15

MShoesmith
Enthusiast
Enthusiast

Cheers Pal.

 

So i have tested the code at the link and the code does work when replacing a Multileader style.

However, i would like the selection to go into a selection set.

Code is show below but comes with a "error bad argument type" message.

Again, any help appreciated

(defun c:test  (/ sel int obj)
 (if (setq sel (ssget "_A" (list '(0 . "MULTILEADER")(if (= 1 (getvar 'cvport)) (cons 410 (getvar 'ctab)) '(410 . "Model")))))
   (repeat (setq int (sslength sel))
     (setq obj (vlax-ename->vla-object (ssname sel (setq int (1- int)))))
     (if (eq (vla-get-stylename obj) "ABC")
       (sssetfirst nil obj)
       )
     )
   )
 (princ)
 )

.

 

Shoey
0 Likes
Message 4 of 15

komondormrex
Mentor
Mentor
Accepted solution

hey, somewhat corrected

 

(defun c:test  (/ mleader_sset mleader_sset_filtered)
 (setq mleader_sset_filtered (ssadd))
 (if (setq mleader_sset (ssget "_A" (list '(0 . "MULTILEADER")(if (= 1 (getvar 'cvport)) (cons 410 (getvar 'ctab)) '(410 . "Model")))))
   (foreach mleader (vl-remove-if 'listp (mapcar 'cadr (ssnamex mleader_sset)))
     (if (= "ABC" (vla-get-stylename (vlax-ename->vla-object mleader)))
     	(ssadd mleader mleader_sset_filtered) 
     )
   )
 )
 (sssetfirst nil mleader_sset_filtered )
 (princ)
 )
Message 5 of 15

MShoesmith
Enthusiast
Enthusiast

Thank you very much. After testing, it does what i require.

I will study the code you have provided and learn from it.

 

Kind regards

Shoey
0 Likes
Message 6 of 15

WeTanks
Mentor
Mentor

In what situation is it useful?

 

Why not use it?

スクリーンショット 2023-03-03 200926.png

We.Tanks

EESignature

A couple of Fusion improvement ideas that could your vote/support:
図面一括印刷

0 Likes
Message 7 of 15

komondormrex
Mentor
Mentor

in selecting all mleaders, regardless of their styles 

0 Likes
Message 8 of 15

MShoesmith
Enthusiast
Enthusiast

Select similar selects all Multi-leaders.

I could use QSELECT and select Multi-leader and style that way.

Both of these can use individually in dwg files.

 

The code given will select all Multi-leader styles in one-click. (Instead of several clicks in QSELECT).

 

But main reason is that i can use the code via a script when changing layer of the selected Multi-leader style in a batch of drawings.

 

Thanks

Shoey
0 Likes
Message 9 of 15

WeTanks
Mentor
Mentor

thanks for the reply.

I understand.


but, This Lisp can only choose ABC,
Others cannot be selected.
It feels a bit limiting.

 

We.Tanks

EESignature

A couple of Fusion improvement ideas that could your vote/support:
図面一括印刷

0 Likes
Message 10 of 15

ВeekeeCZ
Consultant
Consultant

@komondormrex @MShoesmith @WeTanks 

 

you guys explore SELECTSIMILARMODE if you're running it in the default setting.

 

And yes, SELECTSIMILAR can be used in scripts.

0 Likes
Message 11 of 15

MShoesmith
Enthusiast
Enthusiast

Thanks for that.

I overlooked the SELECTSIMILARMODE for selecting Multi-leader styles. (object style was not checked in the settings for me).

I will look into using that and SELECTSIMILAR in a script too.

 

But the code provided is fine too.

 

Regards

 

Shoey
Message 12 of 15

komondormrex
Mentor
Mentor

so did i. too many variables to remember)))

0 Likes
Message 13 of 15

ВeekeeCZ
Consultant
Consultant

Well, if that's the case, maybe your vision serves you better. 😉

 

BeekeeCZ_0-1677846915510.png

 

0 Likes
Message 14 of 15

komondormrex
Mentor
Mentor
Accepted solution

in case

 

 

 

(defun select_mleader_style  (mleader_style_list / mleader_sset mleader_sset_filtered)
	(setq mleader_sset_filtered (ssadd))
 	(if (setq mleader_sset (ssget "_A" (list '(0 . "MULTILEADER")(if (= 1 (getvar 'cvport)) (cons 410 (getvar 'ctab)) '(410 . "Model")))))
   		(if mleader_style_list 
   			(foreach mleader (vl-remove-if 'listp (mapcar 'cadr (ssnamex mleader_sset)))
   			  (if (member (vla-get-stylename (vlax-ename->vla-object mleader)) mleader_style_list)
   			  	(ssadd mleader mleader_sset_filtered) 
   			  )
   			)
			(setq mleader_sset_filtered mleader_sset)
		)
 	)
 	(sssetfirst nil mleader_sset_filtered )
 	(princ)
)

 

 

 

(select_mleader_style nil) - to select all mleaders

(select_mleader_style '("ABC" "BCD")) - to select all mleaders styled with "ABC", "ВCD" styles

Message 15 of 15

WeTanks
Mentor
Mentor

You are Great!

This is very convenient!

どうもありがとうございました。

We.Tanks

EESignature

A couple of Fusion improvement ideas that could your vote/support:
図面一括印刷

0 Likes