algorithmic modeling for Rhino
What is the right way to share some value among all opened grasshopper gh documents ? I would like to have one boolean value to control notify icon visibility, right now if I have 2 (or more) components I have 2 (or more) notify icons. So what I'm actually asking for is something like global timer toggle...
I can of course traverse all documents and search for another component with notify icon (and then decide what to do), but I assume that it's not a right way.
Tags:
If you're making a GHA project, then you can put in some global (static in C#, Shared in VB) variable that all components have access to. That's how the timer toggle works.
You can also create a static event that all relevant components can subscribe to in case the value changes, that would be a good way to inform everyone.
--
David Rutten
david@mcneel.com
Thanks, I got it to run properly(?) now. To be honest the most complex part of it was what to do on document load and save (to trigger or not to trigger, that was the question)... but I resolved it by checking stuff in AddedToDocument. Is that correct or should I override another sub ?
There are several ways to go about this, which one is best depends on specific circumstances.
If your component is liable to start doing stuff out of the blue (i.e. not as a result of SolveInstance being called), then you should probably override AddedToDocument and RemovedFromDocument. Because you don't want to keep doing stuff once you've been officially deleted.
The other two methods allow you to keep track of the state of the document you're in. Is it currently active in a Canvas? Is it about to be removed entirely? Did it just get pushed onto the backburner because another document was loaded in the canvas instead? etc.
I'd say that overriding [1] and [2] gives you all the information you need. [3] is only really useful if your logic isn't tied to a specific document, but rather to whatever document is loaded.
--
David Rutten
david@mcneel.com
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
© 2024 Created by Scott Davidson. Powered by