Run PythonScript without GUI

Hello everyone,

I’ve written a Python script which allows me to generate a geometry based on a number of variables. All I have to do is start Rhino, set the variables and run the script. I was wondering if it was possible to run the PythonScript without ever starting the GUI, preferably from CMD or Powershell. All imports exports are automated anyway.

1 Like

Hello,

Does this help?

1 Like

I’m pretty sure that this should allow me to pull this off.

This does not work from Powershell but it does work from CMD.

However the -RunPythonScript simGen.py -exit command does not close Rhino. Rhino remains open. It seems to try and run the -exit command as part of the Python Script

Also, isn’t it possible to run it without the GUI?

OK so it can now be done if I use rs.Exit() in the python script.

But this still requires a GUI. I want Rhino to stay closed, basically just doing it’s thing silently without ever popping up in my screen. Is this possible?

1 Like

I don’t know a way to do this. Have you disabled redraw to minimise the cost of the gui?

Hi @SNC,

To “run” Rhino without a GUI, you’ll need to automate Rhino using ActiveX automation.

https://developer.rhino3d.com/api/rhinoscript/introduction/external_access.htm

Here are a couple of examples you can review:

https://github.com/mcneel/rhino-developer-samples/blob/6/rhinoscript/RhinoRender.vbs
https://github.com/mcneel/rhino-developer-samples/blob/6/rhinoscript/TestRhino6Automation.vbs

https://github.com/mcneel/rhino-developer-samples/tree/6/rhinocommon/cs/SampleCsAutomation

https://github.com/mcneel/rhino-developer-samples/tree/6/cpp/SampleAutomationClient

– Dale

Why don’t you try rhino3dm and compute-rhino3d modules for CPython?

Thanks. I’ll give it all a try!