Launching Rhino for Mac with a runscript argument

As of the most recent RhinoWIP, it’s now possible to launch Rhino for Mac with a -runscript command-line argument.

This expert feature has been around in Rhino for Windows for a while, and it is most frequently used as part of a larger scripted process in which you want to batch process files or automate some repetitive task.

Since this feature has yet to be documented and it differs a little from the Windows counterpart, I thought a post was in order.

How to launch Rhino and run a macro:

  1. Quit Rhino if you already have it open.
  2. Launch the /Applications/Utilities/
  3. At the $ bash prompt, type:
    open /Applications/ --args -runscript "_Line 0 10,10,10"
    /Applications/ -runscript "_Line 0 10,10,10"
    and press return

This ought to launch the RhinoWIP, create a new document, and add a line from the origin to 10,10,10
The contents of the script are, obviously, up to you.

With a file:

You can use this in conjunction with a yourfile.3dm argument as well and this will run the script after opening that model. For example:

/Applications/ ~/Desktop/yourfile.3dm -runscript "_Line 0 10,10,10"

will launch Rhino, open yourfile.3dm, and run the macro/script you provide.

For Longer scripts:

For longer scripts, it’s probably wiser to author them with Python, and then use the -_RunPythonScript command and pass the path to your script file:

/Applications/ -runscript "-_RunPythonScript /full/path/to/"

As always, please let us know when you find bugs.

@KelvinC I think I remember you documenting this, but I can’t find it. Can you please point us to the official documentation for this?

It’s here.|_____5

In my experience, the path for launching Rhino with a python script is slightly different with Mac M1 (and friends) ships.

As an example, I use the following procedure for running Rhino 7 via Python with my Mac M1 (macOS Monterey) by double-clicking a command file:

  1. create a command file (e.g. run.command) that will contain the shell script. Make sure that the file is executable. To do so, refer to this link.

  2. edit the command file, and put the following command line:

open /Applications/Rhino\ --args -runscript “-_RunPythonScript /Users/YourUserName/path/to/”

Hope it helps someone!