Hi everyone !
I’m looking for a way of launching a grasshopper file without human intervention.
Like using a c++ code to write in the CMD a line which open rhino with grasshopper and the specific file.
Is there a way of doing this ?
Thanks a lot
Hi everyone !
I’m looking for a way of launching a grasshopper file without human intervention.
Like using a c++ code to write in the CMD a line which open rhino with grasshopper and the specific file.
Is there a way of doing this ?
Thanks a lot
In Rhino6, you should just be able to have Rhino start and open any *.gh file. But I’m pretty sure you can send a startup command to Rhino as a command-line argument. You’ll need something along the lines of
_GrasshopperOpen "C:\Users\User Name\Desktop\filename.gh"
i’ve just tried it with this command line :
"C:\Program Files\Rhinoceros 5 (64-bit)\System\Rhino.exe" /runscript="_GrasshopperOpen C:\Users\olivier.stocker\Desktop\cmd_launch.gh"
but it seems that the space beetween “_GrasshopperOpen” and “C:\Users\olivier.stocker\Desktop\cmd_launch.gh” made it unclear for rhino : in the command board is only written “_GrasshopperOpen” and then ask the user to select manually a file
i’ve also tried this but it failed as “unkown command”
"C:\Program Files\Rhinoceros 5 (64-bit)\System\Rhino.exe" /runscript="_GrasshopperOpen(C:\Users\olivier.stocker\Desktop\cmd_launch.gh")
EDIT :: i’m on rhino 5
EDIT 2 :: even by testing the command line manually in rhino, i didn’t manage to open the file … it’s quite strange : i typed “_GrasshopperOpen”, then selected the file manually, but nothing happened, even with grasshopper already launched
in case you won’t do this fully with a rhinoscript as provided in link, you could also create a custom command or you invoke it from outside with this (its c# but should be identical to c++ )
Grasshopper.Plugin.GH_RhinoScriptInterface gh;
gh = (Grasshopper.Plugin.GH_RhinoScriptInterface) Rhino.RhinoApp.GetPlugInObject("Grasshopper");
//Print(gh.GetType().ToString());
gh.DisableBanner();
gh.ShowEditor();
gh.OpenDocument("C:\\somewhere\\somefile.gh");
gh.DisableBanner();
so i go though and build a solution to open Rhino and GH automatically :
I register your code into a .rvb, and
gh.OpenDocument("C:\\somewhere\\somefile.gh");
is dynamically modified thanks to a c++ code, depending on which GH i want to open. Then with that same code i call the command line :
"C:\Program Files\Rhinoceros 5 (64-bit)\System\Rhino.exe" /runscript="_-Open C:\\somepath\\somefile.3dm _-LoadScript C:\somepath\autostart.rvb"
and it’s working just fine ! so thanks you tomtom