Exit command not working

I’m trying to run some Rhino command scripts from a DOS prompt, where I exit Rhino after each script. I’ve tried putting the Exit command in either the script I run or the command prompt but neither work. They show up in the command history, but don’t actually do anything. If I manually type exit it works fine.

I’m using the latest version of Rhino 6, at least as of writing.

The reason for exiting and starting Rhino again is that each script maxes out the RAM on my system and Rhino doesn’t seem to clear it any other way (such as create new file etc).

If you see memory filling up due to the undo stack you can use _ClearUndo to clear the undo and redo lists.

Thanks. I’ll give that a go.

Why not using taskkill /IM Rhino.exe. A little brute force with the cmd-hammer. :wink:

Nicer to not have to restart the process, obviously (:

Agreed it would be nicer, but _ClearUndo is making no difference. I only tried 2 scripts but the memory usage continued to build up on each. I tried the command manually after it ran the scripts, but that made no difference either. When I closed Rhino afterwards the memory usage went back down to its starting position.

Might be worth saying that the scripts read in a point cloud, move it and save the Rhino file. The memory usage goes up during the move and also when starting a new file and importing the next point cloud.

I’ll give that a go. Thanks

I am having the same issue, calling Rhino from a python script. The main Rhino command is ReadCommandFile, which works fine, but at the end of my command file I added an _-Exit which does not work.
The Rhino prompt asks if I want to save changes, but whatever I do at this point, either manually or from the command file does not change anything. In other words, if my command files ends with “_-Exit\n”, even clicking Yes or No in the prompt (cf picture) won’t have any effect.

Although I know there are workarounds (and I don’t have to programatically close Rhino), I am curious as to this behavior.

1 Like

Hi Taquet!
I have exactly the same problem. Did you manage to find sth???
thanks in advance

Hello tg1,

Unfortunately not! If you find something, I would be interested!

You can programmatically avoid the “Save changes to Untitled” option by setting the property Rhino.RhinoDoc.ActiveDoc.Modified = False

You can try the command version of this which would be something like:

! _-RunPythonScript (import Rhino; Rhino.RhinoDoc.ActiveDoc.Modified = False)

Notice that you are telling the document that there are no modifications so all unsaved data will be lost if you exit without explicitly saving

Hope this helps.

1 Like

Hi David and thanks for the reply.

Let me specify the problem a liitle better.
I use a python subprocess to:

  1. Run Rhino
  2. RunPythonScript to:
    a) Run a grasshopper file that changes and bake the new geometry.
    b) Save the new rhino object as a 3dm file. (File successfully saved)
    c) Exit Rhino (as you see in the commands, the command Exit (or _-Exit) is written
    but never executed). SO RHINO REMAINS OPEN.

I Have tried —> rs.Exit(), rs.Command(“Exit”),rs.Command("_-Exit") inside RunPythonScript and even -Exit command but NOTHING works.

Sorry for the long description.
Any idea?

Thank you in advance

@tg1 can you post your script so that I can try to replicate your issue here?

subprocess.py (415 Bytes)
Runpythonscript_Grasshopper1.py (2.8 KB) script.py (442 Bytes)

I run the subprocess.py
You only need to change the paths.

Thanks a lot!

If I run this inside of Rhino, it will close:

import rhinoscriptsyntax as rs
def exit():

– Dale

Thanks for trying to deal with this problem.

When running the PythonScript inside Rhino, everything works perfectly.

But when using an external python and a python subprocess to open Rhino, the problem appears. I have attached some py files above. If you have time, you could try ro run subprocess.py to see what is happening. (only change the paths)

Thanks in advance.

Dear David Andres Leon,
Unfortunately, I did not manage to “exit” Rhino using an external python(opens Rhino and runs a rhno python script) . Even if the command is written in the command line of Rhino, it is not executed. If you have time, could you please make a try with the files that i attached below. ? Thanks in advance! The files are some comments above…

Dear all,

I am also very (to say the least) interested in seeing that working.
I am not currently able to fully automate the use of Rhino from Python since Rhino will not close.

Here is a simple text file that I drag & dropped into my open Rhino application, with the results.

I had various attempts at this, none working when there is a file involved (the Exit command will work when typed directly in the Rhino command line).

Notice that when typed directly in the command line, ‘_-Exit’ directly closes the application.
However, when scripted (through the text file), the “Save changes […]” appears.

Best regards,
Gabriel Taquet

RhinoCommandFile.txt (140 Bytes)

You need one more _Enter

I wish that was it!

RhinoCommandFile.txt (189 Bytes)