Run Rhino 6 and python script from Windows command line

Hello,

I’m trying to do something really simple, namely run Rhino from windows command line with some arguments:

.\Rhino.exe /nosplash /runscript=“!-_RunPythonScript (C:<path_to_python_script>\script.py)” C:<path to input file>\rhino-testbench.3dm

What I want to achieve with this is to:

  1. Launch Rhino 6 → works
  2. Open the input 3dm file I provide → works
  3. Run the python script I provide → does not work

Rhino 6 does not run the script. it’s doesn’t to anything and the console does not show any information whatsoever. It’s like it’s ignoring the /runscript part entirely. In fact, this official doc here Rhino - Running Rhino from the Command Line does not work either. I see it’s Rhino 5, but I’m running Rhino 6.

Does this mean, I cannot use Rhino 6 to run python scripts from the command line?

Also, I tried pasting !-_RunPythonScript (C:<path_to_python_script>\script.py) in Rhino’s command line to check if there’s something wrong with it, and it’s not. It runs the script as it should. So this makes me think the problem is elsewhere. Is there a verbose mode I can launch Rhino 6 with to see what’s going on?

I would really appreciate some help here because I’m currently relying on this automation in order to have things working.

Thanks

The command format “RunPythonScript()” is incorrect.

You can refer to the following format:

“D:\Program Files\Rhino 6\System\Rhino.exe” /nosplash /runscript="-_RunPythonScript d:/test.py" d:/test.3dm

1 Like

Thank you for your response, but unfortunately it does not work. The same thing as before is happening. Rhino starts, loads the provided input .3dm but does not run the script. And it does not provide any information in the console. Also, like I said before, pasting:

-_RunPythonScript <path_to_python_script>.py

Inside Rhino’s command line while running runs the script perfectly fine…

Hi @alexandrupopoviciioa,

This in a batch file seems to work:

C:
CD "\Program Files\Rhino 6\System"
Rhino.exe /nosplash /runscript="_-RunPythonScript (C:\Users\Dale\Desktop\test.py)"

– Dale

1 Like

Hi Dale,

Thank you for your response. After several other attempts, it looks like the issue I’ve described in my previous posts was because I was running the command from windows PowerShell… When running it from the command line(cmd.exe) it runs fine.

2 Likes

Hi Dale, is it possible to do the same without launching rhino again if it is already open?
in my case i am using Popen from subprocess to call the script from python.
Thanks

Hi @taha,

Not that I know of.

– Dale

Hi @taha,

If you are interested you can have a look at this visual studio code extension, it launches your script dynamicaly.

Name: RhinoPython
Id: designtoproduction.rhinopython
Description: A Visual Studio Code extension to program IronPython for rhino.
Version: 0.1.11
Publisher: Design-to-Production
VS Marketplace Link: RhinoPython - Visual Studio Marketplace

1 Like

In case anyone is interested in how to do this from PowerShell…

$Python = “<FilePathIncludingNameOfPythonScript.py>”

and then if you are just executing the script use:

& “C:\Program Files\Rhino 6\System\Rhino.exe” “/nosplash /runscript=”"_-RunPythonScript ($Python)"

Or if you want to run the script against a specific file:

& “C:\Program Files\Rhino 6\System\Rhino.exe” “SomeFileToRunScriptAgainst.stl” “/nosplash /runscript=”"_-RunPythonScript ($Python)"

Twitch All the quotation marks…

Also, the <> should be dropped when replacing the file paths with relevant information

1 Like

A post was split to a new topic: Batch File Script help