AutoLISP to Deselect or Unselect Currently Selected Objects

AutoLISP to Deselect or Unselect Currently Selected Objects

Anonymous
Not applicable
3,616 Views
4 Replies
Message 1 of 5

AutoLISP to Deselect or Unselect Currently Selected Objects

Anonymous
Not applicable

I'm writing an AutoLISP routine that prompts the user to select a single object, and can't figure out how to deselect all currently selected objects before prompting the user with (ssget) or (entsel).  Is there an easy way to do this? (I'm not asking how to delete a selection set from memory, but how to deselect objects that are visibly selected).

 

This is an issue because I want the user to select only one object.  With (ssget), the way you would do this is:

 

(ssget "_+.:E:S")

BUT, if the user already has objects selected when the routine is run, those objects will be included in the selection set, hence returning a selection set with multiple entities.

 

(entsel) works as desired, with restricting the returned selection set to a single object.  BUT if objects are already selected when (entsel) is called, those objects remain visibly selected (with the blue-square-grab-points visible) while the user selects an object for (entsel).  This would be confusing behavior for the end user.

 

I'm running Windows 10 and AutoCAD 2016.

 

Thanks!

 

 

 

 

0 Likes
Accepted solutions (1)
3,617 Views
4 Replies
Replies (4)
Message 2 of 5

Shneuph
Collaborator
Collaborator
Accepted solution

Does

(sssetfirst nil nil)

work?

 

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
0 Likes
Message 3 of 5

Anonymous
Not applicable
Perfect! Thanks.
0 Likes
Message 4 of 5

john.uhden
Mentor
Mentor
Or just (sssetfirst)

John F. Uhden

Message 5 of 5

Kent1Cooper
Consultant
Consultant

@Shneuph wrote:

Does

(sssetfirst nil nil)

work?


[I believe just (sssetfirst nil) is enough to accomplish that.] EDIT -- didn't catch @john.uhden's even-more-minimalist one.

Kent Cooper, AIA
0 Likes