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.
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:
Check for updates (script already does this)
If there is an update then unload the plugin that is running
Then copy new plugin over
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.
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.
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.
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.
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?