How To Clear Selection In Revit 2015 With API

How To Clear Selection In Revit 2015 With API

Anonymous
Not applicable
2,856 Views
5 Replies
Message 1 of 6

How To Clear Selection In Revit 2015 With API

Anonymous
Not applicable

In Previous, Use uiDocument.Selection.Elements.Clear(), but in Revit 2015, It's Obsolete, How to Clear Selection

0 Likes
2,857 Views
5 Replies
Replies (5)
Message 2 of 6

PhillipM
Advocate
Advocate

I'm also having this issue from within an iDropHandler.

 

I'm using  "document.Selection.GetElementIds.Clear()" but it is still returning previously selected elements even though they are defiantly unselected in the Revit UI.

 

Any Ideas?

0 Likes
Message 3 of 6

Anonymous
Not applicable

 You can try the following code.

 

uiDocument.Selection.SetElementIds(new List<ElementId>());
Message 4 of 6

PhillipM
Advocate
Advocate

Thanks for the hint.

 

I have tried that and it still not working correctly.

 

Please see below video that explains my issue.  It is as though there is a bug in the IDrop event 😞

 

https://dl.dropboxusercontent.com/u/7827802/iDropSSIssue.wmv

 

Any help is much apreciated.

 

Regards

 

Phillip Miller

0 Likes
Message 5 of 6

Anonymous
Not applicable

Thanks, it' all right.

0 Likes
Message 6 of 6

bxw
Enthusiast
Enthusiast

There is probably a shorter way but this works:

 

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

 

0 Likes