Rhino / Grasshopper
Rhino can be executed through command-line instructions, which also allows to execute a grasshopper script. See the Rhino documentation for more info on running Rhino from the command-line interface.
VIKTOR's Rhino / Grasshopper integration requires a Generic worker.
from viktor.external.generic import GenericAnalysis# Generate the input file(s)files = [ ('input.json', BytesIO(b'filecontent1')),]# Run the analysis and obtain the output filegeneric_analysis = GenericAnalysis(files=files, executable_key="run_grasshopper", output_filenames=["output.json"])generic_analysis.execute(timeout=60)output_file = generic_analysis.get_output_file("output.json")
GenericAnalysis.execute needs to be mocked within
the context of (automated) testing.
executable_key in the example above refers to the "run_grasshopper" command. This command should also be
specified in the configuration file on the server, located in the same directory as the worker:
maxParallelProcesses: 1 # must be one, please do not change
In this example, the worker will run "run_grasshopper.bat" when a job is received. This batch script can be used to
for example call Grasshopper which uses the
input.json file that has been sent along with the job in
"C:\Program Files\Rhino 6\System\Rhino.exe" /nosplash /runscript="-open %rhinoFilePath% -grasshopper document open %ghFilePath% _save _enter exit _enter"