How to Unhighlight All Objects in RhinoDoc?

In Rhino (using RhinoCommon API), when working with RhinoDoc, some objects might be highlighted due to user interactions or script logic. To unhighlight them, the straightforward approach is to loop through the object table and set Object.Highlighted = false for each highlighted object. However, this feels inefficient, especially in documents with many objects.

Is there a simpler or more performant way to unhighlight all objects at once? For example:

  • Does Rhino provide a built-in method like UnhighlightAll() or similar?
  • Is there a way to reset the highlight state globally without iterating through every object?

Example of the current “inefficient” approach:

foreach (var obj in doc.Objects)  
{  
    if (obj.Highlighted)  
        obj.Highlighted = false;  
}  

This works but seems suboptimal for large models. Any insights or API tricks to achieve this more elegantly?

You’d typically disable the redrawing until your code is done. You can do that with ViewTable.EnableRedraw Method .

doc.Views.EnableRedraw(false, false, false);

// all your logic here

doc.Views.EnableRedraw(true, true, true);

There is no un-highlight method, but you could record the selection you need, then unselect everything ObjectTable.UnselectAll Method.

Thank you for the suggestion!
However, ViewTable. EnableRedraw is designed to temporarily disable viewport refreshing (to reduce UI lag) and does not directly clear object highlight states. The core issue here is how to batch-reset the highlight property rather than optimizing loop performance alone.

The highlighted state of the object may be caused by other operations or commands, and I have no way of knowing which objects in the document are highlighted.

is this question about a plugin or a script ?

Rhino is extremely fast in iterating over the objects list.

not sure if there is a state where objects are highlighted but not selected.
If you set highlight by code, you may want to track those objects in a list ?

there is more stuff about selected then hightlighted:

https://developer.rhino3d.com/api/rhinocommon/rhino.docobjects.tables.objecttable/getselectedobjects

And quite powerful:
https://developer.rhino3d.com/api/rhinocommon/rhino.docobjects.tables.objecttable/getobjectlist

https://developer.rhino3d.com/api/rhinocommon/rhino.docobjects.objectenumeratorsettings

@nathanletwory
do you really need to turn of Redraw in a plugin 's command ?
most of the examples don 't do this - but explicit redraw the views !

kind regards - tom

Correct, that is why I suggest to record the object selection as you need at the start of your process, then unselect everything. Subsequently disable refreshing of viewports if you don’t need them to update. If you need updates of viewports only at specific times of your code then you can manually issue viewport redraws.

You don’t have to disable redrawing, but if you are doing lots of operations using existing commands that also draw it may be beneficial to turn of viewport redrawing if it is not necessary for the function of your code. In larger models it can speed up the execution of your code quite a bit.