Is there a way to press the play button on trigger component using rhino python script(NOT from inside the GhPython component of .gh file ).
OR
Is there a way to execute a GhPython component from rhino python script,since the trigger is executing that component only
I was able to get here, But, I don’t see any methods to trigger the component’s button.
import Grasshopper
ghdoc_server = Grasshopper.GH_InstanceServer.DocumentServer
doc = ghdoc_server[0]
for object in doc.Objects:
if object.Name == 'Trigger':
print object.NickName
Alternatively, you can create a GhPython Script component, and control it, how ever you want.
import Grasshopper
import time
interval = 10 #ms
interval_in_seconds = interval/1000
# Define here, what happens when the trigger is activated
def doSomething(target_component):
target_component.ExpireSolution(True)
# Find the gh_comp object from canvas
ghdoc_server = Grasshopper.GH_InstanceServer.DocumentServer
doc = ghdoc_server[0]
target_object = None
for object in doc.Objects:
if object.Name == 'GhPython Script' and object.NickName == 'test_comp':
target_object = object
# Maybe you can add w ehile loop to run
# and use RhinoGet function to break
# But, here is a simpler example.
for i in range(5):
time.sleep(interval_in_seconds)
target_object.ExpireSolution(True)
HTH
Kaushik LS
Chennai, IN
1 Like
Thank you very much for the solution
one more stupid ques
how do you nickname a ghpython script component?
nvm got it TY
from Code:
# inside 'GhPython Script' component
ghenv.Component.Nickname = 'test_comp'
from Canvas:
TY again
You’re welcome.
If the solution helped you, kindly mark it as solved, and close the question.
It helps others who are looking for similar solutions.