Automate Grasshopper

Hi,
We want to automate our process of creating models and have a few questions.

Our use case is to trigger Grasshopper runs remotely and headless but we cannot seem to find the correct documentation.
We are trying to use a python script that loads Rhino and executes a separate script in the Rhino environment. We cannot find how to do that correctly.

Our system provides parameters that needs to be passed over to grasshopper (String parameters, numeric parameters, files) and our expectation is that it will give us an output model file that can further be used in our production chain.

When asking ChatGPT it suggested something like this:

open_result = rhino.RunScript(f'_GrasshopperOpen "{gh_file_path}"', True)
if not open_result:
    print(f"Failed to open Grasshopper file: {gh_file_path}")
    return

# Wait for Grasshopper to fully load the file
time.sleep(5)

# Construct the _GrasshopperPlayer command
param_string = ' '.join([f'{key}={value}' for key, value in params.items()])
gh_player_comm

which looks good but it doesn’t work as expected. Could someone provide any documentation or maybe a working example code block with which we can make it work?

Thanks in advance and regards,
K.

I am no expert, but don’t you need to use the Grasshopper Player from Rhino?

1 Like