Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*Expert Elite*
Kent1Cooper
Posts: 5,872
Registered: ‎09-13-2004
Message 1 of 4 (838 Views)

Combining (ssget) selection methods: Implied, not Locked

838 Views, 3 Replies
10-10-2012 11:00 AM

I learned [from Lee Mac, and have since seen it elsewhere], a while back, that this selection-method combination in (ssget) [which includes some methods undocumented in the AutoLISP Reference] will let you pick one thing that's not on a locked Layer, sort of like (car (entsel)) but with the locked-Layer control and putting it into a selection set:

 

(ssget "_+.:E:smileyfrustrated::L")

 

So clearly, it's possible to combine selection methods in (ssget).  Clearly you shouldn't be able to combine some of the others, such as X with C, but I haven't found a way to combine the ones I want.

 

I'm trying [in the current effort] to find out whether the implied selection [pre-selected objects with PICKFIRST = 1] includes any Arcs on unlocked Layers, and if so, put them into a selection set.  I can do the two sub-parts of that -- I can find Arcs in an implied selection:

 

(setq arcss (ssget "_I" '((0 . "ARC"))))

 

and I can have the user select Arcs [not pre-selected/implied] while forbidding those on locked Layers:

 

(setq arcss (ssget "_:L" '((0 . "ARC"))))

 

But I haven't found a way, in one (ssget) operation, to find Arcs in the implied selection that are not on locked Layers.  These:

 

(setq arcss (ssget "_:LI" '((0 . "ARC"))))

and

(setq arcss (ssget "_I:L" '((0 . "ARC"))))

 

both get me this message:
 

; error: bad ssget mode string

 

So apparently you can't combine just any selection method options.  Could it be that only the colon-prefixed initial-letter ones can be combined, as in the example at the top, but not those along with un-colon-prefixed letters?  Does anyone know of a way to do this?  Or must I resign myself to just getting all Arcs in an implied selection, whether locked or not, and then eliminating any that are on locked Layers one at a time, as I step through the selection set to work with them?

 

Thanks for any advice,

Kent Cooper
Mentor
phanaem
Posts: 153
Registered: ‎02-06-2007
Message 2 of 4 (820 Views)

Re: Combining (ssget) selection methods: Implied, not Locked

10-10-2012 02:44 PM in reply to: Kent1Cooper

Hi Kent

This works in AutoCAD 2012

(if
    (setq ss (ssget "I" '((0 . "ARC"))))
    (setq ss1 (ssget ":L:P" '((0 . "ARC"))))
    )

 HTH

*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 3 of 4 (810 Views)

Re: Combining (ssget) selection methods: Implied, not Locked

10-10-2012 06:06 PM in reply to: Kent1Cooper

Kent1Cooper wrote:

 

So apparently you can't combine just any selection method options.  Could it be that only the colon-prefixed initial-letter ones can be combined, as in the example at the top, but not those along with un-colon-prefixed letters?  Does anyone know of a way to do this?  Or must I resign myself to just getting all Arcs in an implied selection, whether locked or not, and then eliminating any that are on locked Layers one at a time, as I step through the selection set to work with them?

 

Thanks for any advice,


Its either that or collect names of all locked layer thru tblnext "Layer" , then use exclusion filter

 

(setq arcss (ssget "I"  (list '(0 . "ARC")'(-4 . "<NOT")(cons 8  locklyrlst)'(-4 . "NOT>"))))

 

HTH

 

 

*Expert Elite*
Kent1Cooper
Posts: 5,872
Registered: ‎09-13-2004
Message 4 of 4 (770 Views)

Re: Combining (ssget) selection methods: Implied, not Locked

10-15-2012 09:20 AM in reply to: phanaem

phanaem wrote:

This works in AutoCAD 2012

(if
    (setq ss (ssget "I" '((0 . "ARC"))))
    (setq ss1 (ssget ":L:P" '((0 . "ARC"))))
    )

Thanks for that suggestion -- I didn't reply sooner because I've been experimenting.  It didn't turn out to be the solution, directly, but it led me to try some variations, through which I found a way to do what I want.

 

The :smileytongue: option is to reject ViewPorts, and isn't the same as the P [without the colon] option for the Previous selection.  Using ":LP" [or "P:L"], to combine locked-Layer rejection with the Previous option rather than with Viewport rejection, gives the same error as my previous try using ":LI" [or "I:L"].  So the reason that "works" isn't because of the :smileytongue: in there, and it works just as well without it [since Viewports are disallowed by the filter anyway].  Also, it doesn't work if you clear the pre-selection [e.g. with Esc] in between -- (ssget ":L:smileytongue:"...) then asks the User to select things, rather than using what was found by the (ssget "I") before, since the :smileytongue: doesn't refer to the Previous selection.

 

But it does work if there's an active PICKFIRST pre-selection -- (ssget) with just the ":L" option works to select things that are not on locked Layers from such a pre-selection, if it exists, without asking the User to select objects, since they already did.  I hadn't epected that.  It's using the implied selection because that's active, an not because it's the Previous selection from the preceding (ssget "I").

 

I tried it, at first without success, in my longer routine.  But I had a (command) function in there prior to that point, and if I called up the routine with a pre-selection, that (command) function was clearing out the pre-selection, so I wasn't getting the selection out of it.

 

But that (command) function is just Undo Begin, which can also be done otherwise, but which in any case I don't need to do until after I establish a selection, before doing anything with it.  When that is moved to after the selection portion, then the function retains the active pre-selection, and gets the things from it that are not on locked Layers, without further asking the User to select things, just as intended.

 

This is an abbreviated version [the real thing actually allows certain other entity types, too] of what I ended up with:

 

(if (ssget "_I" '((0 . "ARC"))); there's a pre-selection with Arc(s) [doesn't need to be (setq)'d into a variable]
  (setq ss (ssget "_:L" '((0 . "ARC")))); then -- get those not on locked Layers [no further User selection]

  (progn ; else -- no pre-selection, or one without Arc(s)
    (sssetfirst nil); un-select pre-selection without Arc(s), if any [no effect if no pre-selection]
    (prompt "\nTo [...do what the routine does with...] Arc(s),")
    (setq ss (ssget "_:L" '((0 . "ARC")))); User select -- accept only Arcs not on locked Layers
  ); progn -- else
); if

Kent Cooper
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.