How can I access a Rhino plugin's dock panel in a Grasshopper plugin

first asked here but reposting for appropriate category

a rhino Plugin containing the following

using System;
using Eto.Forms;
using Rhino.UI;
using Rhino.PlugIns;
using System.Runtime.InteropServices;

namespace SomePlugin
{
    public class MyRHPlugin: Plugin
    {
        public MyRHPlugin() { Instance = this; }
        public static MyRHPlugin Instance { get; private set; }
        public UserPanel MyPanel {get; set;}
    }

    [Guid("1234")] // random guid here. no problem
    public class UserPanel: Panel
    {
        public UserPanel(){ }
        public static Guid PID
        {
            get { return typeof(UserPanel).GUID; }
        }
    }
}

and in a separate Grasshopper plugin I have this

// abbreviated code above...
protected override void SolveInstance(IGH_DataAccess DA)
{
    // DA gets all inputs...abbreviated
    Guid id = new Guid("9876"); // correct id for the plugin
    
    if (!PlugIn.GetPlugInInfo(id).IsLoaded) { return; }
    
    MyRHPlugin myplugin = PlugIn.Find(id) as MyRHPlugin;
    DA.SetData(0, myplugin.MyPanel.ToString()); // this line is where debugger encounters error
}

when this runs, i encounter a null reference error. it says the getter returns null.
how can i access that panel in my GH plugin? like reading textboxes

I’ve omitted the loading part. that part works. the panel shows correctly in rhino

Do you assign the loaded panel object to the property MyPanel?

2 Likes

You can subscribe to the panel load event to assign the MyPanel like: MyRHPlugin.Instance.MyPanel = this; and it will happens when you open the panel somehow.

1 Like

I was wondering where it’d be instantiated. I thought Rhino took care of that.
Thanks guys. Working now.