How to highlight elements in Revit 2016

How to highlight elements in Revit 2016

Anonymous
Not applicable
3,626 Views
6 Replies
Message 1 of 7

How to highlight elements in Revit 2016

Anonymous
Not applicable

Hi!

 

I tried to highlight elements by their ids in Revit 2016. I use this code:

 

UIDocument uiDoc = new UIDocument(Document);
uiDoc.Selection.SetElementIds(Elements);
uiDoc.RefreshActiveView();

But it just select element without highlighting. When i try call PickObjects() method like:

 

uiDoc.Selection.PickObjects(ObjectType.Element, "Select Objects");

it throw me InvalidOperationException with next message: "The active view is non-graphical and does not support capture of the focus for pick operations."

 

Thank you!

 

 

0 Likes
Accepted solutions (1)
3,627 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
Strange, I use exact the same code, without the last line (don't need to refresh). Is it possible you have set the highlight color the same as the select color in the revit settings, This could look like nothing is selected.
0 Likes
Message 3 of 7

Anonymous
Not applicable

Your code works for me as well. What kind of view are you running this in? That's the kind of exception you get if you run it in a schedule view for instance.

 

/Martin

0 Likes
Message 4 of 7

Anonymous
Not applicable

Thank you for your answer. I run it into 3D view. Maybe i should move this to External command? 

0 Likes
Message 5 of 7

Anonymous
Not applicable

I suppose, that my problem can be related with threads. I wrote this code like external command and added button to the ribbon panel, as a result it work fine. But when I moved this button into DockablePane it stopped working. I discovered that if I put breakpoint into this external command and run it twice it will highlight objects.

I also tried run this external command from Idling-event handler but it was unsuccessfully.

0 Likes
Message 6 of 7

Anonymous
Not applicable
Accepted solution
Your problem is probably related to this thread: http://forums.autodesk.com/t5/revit-api/click-on-dock-pane-deselects-elements/m-p/5279637/
DockablePanes mess with the behaviour of Revit's Selection system. I suggested a workaround in that thread that reprtedly worked to some extent. See if youvhave any success with it.
Message 7 of 7

Anonymous
Not applicable

Thank you for your time and your answer. You really helped me.

0 Likes