Simulate a button click with python

python
(Mesrop Andriasyan) #21

Thank you @seghierkhaled. That’s exactly what I needed.

1 Like
(Michael Pryor) #22

The only thing that isn’t spectacular there is now you need to keep a timer on all the time.

1 Like
(Seghier khaled) #23

i use enable/disable object for the timer
timer2.gh (6.1 KB)

2 Likes
(IVELIN PEYCHEV) #24

:slight_smile: The script was added to this thread see:

#25

You could simplify things by also scripting the GHPython component to update itself (i.e. instead of using a timer and plugins). This function should do it:

import Grasshopper as gh

def updateComponent(interval):
    
    """ Updates this component, similar to using a grasshopper timer """
    
    # Define callback action
    def callBack(e):
        ghenv.Component.ExpireSolution(False)
        
    # Get grasshopper document
    ghDoc = ghenv.Component.OnPingDocument()
    
    # Schedule this component to expire at interval
    ghDoc.ScheduleSolution(interval,gh.Kernel.GH_Document.GH_ScheduleDelegate(callBack))
4 Likes
Flicker a true (mimic button press)
(Michael Pryor) #26

Finally :smiley:

1 Like
(Seghier khaled) #27

I see that in other thread but i have 0 knowledge in scripting with grasshopper

(IVELIN PEYCHEV) #28

:wink:

I wanted him to search the forum a little bit

#29

That isn’t necessary, the code I posted above should work in the “normal” GHPython scripting component.

1 Like