Internalize Timer in C# - Simple Counter

I made a comment on line 15 where one can set the update interval (I just hardcoded it back then for simplicity). Attached a version that exposes this as an input parameter and also slightly changes the logic to have a Run state boolean toggle and an explicit Reset button:

191228_GHPython_Timer_00.gh (4.5 KB)

That certainly sounds pretty convoluted. Between the if "foo" not in globals() approach to creating persistent variables and the updateComponent() function, you can probably solve most dynamic storage/iteration situations in a more straightforward GHPython manner I imagine. The one issue I can think of here is that the DataRecorder doesn’t expire downstream components while recording (if I recall, might be confusing it with the data dam).

Sidenote: Generally speaking for dynamic pipelines, I tend to separate the iterative feedback loopy stuff (which typically happens upstream) from the logging/recording stuff (which typically happens at the end somewhere downstream).

Edit: Slight update to have Reset go to zero while running:

191228_GHPython_Timer_01.gh (4.5 KB)

4 Likes