Grasshopper

algorithmic modeling for Rhino

Stop C# component output from updating unless condition is met

Hi all,

I'm trying to stop my custom component from running unless one of the input is "True". However, if I am changing an input boolean toggle from True to False, it will reevaluate and the output will be lost.

Effectively, this means I can't use the Button component to rerun the analysis in the component.

Is there a way to resolve this? I have looked at this thread: http://www.grasshopper3d.com/forum/topics/data-be-dammed but unfortunately there is no answer there.

Views: 998

Replies to This Discussion

The problem is that your component expires before you know what the new data will be. So there's no way to securely decide at expiration time whether you really want to expire or whether you want to ride the next solution out and keep your old data.

There are some solutions:

  • Cache the last solution along with the input values and assign it immediately to the outputs. This will allow you to cut down on computation time, but the downside is that everything downstream from your component will still need to be solved again. So, not a very good solution.
  • Try and figure out whether the boolean comes from an object you can inspect, such as a Button or Toggle. At expiration time you can look at the source objects of your boolean input, and, if it's a Toggle read the current state. and decide based on that. You could even choose to display a warning if the source isn't a toggle.
  • Always refuse to expire when your sources change, but then triggering a second solution to run after the first if it turns out that the boolean value was True. You can solve your component inside this second solution.
  • Override the attributes of your component and add a button to it. Then you keep full control over whether the component is supposed to keep or recompute its outputs. However it also means you cannot control this behaviour logically, it will require the user to click on a button.

To "Override the attributes"...

Wouldn't this be a compromise?

Its the same component both times...

NOTE: used ZUI-Interface to toggle between Input and Button...
(source < note inherentation "GhComponent_ToggleSwitch")

Greets
Mark

Attachments:

Thanks, caching the results will be fine for now.

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service