Save a file with filename prompt from script?

by Ziflin   Last Updated July 13, 2018 01:15 AM

I'm trying to write a simple script to save without Blender showing the confirmation popup. This works fine if the file already has a name, however, if I call bpy.ops.wm.save_mainfile() and the file has not been previously saved, Blender simply crashes/exits completely.

So is there a way to call save_mainfile() so that it behaves the same at the normal File/Save operation where it will prompt the user for a filename? (Note that calling save_as_mainfile() also crashes Blender.

Here's what I was at least hoping would work:

def execute( self, context ):
    if not
        bpy.ops.wm.save_mainfile() { 'INFO' }, 'File saved.')
    return { 'FINISHED' }

Related Questions

How to retrieve the thumbnail from a .blend file?

Updated August 17, 2015 17:06 PM

Python: Check if file was saved

Updated July 27, 2016 08:06 AM

blenderplayer and 3rd party libraries

Updated November 20, 2017 10:15 AM