Use of trigger in combination with stream gate?/

Hi, I am looking to combine the use of a stream gate with a trigger component. To test this idea, I made the following program

  1. There is a trigger that updates stream gate. One target connects to a python component, the other to another py component.
  2. The Python component increments a ‘tick’ variable in the globals dictionary. (the python component is simply placeholder for standard components eventually)
  3. I expected only one of the Python components to re-execute. However both rexecute every trigger interval, despite one having input wire that is orange (no data)?

I can find other ways to solve this through Python, but wanted to know if I can achieve it without scripting.


TestingTriggerTimer.gh (33.5 KB)

Check x for input. Increment only when it is not None:

if x: ticks += 1

Hi thanks Nathan for the suggestion. I wrote the python component with some arbitrary code as a placeholder to be substituted eventually. But I just want to clarify that an orange wire carrying no data will still cause a component (not just scripting components) it is connected to to expire solution and SolveInstance again?

I believe there will always be a solve instance, but it is up to the component to ensure no unnecessary calculations are performed. In general when something like this is set up you’ll find that downstream components all turn orange to show data is missing.

If you don’t want all the connected components down the line to thrown warnings, because they aren’t getting any data at relevant inputs, you could always define a default value that your component outputs when it has nothing else to compute.

You could refactor your code to this:

if reset or 'ticks' not in globals():
    ticks = 0  # default to zero

if x:
    ticks += 1

a = ticks

Note how it’s not necessary to push a ticks value (e.g. 0) mapped to the key “ticks” into the globals() dictionary! This is because the latter is a global symbol table that is maintained by the compiler and keeps track of all information - including created variables - from the global scope.

You probably meant to put a = ticks in the if x block. Or not… don’t know. I suppose the default way for GH components is to not pass on any data when they haven’t received all the data they require for their computation.

Not really, as mentioned in my previous reply this is an example where ticks defaults to 0.

Hi thanks both for the replies.