Add a Grasshopper Plugin Folder Path via Script

Hello everyone,

When I run the GrasshopperDeveloperSettings command, I can manually add plugin folder paths so Grasshopper can load custom components from those directories.

I’m wondering if there’s a way to add a folder path programmatically, either by using a batch script or a Python command, so I don’t have to add it manually every time.

Has anyone done this before or knows how to achieve it?

Thanks in advance!

I’ve moved you over to the Grasshopper Developer category as that should help you find more relevant results :slight_smile:

1 Like

It depends who it’s for, and how your users will install your plug-in. I use .ghuser launcher components that put my package’s path in sys.path, import it, then restore sys.path.

If you’re using CPython3, publishing to PyPi is an elegant solution. I’ve not tested it, but if the #r: syntax lets you point to a url dependency specifier, then you don’t even need PyPi.

1 Like

You could edit the contents of grasshopper_kernel.xml in %APPDATA%/Grasshopper before you load Grasshopper.

Paths defined in GrasshopperDeveloperSettings dialog are stored there in a | separated string.

 <item name="Assemblies:Folders" type_name="gh_string" type_code="10">C:\example\plugin1\bin\|C:\example\plugin2\bin\</item>

But just to be clear.
When using the command dialog - you shouldn’t have to do it everytime. You only need to do it once.

Beware that any changes made using the command dialog are persisted only if you exit Rhino properly. Killing the rhino.exe task via Task Manager or from Visual Studio by stopping the debugger will make it fail to save your changes.