I have a Grasshopper script that runs for 40 minutes. After it is finished, I would need to tweak some parameters (e.g. a number slider from 4 to 7, and change a string input). Then I would run it again.
The problem is, I may need to run it a couple more times but I would like to set everything up so I could leave it run overnight.
I could think of copying the whole script (very heavy) and pasting next to it, but then this would make it very very heavy.
Is there a better way to automatize this? perhaps using a external python console? I am always willing to learn more on the coding front, as long as someone could point me to the right direction.
Attached is something i thought about. Like maybe saving a state and have every state run one time.
Actually the more I think about it, I think it would be best to control and run my grasshopper scripts externally, like with a Python Console or PyCharm. Because I have multiple scripts, each script may run for quite some time, and they are dependent on each other.
I am building a script that export two CSV files on the server, which will then be read by another script.
And in my mind I am thinking about having a python console read the output of the first script (maybe as form of a boolean). Once it is done, the second grasshopper script will run.
The second script will have to run a couple times, each time with different “Save State”.
Is it possible at all? If anyone could point me to a right direction, like a documentation or some sort, I could figure it out on my own.
I really don’t want to condense all the different scripts and save states into one file…
Edit: Can I get some help or pointers?
Edit: I wonder if it is not possible. if so, I would just build everything in one script.
There is a so called GrasshopperPlayer in Rhino7 to run definitions.
But, you could also use Python to initialize a Grasshopper instance and execute a definition. This is quite advanced, but doable. Of course, you can also load and modify components like this. Decompiling Grasshopper is quite handy for this sort of approach.
The question is rather, if it’s worth to implement these hacks? Have you considered optimizing your definition for faster execution? 40 minutes sounds quite long. Unless you are doing plenty of boolean operations on your geometry, there is definitely room for improvement.
And if both things won’t work for you, you can always use a ‘Integration’-testing framework to automate the manual clicking procedure. With modern tools, it’s even easy to implement an automation event based (e.g. a color at screen position xy has changed). Since Grasshopper on Windows is WPF/Win32 based you can also use WinSpy to get more information about Grasshopper views and use this as well.
For simple automation, you might want to check pyautogui. For more advanced tools, check Appium( (with WinAppDriver), AutoIt etc…
Big thanks for the reply!!! finally a helpful friend !
Yes unfortunately. The script runs a lot of Ladybug simulation and if you are familiar with it. 40 minute for those components are not exaggerating.
But reading your answers, I realize Grasshopper can still be externally hacked into with WinSpy and pyautogui. I will look into those later.
But for now I will probably try out GrasshopperPlayer and maybe just keep optimizing the script. I see that there is no shortcut to what I want to do.
Big Thanks anyway!!