Running Rhino 7 in batch mode

Hello together,

i want to automate my application in rhino, so i’m working in batch mode. I was able to run rhino and grasshopper in batch mode. Hovewer, rhino pops up, when I run the following code in cmd:

“C:/Program Files/Rhino 7/System/Rhino.exe” /nosplash /runscript=" _-RunPythonScript"

I saw same questions in forum, but nobody solved this problem in python (at least I didn’t see it). Is there a way running rhino 7 without popping up. Some other softwares use commands like ‘-batch’. Is there also such a command in rhino?

Hi -

Perhaps the following is what you are looking for?


1 Like

Of course now it would be just Rhino 7 or perhaps even Rhino 8 WIP.

1 Like

Thank you for your response Wim and AIW. I tried rhinoinside. However, I got this error. Do you have any idea, why did I get this error and how can I solve it?
Little translate to english: “the given assembly name or the code basis is unvalid” :smiley:

as an update:

If I try to launch python code in rhino command, I get the same error message. However, it works, when I launch the code in second time. I need to run this python code from cmd.exe with the following code:
“C:/Program Files/Rhino 7/System/Rhino.exe” /nosplash /runscript=" _-RunPythonScript"

Python code:
import rhinoinside
import os

import System
import Rhino
import clr
import Grasshopper
from Rhino import RhinoApp, RhinoDoc
from Rhino.Geometry import *
import rhinoscript as rs

import scriptcontext

def DocumentModified(modified=None):
“”“Returns or sets the document’s modified flag. This flag indicates whether
or not any changes to the current document have been made. NOTE: setting the
document modified flag to False will prevent the “Do you want to save this
file…” from displaying when you close Rhino.
modified [optional] = the modified state, either True or False
if no modified state is specified, the current modified state
if a modified state is specified, the previous modified state
oldstate = scriptcontext.doc.Modified
if modified is not None and modified!=oldstate:
scriptcontext.doc.Modified = modified
return oldstate

#Required to set current working directory of rhino that grasshopper can see the path
cmd="-SetWorkingFolder “+”"“+os.getcwd()+”""
rs.application.Command(cmd)#Doesn’t correctly pass working dir to grasshopper
-SaveAs " + “delete.3dm”)#this operation does,…somehow

gh = RhinoApp.GetPlugInObject(“Grasshopper”)




any idea?

Can you provide a little insight on what it is your gh definition is trying to do? It may help with making a recommendation

Hi Steve,

My gh script takes some parameter from .txt file. The parameters are numbers and text. Then, it creates geometries with given parameters and export them as .x_t or .igs file.

Everything works very well, when I execute rhino from outside. However, rhino pops up, when I execute the script. I only prevent this popping up and want to launch rhino in background.

You definitely don’t need this for the way you are starting Rhino. That is for running Rhino inside of CPython and that is not what is being done here.

You should be able to do what you are trying to do with our external access technique. Here’s a post where something similar was done

Hi Steve,

all of codes are in VBA. Is it also possible to do that in python? I mean, actually I use HEEDS software for automation and connection of rhino with some other software. But, what HEEDS does only creating the following code and execute it in CMD: “C:/Program Files/Rhino 7/System/Rhino.exe” /nosplash /runscript=" _-RunPythonScript"

Therefore, the external access to Rhino should be done with using GrasshopperRhinoInterfaceScript in python. Do you have any example for that?

HEEDS would launch a vbs file with the script to launch and run Rhino. In the script you would call
RunScript "_-RuntPythonScript"

Here’s a sample