Hello,
it appears this old issue has once again become relevant in Rhino 6.
Selecting many objects using Rhinocommon is very slow if the object properties dialog is open.
Selecting all objects in a dcoument using “_selAll” is fast, independently of whether the object properties dialog is open.
The RhinoCommon doc.Objects.Select() functions are equally fast, but if the object properties dialog is open, the selection is followed by a delay of several seconds.
Is there a way in RhinoCommon to reproduce the speed of “_selAll”? A working way to disable the properties panel during selection?
Many thanks for any help!
Daniel
public class SelectionDebug : Command
{
public SelectionDebug()
{
// Rhino only creates one instance of each command class defined in a
// plug-in, so it is safe to store a refence in a static property.
Instance = this;
}
///<summary>The only instance of this command.</summary>
public static SelectionDebug Instance
{
get;
private set;
}
///<returns>The command name as it appears on the Rhino command line.</returns>
public override string EnglishName
{
get { return "SelectionDebug"; }
}
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
IEnumerator<RhinoObject> ros = doc.Objects.GetEnumerator();
List<Guid> nextGuids = new List<Guid>(); //guids of objects in Rhino document
while (ros.MoveNext())
{
nextGuids.Add(ros.Current.Id);
}
Stopwatch sw = new Stopwatch();
sw.Start();
//Option 1
Rhino.RhinoDoc.ActiveDoc.Objects.Select(nextGuids);
sw.Stop();
RhinoApp.WriteLine("option 1 took" + sw.ElapsedMilliseconds);
sw.Restart();
//Option 2
foreach (Guid guid in nextGuids)
{
RhinoObject rO = Rhino.RhinoDoc.ActiveDoc.Objects.Find(guid);
if (rO != null)
{
rO.Select(true);
}
}
sw.Stop();
RhinoApp.WriteLine("option 2 took" + sw.ElapsedMilliseconds);
sw.Restart();
Guid guidP = Rhino.UI.PanelIds.ObjectProperties;
bool open = Rhino.UI.Panels.IsPanelVisible(guidP);
if (open)
{
Rhino.UI.Panels.ClosePanel(guidP);
}
sw.Reset();
sw.Start();
//Option 1
Rhino.RhinoDoc.ActiveDoc.Objects.Select(nextGuids);
sw.Stop();
RhinoApp.WriteLine("option 1b took" + sw.ElapsedMilliseconds);
sw.Restart();
//Option 2
foreach (Guid guid in nextGuids)
{
RhinoObject rO = Rhino.RhinoDoc.ActiveDoc.Objects.Find(guid);
if (rO != null)
{
rO.Select(true);
}
}
sw.Stop();
RhinoApp.WriteLine("option 2b took" + sw.ElapsedMilliseconds);
sw.Restart();
if (open)
{
Guid guid = Rhino.UI.PanelIds.ObjectProperties;
Rhino.UI.Panels.OpenPanel(guid);
}
doc.Views.Redraw();
return Result.Success;
}
}