Updating a plugin while Rhino is running

I have created a company Rhino environment that I distribute within the company. This shares model templates, Grasshopper Toolbars and a small plugin containing some commands and a toolbar.

The way it works right now is that every time a user opens Rhino through the desktop icon it executes a little python script that ensures that the users have the newest company settings and so forth. It is basically a glorified file copier. :slight_smile:

My problem is that the .RHP plugin for the environment will not update with this method. Because it seems that plugins cannot be loaded / overwritten when the user has Rhino open.

Is there a way around this in python?

I was thinking the process would be:

  1. Check for updates (script already does this)
  2. If there is an update then unload the plugin that is running
  3. Then copy new plugin over
  4. Reload plugin

Is this possible? There seems to be some code to unload, but I have not been successful in getting it to do this.

Hi @mpd,

If the plug-in is loaded, then you’re stuck. Plug-ins are not unloadable.

A solution is to make sure your plug-in does not load when Rhino loads. That is, your plug-in should load on-demand.

public override PlugInLoadTime LoadTime => PlugInLoadTime.WhenNeeded;

– Dale

1 Like

I am not certain but i think you might be able to host a company internal yak package manager on a shared network drive. I am not sure whether rhino will auto-update on each launch from such a package repository like it does from the main one. Might be worth exploring though.

1 Like

For Python plug-ins, I achieved something like hot reloads (primarily for my own convenience when developing) by adding a little auxilliary component that deletes all the plug-in’s packages from sys.modules. Launcher code doesn’t get updated (though a lot is possible with Python components, if you think updating the components the user has already placed is a good idea at all). All the code to be updated and hot reloaded must go in the package.

My understanding is that .rhp’s must be installed via Yak or click and drag, and then Rhino restarted. Also, both C# and compiled Python components are fixed to the version of the plug-in that was installed when they were placed on the Grasshopper canvas, so users of those must rebuild their worksheets with new components from the updated plug-in.

If this is for during development on your machien you could either write functions in the Script Editor.
Or use Visual Studio 2022 and its HotReload functionality - I use it dozens of times a day to update code in the plugin I write while developing. It has some limitations but really does shorten the development cycle.

I am back from vacation and finally had a moment to look at this. It seems to me that setting up a yak is a good solution so that this runs through the package manager.

Rhino - Custom Package Repositories

As I understand it I will need to add my path to my local company network drive to this variable Rhino.Options.PackageManager.Sources.

Then I can just drop in my .rhp files into that network path or will I need to package my plugin differently?

Will try and set it up on my local pc. I could not find any info on wether it would update when a new version is available.

I believe it will update each time Rhino is launched as controlled by

The package manager requires a .yak package file, not just an .rhp file.

– Dale

I got this working. Very easy, just distribute the path to all members of the environment and since my plugin is already made with the Rhino 8 script editor I could easily produce the yak file from there.

I am struggeling a bit to get it to automatically install it through the yak but at least it was easy to get it in there. Rhino - Yak Command Line Tool Reference

At least it claims that it can’t find the package. But that was also just with the ChatGPT code, so I will try and mess around and see what I can find. :smiley:

Thanks for the help so far.

1 Like

I am a bit stumped on how to change the attribute Rhino.Options.PackageManager.Sources under the advanced settings to point to the correct area in the local network.

Is there a way to set this attribute through command line or python so I can automatically turn it on for all users?

Figured it out. I was overthinking things. Just yak install package in the original BAT file that copies the other files.