Properties window slowing down object selection


#1

Hello!

Whats the best way for selecting thousands of objects in Rhinocommon? I have an issue whereby automated selection is very slow as soon as the object properties window is open. I have tried a number of selection commands, along the lines of:

List<> nextGuids = new List<>() // thousands of guid objects - guids of objects in Rhino document

//Option 1
Rhino.RhinoDoc.ActiveDoc.Objects.Select(nextGuids);

//Option 2
foreach (Guid guid in nextGuids)
{
Rhino.RhinoApp.RunScript("_SelID " + guid, false);
}

//Option 3
foreach (Guid guid in nextGuids)
{
RhinoObject rO = Rhino.RhinoDoc.ActiveDoc.Objects.Find(guid);
if (rO != null)
{
rO.Select(true);
}
}

When the properties window is open, selection takes up to a minute for about 10000 objects. When closed, the same Operation only takes a few seconds. Is there a way to disable the properties window (or relevant event handlers) temporarily?

Thanks,

Daniel


#2

Yeah thats possible to close that panel before the command and open it after again:

UI.Panels.ClosePanel(UI.PanelIds.ObjectProperties)

Think there is an Openpanel also there :smile:
Maybe to make it faster you can also try
  RhinoDoc.ActiveDoc.Views.RedrawEnabled = False

and at the end true. So the visual stuff will be shut down and activated later again. this Can make a command run a couple of times faster :wink:


#3

thanks, yes, I’m already disabling redraws to speed things up.
Actually closing panels seems to be a bit cumbersome I guess. Also, I’d have to reopen them afterwards etc.
Maybe writing a custom Selection Command and passing the nextGuids list could help?
I guess this would put Rhino into the InCommand state and disable all sorts of things.
But I thought I’d ask if anyone knew of a leaner way of going about this…


#4

in any case, I’ll use your advice for now, it seems to work well enough for now! Thanks!

       bool prop = Rhino.UI.Panels.IsPanelVisible(Rhino.UI.PanelIds.ObjectProperties);
       if (prop)
       {
           Rhino.UI.Panels.ClosePanel(Rhino.UI.PanelIds.ObjectProperties);
       }
       Rhino.RhinoDoc.ActiveDoc.Objects.Select(guidsNew);
       if (prop)
       {
           Rhino.UI.Panels.OpenPanel(Rhino.UI.PanelIds.ObjectProperties);
       }

Doc.Objects.Select(guids) fires SelectObject event for each guid