Hi,
Fairly simple question but I cant find it.
Would it be possible to set a ‘timer’ for a boolean (toggle)?
Meaning, when the boolean is set to True → keep 5 sec True → hereafter return to False.
Many Thanks!
Hi,
Fairly simple question but I cant find it.
Would it be possible to set a ‘timer’ for a boolean (toggle)?
Meaning, when the boolean is set to True → keep 5 sec True → hereafter return to False.
Many Thanks!
Hey there,
I had to solve a similar issue to have a looping script. But this doesn’t run upon setting the boolean to True. It runs by itself with a 5s interval.
To get a set to True > 5 seconds > False you could work with time.sleep(5) but that’ll also freeze your GH for 5 seconds.
Another option is using a data dam connected to a toggle in front and the python block in the end. Use a (2s / 2s / 1s ) time on them to get 5s. I attached a script below with all 3 examples. Goodluck!
examples-timer.gh (9.4 KB)
There is a timer component in Peacock plugin.
You can put in max value and build a condition for changing the boolean value.
Here’s a quick variation of an old GHPython counter/timer that might work for you:
May I ask how you got that specific UI/background in grasshopper?
FroGH has a “Toggle Autostop” component that sets Toggles to False when a given condition is met.
I have adapted @AndersDeleuran’s timer to work with said component in the attached definition.
Timer stop on condition.gh (10.6 KB)
If one needs to stop updating once we hit the target, one can add an else statement here:
I forget, but think using this old script:
Ahhh, just checked out the froggy file. You can update the code within the if statement starting at line 35 to set the value of the input boolean toggle back to false:
Hi,
Thanks all for the posted solutions :).
Unfortunately I didn’t describe the problem specific enough I am afraid.
See the gh file below.
After a click on a ‘button’, the output is only a very short time ‘True’.
The thing what I am trying to achieve is that theoutput is ‘kept on True, for e.g. 5sec’, after being returned to False.
Any suggestions?
Many thanks:)
The logic might be a bit off prior to clicking the button, but something like this maybe:
Hi there. This is a wonderful script! Thankyou!.
I would like to know if there is a way to loop this based on a specific cycle count? I want the True-False to repeat 5 times to trigger 5 times on a boolean component of a grasshopper file export module.
I am noob in GH and it doesn’t work if I try to put the code into a FOR loop. Hope you can give some advice. Thanks