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.