Button click delay?

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.


Delay Button Press for 0.2sec.gh (1.7 KB)

I do found some inspiration here: Triggering a button - Grasshopper / Kangaroo - McNeel Forum

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.


Delayed_Button_Press.gh (7.1 KB)

1 Like

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)

Thank you for replay. Unfortunately I can’t see any improvement. I do miss something?

Timer with delay.gh (3.2 KB)

Hi @Cumberland,

If you are using Anemone you can use ‘Time Buffer’ like this.

Uncheck ‘Multithreaded’ to make the wait synchronous.

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

here a related post: Grasshopper Timebuffer with Ghpython - #7 by antoinemaes