Hello, I have a problem dealing with Grasshopper button components and accessing them from a python script to “simulate” a click, by means of the Grasshopper API.
[Context] I have a GH solution consisiting in multiple phases where I have to bake geometries in different layers. Such layers are taken as input by other GH nodes in the pipeline.
I’m writing a python script to test the overall workflow, but I cannot figure out how to “trigger” GH buttons.
I’ve tried to change the bool value of the button component’s
ButtonDown property, but I don’t understand how to “refresh” the solution and generally how the solution pipeline works, that is: do I have to expire the component which I am modifying? do I have to expire the entire solution? how does the solution scheduling works?
I also tried to ignore the button component, and to manually feed the downstream component with a temporary
True value, but again, I do not figure out how to recompute the solution.
trying to change a node input/source triggers the message “
The X object expired during a solution”.
I don’t understand how I can control the fact that the solution is being processed or not.
Futhermore, the button node click should trigger another node which finally bakes an object to the model, and I need to get that baked object by means of
rhinoscriptsyntax.LastCreatedObjects() and go on with further testing on that.
As far as I could understand, the solution expiration/recomputation cannot be forced in a synchronous way (it is rather scheduled).
In the end I solved the issue by using separate sequential scripts, so that between one and the other the grasshopper solution “has time” to expire ad recompute.
So, everytime i need to simulate a button component click, I set its value, expire the component and end the script.
The following script starts the workflow execution where the previuos one was left off.
That’s quite of an awful hack, but it worked.