Scripts: Re-Sync Blend Files #240

Merged
Sebastian Parborg merged 8 commits from TinyNick/blender-studio-pipeline:feature/resync_all_files into main 2024-02-22 16:21:03 +01:00
Showing only changes of commit fd239f66a7 - Show all commits

View File

@ -12,6 +12,34 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import bpy import bpy
import contextlib
for lib in bpy.data.libraries:
lib.reload() def main():
if len(bpy.data.libraries) == 0:
return
for lib in bpy.data.libraries:
lib.reload()
with override_save_version():
bpy.ops.wm.save_mainfile()
print(f"Reloaded & Saved file: '{bpy.data.filepath}'")
bpy.ops.wm.quit_blender()
@contextlib.contextmanager
def override_save_version():
"""Overrides the save version settings"""
save_version = bpy.context.preferences.filepaths.save_version
try:
bpy.context.preferences.filepaths.save_version = 0
yield
finally:
bpy.context.preferences.filepaths.save_version = save_version
if __name__ == "__main__":
main()