hello, I’ve been trying to use an external python script to start a grasshopper definition using the python rhinoinside module.
so far it isn’t working and I can not figure out why, it is crashing in the openDocument.
here is the code:
import rhinoinside
import clr
# Load Rhino.Inside
rhinoinside.load()
# Import necessary namespaces
clr.AddReference('RhinoCommon')
clr.AddReference('Grasshopper')
import Rhino
import Grasshopper
# Load the Grasshopper document
gh_file = r"C:/Users/abc/Desktop/RunTest.gh"
gh_doc = Grasshopper.Instances.DocumentServer.OpenDocument(gh_file)
# Set input parameters
input_params = gh_doc.Objects.OfType[Grasshopper.Kernel.Special.GH_NumberSlider]()
for param in input_params:
if param.NickName == "Slider1":
param.Slider.Value = 5.0
# Compute the Grasshopper document
gh_doc.NewSolution(True)
# Get the output parameters
output_params = gh_doc.Objects.OfType[Grasshopper.Kernel.Special.GH_NumberParam]()
for param in output_params:
if param.NickName == "Output":
print(f"Result: {param.VolatileData.AllData(True)[0]}")
has anyone been able to do this?
Thanks in advance.