Not Loading Rhino Plugin at Startup

Hello,

I have a developed Rhino plugin that when you launch it from the command line, its WPF UI gets docked as a new tab next to the properties panel. Everything fine so far.

The problem is that when I restart Rhino this plugin is still docked next to the properties panel and I want it just to be loaded from the command line.

Any help would be appreciated.

Kind regards,

Diego

If I understand correctly, you could close the panel when rhino closes.

If you subscribe to the RhinoApp.Closing event, then close the panel, it probably won’t be open on starting rhino again.

https://developer.rhino3d.com/api/RhinoCommon/html/Overload_Rhino_UI_Panels_ClosePanel.htm

That looks like the perfect approach, however the method Rhino.UI.Panels.ClosePanel() doesn’t seem to do anything. The plugin is still there when I restart Rhino and when I debug it step by step I don’t see any changes either.

public class MyRhinocerosPlugIn : Rhino.PlugIns.PlugIn
 {

        public MyRhinocerosPlugIn()
        {
            Instance = this;
            RhinoDoc.CloseDocument += close_plugin;
        }

        protected void close_plugin (object sender, DocumentEventArgs e) 
        {
            // This does nothing
            Rhino.UI.Panels.ClosePanel(typeof(MyPanelHost));

            // This returns a guid, but it does nothing
            var my_guid = typeof(MyPanelHost).GUID;
            Rhino.UI.Panels.ClosePanel(my_guid);

            // This returns null
            var my_panel = Rhino.UI.Panels.GetPanel<MyPanelHost>();

            // this returns the guids of the panels, but then all the items of panel_list are null
            var guids = Rhino.UI.Panels.GetOpenPanelIds();
            var panel_list = new List<object>();
            foreach (var guid in guids)
            {
                var panel = Rhino.UI.Panels.GetPanel(guid);
                panel_list.Add(panel);
            }            
          
            // this throws an error, because RhinoDoc.ActiveDoc is null
            var my_panel2 = Rhino.UI.Panels.GetPanel<MyPanelHost>(RhinoDoc.ActiveDoc);
        }
}

I also read that the plugins started from c++ are not accessible through these methods. May it be the case? Although my plugin is a .NET assembly.