Close rhino and grasshopper

Hi,

I’d like to automatically close Rhino (and GH obviously) when my python script inside GH is done. Nothing difficult !

I use :
scriptcontext.doc=rh.RhinoDoc.ActiveDoc
rs.DocumentModified(False)
rs.Exit()
to close Rhino without being asked for saving, but I can’t find how to do the same for grasshopper which ask to save the modified file.

Any ideas ?

Regards,

Hi Sébastien M,

Did you ever find a solution for this?

I am trying to do the same thing but haven’t been able to figure it out.

Best regards,
Kevin

A little late to the party, but I was able to do this by making the Python script able to be called by command.

in Rhino, “RunPythonScript”, make a new script, make it “command”
Add your code and close it.

Inside of Grasshopper, I made a C# node that just sends the command to Rhino to run the script. A dirty hack, but it works.

1 Like
Process.Kill()

Keyu,
Could you provide an example?

Is it just Process.Kill(Grasshopper) ?

Thanks!

Rhino.RhinoApp.Exit()
Will close the Rhino that the grasshopper script is attached to.
It might prompt you to save grasshopper, no idea if you want to do that though.

Thanks for the reply Christopher. I have been using your method, but I was hoping to prevent the Grasshopper save dialog.

I have been creating a new workspace in Rhino to get rid of the save screen , but stuck with Grasshopper save still.

I resolved this by creating a command python script.

import os

os.system(‘Taskkill /F /IM rhino.exe’)

Well if you don’t mind running a save command on the gh files:

other options include savebackup:

This should stop the document from prompting the save dialog.