how to clear a selection

how to clear a selection

Joris.vd.Meulen
Collaborator Collaborator
1,381 Views
2 Replies
Message 1 of 3

how to clear a selection

Joris.vd.Meulen
Collaborator
Collaborator

So, I'm not succesful in clearing my selection. 

 

Reading revitapidocs UI.Selection it seems to me that

Selection.SelElementSet.Clear()  is deprecated since SelElementSet is ...
(And it isn't working for me)
 
So I thought:
Selection.SetElementIds()
or Selection.SetElementIds(None)
or Selection.SetElementIds(<emptylisthere>)
Nope.
 
So no I wonder: how to clear my selection?
Must be something simple I'm missing / doing wrong?
love python coding
0 Likes
Accepted solutions (1)
1,382 Views
2 Replies
Replies (2)
Message 2 of 3

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @Joris.vd.Meulen ,

Could you please explain a bit more?

I tried using the code you mentioned and I am able to clear my selection.

Try using the below code and let me know what problem you are facing

 //1
 IList<ElementId> emptyList = new List<ElementId>();
 uidoc.Selection.SetElementIds(emptyList); 

 //2
 ElementId invalid = ElementId.InvalidElementId;
 IList<ElementId> invalidList = new List<ElementId>();
 invalidList.Add(invalid);
 uidoc.Selection.SetElementIds(invalidList);  

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 3

Joris.vd.Meulen
Collaborator
Collaborator

Well, no need anymore. Your coding is exactly what I did, except mine had some stupid mistakes. Sigh. 

 

Thanks for your help!

love python coding
0 Likes