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.data.filepath:
bpy.ops.wm.save_mainfile( ?parameter to prompt for filename? )
else:
bpy.ops.wm.save_mainfile()
self.report( { 'INFO' }, 'File saved.')
return { 'FINISHED' }
save_as_mainfile
, I think it attempts to save the file to the specified path. Based on the fact that no path is provided in your code, it is probably trying to save to some default location it does not have write permission for. Your script needs to obtain a location and obtain permission to write to that location to usesave_as_mainfile
. However, it is weird your blender version crashes - mine logs an error to the system console. $\endgroup$save_as_mainfile
. $\endgroup$