Hello, I am struggling to find the best way to reuse components in my scripts.
I am working on a script that uses many externally referenced ghclusters. These clusters appear throughout all levels of the script: on the highest level (i.e. the main GH file) but also inside other clusters. Because these ghclusters are externally referenced, I can make an update to the base file, and then every instance of that cluster knows that a newer version exists, and I can update them (manually).
The point is that when I distribute this script to other users, the end users will not have the directory available where we stored the externally referenced clusters during development. So I would like to package and distribute the clusters with the script. Ideally I would like to use a relative path reference, but that does not seem to be possible.
I also did a test with just using simple (unreferenced) ghclusters: create a cluster ‘A ‘ in the main GH script. Then create another cluster ‘B‘ where you use that other cluster ‘A‘. Then go back to the main script, make some changes to A, save and close. Then see if the version of ‘A‘ inside ‘B‘ has updated, but that doesnt work.
I spoke with AI and they proposed to use UserObjects. I could package a bunch of UserObjects and distribute them with the script. Then ask the end users to copy the userobjects to their userobjects folder, and it should work. So I did a small test, trying the same thing as described above: make a UserObject, use it in a main GH script, also use it inside a cluster. Then make some changes to the userobject (open, make changes, save and close) and then see if it has updated in the script and in the cluster. The answer is NO (!!).
For starters, I see that the userobject file in the userobjects folder doesnt even update, as the ‘Date modified‘ field doesnt change after I made changes. This confuses me so much. How am I supposed to do this?
I read this post (Updating user objects - Grasshopper - McNeel Forum) and they say that you should manually delete the old userobject, create a new one manually, then replace all instances of the old versions with the new version manually. Is that really the case?
The thing is that the externally referenced ghclusters (kind of) work the way I want to (except I dont like the manual updating). Now I just want it to work with something that is distributable.
What would you guys advise? How do you do this?
Many thanks in advance