I have a .gh script I want to open and run in the background without loading the GUI.
I’m aware of GrasshopperPlayer but that isn’t quite what I’m looking for here.
All inputs/outputs are handled outside of the gh canvas via Eto.Forms interactions and.
I thought the following RhinoScript code should work:
Option Explicit
Call Main()
Sub Main()
Dim GH
Set GH = Rhino.GetPlugInObject("Grasshopper")
' Disable the startup banner
Call GH.DisableBanner()
' Open the Grasshopper document
Call GH.OpenDocument("path_to_my_grasshopper_script_i_want_to_run")
End Sub
RunHeadless seems to do nothing and I don’t see any additional information on it in the SDK docs here:
A workaround is closing the window after it’s loaded like so:
Option Explicit
Call Main()
Sub Main()
Dim GH
Set GH = Rhino.GetPlugInObject("Grasshopper")
' Disable the startup banner
Call GH.DisableBanner()
' Open the Grasshopper document
Call GH.OpenDocument("path_to_my_grasshopper_script_i_want_to_run")
' Hide the editor
Call GH.HideEditor()
End Sub
Or like this:
Option Explicit
Call Main()
Sub Main()
Dim GH
Set GH = Rhino.GetPlugInObject("Grasshopper")
' Disable the startup banner
Call GH.DisableBanner()
' Run Grasshopper Headless
Call GH.RunHeadless()
' Open the Grasshopper document
Call GH.OpenDocument("path_to_my_grasshopper_script_i_want_to_run")
' Ensure Grasshopper starts minimized (or hidden)
'If GH.IsEditorLoaded() Then
'Call Rhino.Command("NoEcho ! _-Grasshopper _Window _Hide _EnterEnd", False)
'End If
End Sub
But I would much prefer to never see the GUI at all.
Any ideas how to achieve that or is there something I’m doing wrong with RunHeadless?
I worked out a work flow that allows a GH file with custom UI to be complied with the Rhino Script Compiler and launched headless via some hoop jumping in a Python launch script.
Understood, thanks @stevebaer. So, in summary, if I want to run Rhino,GH, or both headless ( and locally) I should be using Rhino.Compute to achieve that?
Thanks for your help!
Interesting thanks for sharing and for sharing each step as you tried things through your process! Looks like you did manage to get a headless implementation running via Python I’ll dig a bit more into and see if it’s viable for my needs.
No, I was just pointing out that the RunHeadless function wasn’t intended to be called for any other purpose. Kiteboardshaper probably has a good technique for doing what you are after