algorithmic modeling for Rhino
I am interested in packaging a custom ValueList component along with a GHA I am writing. It requires no modification to its functionality, just a pre-packaged list of values. It is easy enough for me to save the list I am interested in as a custom .UserObject, but I want it to be installed as part of a single GHA.
Is there an easy way to do this? Can I create a custom component that derives from GH_ValueList? Is there some way to package a .UserObject in to a GHA along with other custom components?
Tags:
Hi Andy,
how about you store the *.ghuser file as a string resource in your GHA project, then write it to the UserObject folder when your GHA is loaded?
You can create a class and derive it from Grasshopper.Kernel.GH_AssemblyPriority in order to be called prior to loading. Then, when the UserObjects are loaded after the GHAs, your object should appear on the toolbar.
ps. I haven't tested this.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi David -
Finally got around to trying this. Seems to work like a charm, only caveat is that the loading process seems to check the UserObjects folder BEFORE the AssemblyPriority code is triggered - so on first install, the custom component appears to be missing, but on quitting and reopening grasshopper, it loads properly. Any way around this? Can I force a refresh of the UserObjects folder?
UPDATE: I seem to have answered my own question, but wanted to leave this available in case others are trying to accomplish the same thing (and also verify that I'm not breaking any rules by doing it this way!) To cause the object to be loaded from within the GH_AssemblyPriority, I'm using GH_InstanceServer.ComponentServer.LoadAddOn(componentPath); where componentPath represents the location of the new component I am writing during loading.
Yeah it is a bit of a catch22. I check the UserObject folders before I start loading any files and I won't enable the file watcher (the piece of code that checks whether new files appear in important folders) until after I'm done loading.
I'm glad that you can solve it via LoadAddOn(), you shouldn't have had to, but at least it works this way. If you can somehow delay creating the ghuser file until the main loading is done, you should be able to have the file addition detected automatically.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Welcome to
Grasshopper
© 2025 Created by Scott Davidson.
Powered by