diff --git a/addon/__init__.py b/addon/__init__.py index edf5c63..8d21cbf 100644 --- a/addon/__init__.py +++ b/addon/__init__.py @@ -14,8 +14,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . import bpy -from .sw.funcs import select_all, workspace_menu, assign_shortcuts, remove_shortcuts -from .sw.ops import SW_OT_workspace, SW_OT_link_workspace, SW_OT_move, SW_OT_link_all, SW_OT_remove, SW_OT_switch, SW_OT_rename, SW_OT_copy_from_scene, SW_OT_activate +from bpy.app.handlers import persistent +from .sw.funcs import select_all, workspace_menu, assign_shortcuts, remove_shortcuts, has_data +from .sw.ops import SW_OT_workspace, SW_OT_link_workspace, SW_OT_move, SW_OT_link_all, SW_OT_remove, SW_OT_switch, SW_OT_rename, SW_OT_copy_from_scene, SW_OT_activate, SW_OT_select from .sw.topbar import TOPBAR_HT_upper_bar from .sw.panel import SW_PT_select_scene_workspaces from .sw.menu import SW_MT_missing_workspaces, SW_MT_copy_from @@ -34,6 +35,7 @@ bl_info = { classes = [ SW_OT_workspace, + SW_OT_select, SW_OT_switch, SW_OT_move, SW_OT_remove, @@ -49,6 +51,12 @@ classes = [ TOPBAR_HT_upper_bar ] + +@persistent +def on_scene(scene): + if not has_data(): + select_all() + og_header = None; def register(): @@ -57,7 +65,8 @@ def register(): for c in classes: bpy.utils.register_class(c) bpy.types.TOPBAR_MT_workspace_menu.prepend(workspace_menu) - + bpy.app.handlers.frame_change_post.append(on_scene) + bpy.app.handlers.load_post.append(on_scene) assign_shortcuts() def unregister(): @@ -65,7 +74,8 @@ def unregister(): bpy.utils.unregister_class(c) bpy.utils.register_class(og_header) bpy.types.TOPBAR_MT_workspace_menu.remove(workspace_menu) - + bpy.app.handlers.frame_change_post.remove(on_scene) + bpy.app.handlers.load_post.remove(on_scene) remove_shortcuts() if __name__ == "__main__":