TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Coder on October 05, 2015, 01:26:30 PM

Title: Select Mleader by Style
Post by: Coder 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 .
Title: Re: Select Mleader by Style
Post by: ChrisCarlson on October 05, 2015, 01:45:41 PM
Yup, here are some possibilities

http://www.cadtutor.net/forum/showthread.php?84527-Filter-By-Multileader-Style&s=7a19272003ece8164cedfeaf24ab0af9
Title: Re: Select Mleader by Style
Post by: Coder 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.
Title: Re: Select Mleader by Style
Post by: ronjonp on October 05, 2015, 03:06:09 PM
You cannot directly filter by style name.
Title: Re: Select Mleader by Style
Post by: roy_043 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. )
Title: Re: Select Mleader by Style
Post by: ronjonp on October 05, 2015, 03:14:56 PM
That does not work in AutoCAD.  :|
Title: Re: Select Mleader by Style
Post by: Coder 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.
Title: Re: Select Mleader by Style
Post by: roy_043 on October 05, 2015, 04:19:22 PM
Sad to hear that.
I actually did check the AC docs, but I obviously misread this:
Quote from: http://docs.autodesk.com/ACD/2011/ENU/filesALG/WS73099cc142f4875516d84be10ebc87a53f-7a31.htm
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)'.
Title: Re: Select Mleader by Style
Post by: ChrisCarlson 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?

Title: Re: Select Mleader by Style
Post by: Coder 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)))
Title: Re: Select Mleader by Style
Post by: ChrisCarlson 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