Objects selection via code is much slower than via viewport

Hi everyone,

I have a file that contains 2500 surfaces.
When I select those surfaces in viewport - they are selected immediately.

But when I try to select objects via rhinocommon, the selection takes 16-17 seconds.

This seems a bit confusing to me. Here are the methods I tried:

HashSet<Guid> objectIds - collection of object ids to select;


foreach (var id in objectIds)
       if (RhinoDoc.ActiveDoc.Objects.Find(id) != null)
               RhinoDoc.ActiveDoc.Objects.Select(id, true, true, true, true, true, true);

foreach (var id in objectIds)
       var obj = RhinoDoc.ActiveDoc.Objects.Find(id);
       if (obj != null)
              obj.Select(true, true, true, true, true, true);

var refs = objectIds.Select(item => new ObjRef(item));

Does anyone know why selection via code takes so long? Is there any way to improve the performance?

Here is the file: No Bueno 2 (3).3dm (9.4 MB)


Dunno, with Python/Rhinoscript it is almost immediate with either




?? --Mitch

Hi @Yuliya,

How about this?

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
  foreach (var obj in doc.Objects)
  return Result.Success;

– Dale

Hi @dale

Thank you for the feedback!
The sample you provided works fine, so there are no problems with the doc. Digging in to find out the reason of such behavior.

Thank you!


What if you wan to select with the GUIDs. so not to select anything else.

It is still super slow, Imagine because it needs to run by each GUID so when you have 6000 it just takes for ever

Any ideas on how to speed this up?

It shouldn’t take very long at all with only 6000 IDs. How are you doing this? Did you cut the screen redraw while selecting? Otherwise the screen will redraw after each object - and that will be slow. For 10K objects here, even looping through each GUID individually with rs.SelectObject(obj), it still takes only about a half second. 0.05 seconds if I use rs.SelectObjects(objs) on the whole list.


Thanks for the quick reply!!!

I’m trying to select within the rhino document.

So in C# if I do this:

Rhino.DocObjects.Tables.ObjectTable ot = Rhino.RhinoDoc.ActiveDoc.Objects;

  bool nSelected = ot.Select(ID);

or this


or for that matter any other combination using GUIDs it takes foerever

If I do this:

  Rhino.RhinoApp.RunScript("SelAll", true);

It’s instant.

and then trying the python version. ( I’m not too good at python)

if I try this

import rhinoscriptsyntax as rs

if T :

Nothing get’s selected.

I’m trying to select it within the rhino doc, not bring it into the GH

I don’t know if I’m making too much sense

Thanks for your help :slight_smile: