PDA

View Full Version : 2014 How t o highlight an element while the command is running



kukuzry
2014-07-07, 06:16 PM
My plugin will show a Window Form with different room properties listed on it. What I want is to highlight an room when I select this room from GUI. Is there any simple way to do it?

The method mentioned in this blog (http://thebuildingcoder.typepad.com/blog/2010/06/highlight-elements.html) can highlight an element only after the Execute() function is finished. However, I want the element to be highlighted in between (i.e., Window Form GUI is still running and a room can be hilghlighted by selecting this room from this GUI)

Thanks,

ColinStark
2014-07-07, 11:31 PM
You should be able to do something like this:



Element elementToSelect;
UIDocument uidoc;

SelElementSet selElementSet = uidoc.Selection.Elements;

//If you want to deselect all previously selected elements
selElementSet.Clear();

selElementSet.Insert(elementToSelect);

uidoc.Selection.Elements = selElementSet;

//If you want to show the element as well
uidoc.ShowElements(elementToSelect);



In 2015, it's done a little differently:




ElementId idOfElementToSelect;
UIDocument uidoc;

uidoc.Selection.SetElementIds(new[] {idOfElementToSelect});

//If you want to show the element as well
uidoc.ShowElements(idOfElementToSelect);



As far as I know, there is no restriction on highlighting the element while a command is running. The link you referenced is very old so the restriction must have been removed since then.

kukuzry
2014-07-08, 01:13 AM
Thanks! I find ShowElements seems very slow. So I use boundingBoxXYZ and UIView class to show element in a specified range..