Close a file without saving with scripting

Hi there,

I am running a script to do some calculations on a mesh file.
Afterwards, I need to close the file without saving it and without creating a .3dm or .3dmbak files in the folder.

Here the command history:

Save file name <C:\dev\.........\output_mesh_dx.3dm> ( Version=5  SaveSmall=No  GeometryOnly=No  SaveTextures=No  SavePlugInData=Yes  Browse ): _Enter
Save file name <C:\dev..........\output_mesh_dx.3dm> ( Version=5  SaveSmall=No  GeometryOnly=No  SaveTextures=No  SavePlugInData=Yes  Browse ):
File successfully written as C:\dev\.......\output_mesh_dx.3dm

Is there a way to close the stl or ply files without creating a .3dm or .3dmbak files?

Thank you,
Hans Paul

I think the way to close a Rhino file without saving is to open a new one after having specifically set the “document modified” flag to False (so it won’t bother you with a “Do you want to save?” prompt).

rs.DocumentModified(False)
rs.Command("_-New _None",False)
1 Like

Alt+F4

http://pywinauto.readthedocs.io/en/latest/code/pywinauto.keyboard.html

SendKeys('%{F4}') # close an active window with Alt+F4

Just a guess. :slight_smile:

Assuming you actually want to quit Rhino, no? Plus you will still get the "Do you want to save? message box to confirm…

os.kill()

Thank you @Helvetosaur for the fast reply.

It works like a sharm

rs.Exit() or Rhino.RhinoApp.Exit()

If you indeed want to close Rhino.

…still need to set the document modified flag to False if you don’t want to get the "Do you want to save? message…

2 Likes