Hi forum. I do need to delay somehow the press of a button for around 0.2 seconds to trigger different bake components in a very specific order all from the same button trigger and I do need a way to add a delay time between triggering different components.
If somebody have a solution for this issue, please post here. Best regards.
Unfortunately this script runs as soon as I open my definition. How I can prevent this loop to start when open the definition? I do need to run only when I do press the Button.
I ended up with this Frankenstein solution. Maybe somebody more skilled than me can find a better way to solve this problem, but for now this is the only way I found that really works.
I don’t have all those plugins installed, so I’m not exactly sure what you’re trying to achieve, but something like this looks like it might work/be edited to work:
I need to delay the press of a button. I do tried a lot of Python solutions but unfortunately all of them begins to run as soon as I open the definition. This 231111_TimerWithBooleanFlag_00.gh one it is no exception.
I do need to have a True value after 1s after I do press the Button and not before. On release state I do need only False values. Something like: False, Button press, wait 1s, switch to True for 0.2s, after that to return to False state.
import rhinoscriptsyntax as rs
import ghpythonlib.components as ghcomp
import time
def delay_button(button_state, delay_ms):
if button_state:
time.sleep(delay_ms / 1000) # Convert ms to seconds
return True
return False
# Use the input parameters
a = delay_button(x, y)
it seems time.sleep() function will pause the entire Grasshopper canvas, rather than maintaining state over time. I’m not expert in phtyon, maybe someone knows how to do it, with native components