I'm trying to solve the slow saving to network drives in Blender. The reason it's so slow is the way Blender handles saving internally.
I found a solution that works by saving the file to a proxy location (temp dir) and then moving it to the network directory.
I'd like to add a checkbox to the save file dialog and the save & load preferences panels, just like the compression option.
I can't seem to find how to implement these toggle buttons on that location in 2.80
I thought I could find the buttons at bpy.context.preferences.
but they don't seem to be there.
Can someone add an example of the code to add a toggle to these panels?
The gist of the code is this:
def execute(self, context):
outname = bpy.path.basename(bpy.data.filepath)
outpath = os.path.dirname( bpy.path.abspath( bpy.context.preferences.filepaths.temporary_directory ) )
outpath_final = os.path.dirname(bpy.path.abspath(bpy.data.filepath))
print(os.path.join(outpath, outname))
report = bpy.ops.wm.save_as_mainfile(filepath=os.path.join(outpath, outname),
check_existing=True, copy=True)
# os.rename(os.path.join(outpath, outname), os.path.join(outpath_final, outname)) # Does not work accross devices
shutil.move(os.path.join(outpath, outname), os.path.join(outpath_final, outname))
return report