algorithmic modeling for Rhino
Hi!
I was wondering if there is a way to simulate the use of global variables in different GH definitions, like in a bigger programming environment, such as eclipse or visual studio. I mean to have parameters with geometric data that could be called and shared in different GH definitions.
I know that, for the moment, this is not possible in Grasshopper, but I would like to know if anyone had the same problem and came up with an idea on how to simulate that behaviour, whether coding or with usual components and parameters.
Cheers!
Tags:
RhinoPython has a dictionary called scriptcontext.sticky which may be used for something like this. It only "sticks" around for the current Rhino session though, but may be accessed from within any Python script (including GH components in different definitions). Perhaps there is something similar for C# and VB..
Hello Anders!
Thanks for your reply.
I´ll take a look at that dictionary and see if there´s an equivalente in .NET.
Can you not just put all of the definitions you need to address form other environments on one grasshopper page and keep that running?
Do all the .gh files reference the same items in same rhino .3dm? / or OSC info? / other ? if so you could copy points in a bigger .3dm / or share the OSC data from one component in a combined definition.
Do they all use kangaroo or another component which maybe cant be in two places? Correct me if I'm wrong but I think that's true of Kangaroo..?
I wonder would this be useful?
Private doc As RhinoDoc = RhinoDoc.ActiveDoc
in VB Script (VB) component
could that be called on to change to sourcing form different definitions ?
newbie guessing ...you may end up needing to run another grasshopper plugin inside grasshopper But I have absolutely no idea of how that would even begin to be possible
Probably not exactly what you had in mind: but what about saving the data to a file? Then it's truly global and persistent. The drawback is that it' costly in terms of performance...
For proper global variables you should indeed use a file as stefan said. If it's only a few simple data types you could also use the Grasshopper settings SDK. Let me know if you want to know how to access it.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks to all of you!
Definetely, perhaps, the best way would be to have a temporary file to save the document´s geometry.
I´ll keep you posted!
Hi David I'd like to access a few simple global variables (numbers, strings) - could you explain further how to use the Grasshopper settings SDK to access these from any Gh document? Thanks!
Step 1, create a new settings server and pick a name that applies to you and only you.
Step 2, start setting or getting values from that server.
Step 3, if you set values, then you must call WritePersistentSettings() before letting the settings server go out of scope, otherwise it will not update the file on disk.
When you call WritePersistentSettings(), there will be an xml file in the Grasshopper settings folder (accessible via the File->Special Folders->Settings menu).
Dim settings As New Grasshopper.Kernel.GH_SettingsServer("my_plugin_settings")
settings.SetValue("setting1", True)
settings.SetValue("setting2", 14)
settings.SetValue("setting3", "hello world")
settings.WritePersistentSettings()
Thank you David this is very helpful.
A somewhat similar request would be to have the ability to hold a user dictionary within individual Grasshopper documents, much like Rhino's SetDocumentUserText command. Is this currently possible?
You could make a dll with a static field and link it to you c# componenet as a assembly. I think this should work.
public static class Collection
{
public static int MyGlobalField;
}
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by