Objects selection via code is much slower than via viewport

rhinocommon
performance

#1

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;

1:
RhinoDoc.ActiveDoc.Objects.Select(objectIds);

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

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

4:
var refs = objectIds.Select(item => new ObjRef(item));
RhinoDoc.ActiveDoc.Objects.Select(refs);

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)

Thanks,
Julia


#2

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

rs.AllObjects(True)

or

rs.ObjectsByType(8,True)

?? --Mitch


(Dale Fugier) #3

Hi @Yuliya,

How about this?

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  foreach (var obj in doc.Objects)
    obj.Select(true);
  doc.Views.Redraw();
  return Result.Success;
}

– Dale


#4

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!