How to Really stop send things to output?

(I am writting custom component in vs,c# script is just for demo because fast to demo)
first,we have a "BB"component,it output something at every 100ms.
When we update one input item of input list(for example “XX” in picture) ,then the “BB” componenrt will read all input and do solveinstance() .
my question is:
When the “XX” is updated and “YY” is “False”,how to prevent the component to do solveInstance() and prevent to update output? because I just want to do solveInstance() when “YY” is “true”.
you will say that when YY is “false”,the output of BB is Null,it seems no output,But in fact ,BB also remain keeping send Null to output continusly(you can see CC component’s output is keep changing always),I just want to know how to make BB component to REAL stop sent Null to CC,when YY is “False”.
Thank you!
image
stopsend.gh (8.1 KB)

This is very difficult, and may not even be possible with a component. You may need to create a custom object to override all the solution logic.

The order of events in Grasshopper is:

  1. Something happens which expires an object (timer tick, mouse click, event handler invoke, …)
  2. This object expires all objects which depend on it.
  3. Those objects expire all objects which depend on them, and so on until there are no dependent objects left.
  4. A new solution is started at the document level.
  5. One of the expired objects is selected (might as well be at random) and asked to compute new data.
  6. This object asks all its input objects to solve themselves. This wave of compute requests sloshes up the network until all source objects are solved.
  7. Pick another unsolved object and solve it until no unsolved objects are left.

So in your case, what happens is:

  1. Timer expires AA.
  2. AA expires out.
  3. AA expires A.
  4. A expires panel.
  5. A expires XX.
  6. XX expires BB.
  7. BB expires out.
  8. BB expires A.
  9. A expires panel.
  10. A expires x.
  11. x expires CC.
  12. CC expires out.
  13. CC expires A.
  14. A expires panel.

You’d have to get into step 5 or 6 and stop that train. Then when the solution comes around and it turns out YY is false you don’t have to do anything. If however YY is true then you need to still not do anything now, but you have to schedule another solution and expire yourself before that solution starts.

This is why objects like the Data Dam have custom UI, to avoid having to rely on a boolean which might not be known at all times.

Isn’t it simplier to simply store the value of XX to a global variable, if it was python it might have been sticky. Then pass this global variable to A. If YY is true. Pass the XX to A.

If the XX is not changed expire(false)

I hope I get the idea correctly.

Global variables are almost always a bad idea. If you have two of these components they keep overwriting each other’s data.

I’m not 100% clear on what you’re suggesting though. If you store XX in a global (or class level) variable, you can assign it again to A if you like, but that’ll still cause a full recalculation of everything which depends on A. Doesn’t matter that you assign the same value as last time, it’ll recalculate it anyway.

At least you can stop the computation of the components when the input receives the same data as before, and also with a variable (like YY) or with the conditions you want. The components will continue to run, but you can exit SolveInstance() with some logic.

1 Like

not if you add the guid as prefix/suffix of the global variable name.