1 # SPDX-License-Identifier: GPL-2.0-or-later
5 When working with linked libraries, very often you need to save and load
6 again to see the changes.
7 This does it in one go, without asking, so be careful :)
8 Usage: Hit Ctrl + Shift + W or find it at the bottom of the File menu.
17 class AMTH_WM_OT_save_reload(bpy
.types
.Operator
):
18 """Save and Reload the current blend file"""
19 bl_idname
= "wm.save_reload"
20 bl_label
= "Save & Reload"
22 def save_reload(self
, context
, path
):
24 bpy
.ops
.wm
.save_as_mainfile("INVOKE_AREA")
26 bpy
.ops
.wm
.save_mainfile()
27 self
.report({"INFO"}, "Saved & Reloaded")
28 bpy
.ops
.wm
.open_mainfile("EXEC_DEFAULT", filepath
=path
)
30 def execute(self
, context
):
31 path
= bpy
.data
.filepath
32 self
.save_reload(context
, path
)
37 def button_save_reload(self
, context
):
38 get_addon
= "amaranth" in context
.preferences
.addons
.keys()
42 if context
.preferences
.addons
["amaranth"].preferences
.use_file_save_reload
:
43 self
.layout
.separator()
45 AMTH_WM_OT_save_reload
.bl_idname
,
51 bpy
.utils
.register_class(AMTH_WM_OT_save_reload
)
52 bpy
.types
.TOPBAR_MT_file
.append(button_save_reload
)
53 wm
= bpy
.context
.window_manager
54 kc
= wm
.keyconfigs
.addon
55 km
= kc
.keymaps
.new(name
="Window")
56 kmi
= km
.keymap_items
.new("wm.save_reload", "W", "PRESS",
57 shift
=True, ctrl
=True)
58 KEYMAPS
.append((km
, kmi
))
62 bpy
.utils
.unregister_class(AMTH_WM_OT_save_reload
)
63 bpy
.types
.TOPBAR_MT_file
.remove(button_save_reload
)
64 for km
, kmi
in KEYMAPS
:
65 km
.keymap_items
.remove(kmi
)