Properties window slows down object selection

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;
    }

}

Hi @dgebreiter,

I made a crapton of objects and ran the attached command. Here are my results:

ObjectProperties panel is hidden.
Option 1 took 4228 milliseconds.
Option 2 took 3907 milliseconds.
ObjectProperties panel is visible.
Option 1 took 4190 milliseconds.
Option 2 took 3902 milliseconds.

Try this: open the Properties penal and then select some object. Now run some command (e.g. Point). Notice how the Properties panel switches to the Viewport page? Then you run a command, the Object page is disabled for performance.

Also, this is the RhinoCommon equivalent to the SelAll command.

public class TestSelAll : SelCommand
{
  public override string EnglishName => "TestSelAll";

  protected override bool SelFilter(RhinoObject rhObj)
  {
    return null != rhObj;
  }
}

TestCs6Command.cs (1.8 KB)

– Dale

Hi Dale,

thanks for getting back to me. I am now trying but failing to emulate the behavior to switch to the ObjectProperties->Viewport tab during my operations.

I thought I’ll somehow select the properties panel and then set the PageType to View. However, this property is read-only.

Rhino.UI.ObjectPropertiesPage op = Rhino.UI.Panels.GetPanel<Rhino.UI.ObjectPropertiesPage>();

op.PageType = Rhino.UI.PropertyPageType.View; //read-only!

How to I switch to the correct page?

Many thanks,

Daniel

Hi @dgebreiter,

If your code is running from a command, this is automatic. If you code is not running from a command, then you might have your code script a test command that does what you want.

– Dale