Author Topic: Select Mleader by Style  (Read 2018 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
Select Mleader by Style
« on: October 05, 2015, 01:26:30 PM »
Hello guys,

Is it possible to make a filter with the ssget function to select Mleaders by their style name ?

Thanks .

Master_Shake

  • Swamp Rat
  • Posts: 1447

Coder

  • Swamp Rat
  • Posts: 827
Re: Select Mleader by Style
« Reply #2 on: October 05, 2015, 02:22:38 PM »
Thank you Chris.

All these example in that thread is about iterating through a selection and not by a filter as far as I understood them.

I have searched in many codes on the web and none on them for a filter with ssget function and that maybe not possible .

Thank you.

ronjonp

  • Needs a day job
  • Posts: 7445
Re: Select Mleader by Style
« Reply #3 on: October 05, 2015, 03:06:09 PM »
You cannot directly filter by style name.

Windows 11 x64 - AutoCAD /C3D 2022

Custom Build PC

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Select Mleader by Style
« Reply #4 on: October 05, 2015, 03:07:09 PM »
This works in BricsCAD:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / enme ss style)
  2.   (setq style (getstring "\nStyle name: "))
  3.   (setq enme
  4.     (cdr
  5.       (assoc
  6.         -1
  7.         (dictsearch
  8.           (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE")))
  9.           style
  10.         )
  11.       )
  12.     )
  13.   )
  14.   (setq ss (ssget (list '(0 . "MULTILEADER") (cons 340 enme))))
  15.   (sssetfirst nil ss)
  16.   (princ)
  17. )

ronjonp

  • Needs a day job
  • Posts: 7445
Re: Select Mleader by Style
« Reply #5 on: October 05, 2015, 03:14:56 PM »
That does not work in AutoCAD.  :|

Windows 11 x64 - AutoCAD /C3D 2022

Custom Build PC

Coder

  • Swamp Rat
  • Posts: 827
Re: Select Mleader by Style
« Reply #6 on: October 05, 2015, 03:47:35 PM »
Thank you guys for your help.

roy , your codes allow me to select Mleaders but it does differentiate between Mleaders'  style names which means that it selects all Mleaders regardless of their style name.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Select Mleader by Style
« Reply #7 on: October 05, 2015, 04:19:22 PM »
Sad to hear that.
I actually did check the AC docs, but I obviously misread this:
The ssget function recognizes all group codes except entity names (group -1), handles (group 5), and xdata codes (groups greater than 1000).
The text would be clearer without '(group -1)'.

Master_Shake

  • Swamp Rat
  • Posts: 1447
Re: Select Mleader by Style
« Reply #8 on: October 06, 2015, 08:04:31 AM »
Maybe there is another way to do what you are attempting. Is the end goal to simply automagically select mleaders with StyleA (With StyleA being predefined) or are you selecting an mleader, grabbing the style and THEN selecting all the mleaders with that style?


Coder

  • Swamp Rat
  • Posts: 827
Re: Select Mleader by Style
« Reply #9 on: October 07, 2015, 03:08:34 AM »
Maybe there is another way to do what you are attempting. Is the end goal to simply automagically select mleaders with StyleA (With StyleA being predefined) or are you selecting an mleader, grabbing the style and THEN selecting all the mleaders with that style?

I was attempting to select only a specific Mleaders with ssget function only.

example:

Quote
(ssget '((0 . "MULTILEADER") (FILTER ONLY A SPECIFIC MLEADER STYLE NAME)))

Master_Shake

  • Swamp Rat
  • Posts: 1447
Re: Select Mleader by Style
« Reply #10 on: October 07, 2015, 09:08:02 AM »
ssget is rather vauge. I was referencing the selection method you were going to use.
http://www.lee-mac.com/ssget.html

If you can use VisualLisp functions,
Code - Auto/Visual Lisp: [Select]
  1. (defun mleadersel ( style / ent mldrs ss1 sscnt )
  2.   (if (setq ss1 (ssget "X" '((0 . "MULTILEADER"))))
  3.     (progn
  4.       (setq mldrs (ssadd))
  5.       (repeat (setq sscnt (sslength ss1))
  6.         (if (= (vla-get-stylename (vlax-ename->vla-object (setq ent (ssname ss1 (setq sscnt (1- sscnt)))))) style)
  7.           (ssadd ent mldrs)
  8.           )
  9.         )
  10.       (if (< 0 (sslength mldrs)) mldrs)
  11.       )
  12.     )
  13.   )
  14.  
http://www.cadtutor.net/forum/showthread.php?84527-Filter-By-Multileader-Style&p=579551&viewfull=1#post579551