Rhino.Inside how to load plug-ins, GH add-ins without registry info

I’m trying to get Rhino.Inside (inside a command-line application) to load my plug-ins and Grasshopper add-ins. This works nicely if they have been loaded once into Rhino itself, as that results in each plug-in getting registry information, but on a system where there is a clean Rhino install without any plug-ins having been registered already, Rhino.Inside does not load my plug-ins (which is of course totally logical, it has no knowledge of where they are).

How do I tell Rhino.Inside where to look for my .RHP and .GHA files?

1 Like

One thing that works is to completely register a plug-in in the registry, just as if Rhino had already loaded it once. Once a plug-in is registered it gets loaded, and any grasshopper components are found there are loaded as well.
It would still be nice to just point Rhino.Inside somewhere to look for RHP and GHA files. @stevebaer do you have any hint here how to do that?

Your command line app could manually call PlugIn.LoadPlugIn with the paths to the plug-ins you want loaded.

Once our plugIn has loaded (and also been launched) in rhino, can we communicate with it? As in call methods defined in the plugin? For example, if I was writing a script in rhino, I would get the plugin from its public static .Instance property. But in my Unity script this returns null, even though I can clearly see it exists in Rhino.

edit: as a use case/example I would like to be able to call the same methods that my WPF UI calls in rhino, from unity. this way I can build a Unity UI quickly. I would not want to have to expose a rhino command for every UI object (probably wouldn’t work anyway because the UI is dynamic)

Hey @wesmcgee,

Are you referencing the assembly in your script to call the Plugin.Instance? There might be issues with app domains there.

I’ve used this method successfully to find the active plugin myself when Instance failed.
https://developer.rhino3d.com/api/rhinocommon/rhino.plugins.plugin/find

var plugin = PlugIn.Find(new Guid("my plugin id"));

Thanks for the reply. Yes, we are referencing the assembly in the script, and we have also tried Plugin.Find(). I suspect you are correct about the app domains.

Do you have a script that can be used to try replicating this scenario?

We did build an empty plugin to test with, but we get the same result with “any” plugin. For example,

Guid guidRhinoRender = new Guid("4f793ad6-60ce-4aaf-8a7e-6e36c752486c");
bool isLoadedRhinoRender = Rhino.PlugIns.PlugIn.LoadPlugIn(guidRhinoRender);
var pluginRhinoRender = Rhino.PlugIns.PlugIn.Find(guidRhinoRender);

We obtain the Guid from the Dictionary returned by GetLoadedPlugins. isLoadedRhinoRender is true. pluginRhinoRender is null. Just to clarify, this is in the Unity script. These methods work fine in in a script run in rhino.

We manually load our plugin when we run the logic in our Rhino Skin for our Rhino Scheme. The same type of code should work for you I suspect.

Thanks,
Well, I think the plugin is loaded just fine, we just can’t “access” it. Rhino.PlugIns.PlugIn.Find(guidRhinoRender) should return the instance of the plugin (which we would then cast to the correct type for it. But it returns null. Of course we are testing with out plugin, not the RhinoRender one.