diff --git a/korman/operators/op_toolbox.py b/korman/operators/op_toolbox.py index bef4f23..3b34522 100644 --- a/korman/operators/op_toolbox.py +++ b/korman/operators/op_toolbox.py @@ -97,3 +97,19 @@ class PlasmaEnableTexturesOperator(ToolboxOperator, bpy.types.Operator): continue slot.use = True return {"FINISHED"} + + +class PlasmaTogglePlasmaObjectsOperator(ToolboxOperator, bpy.types.Operator): + bl_idname = "object.plasma_toggle_objects" + bl_label = "Toggle Plasma Objects" + bl_description = "Toggles the Plasma Object status of a selection" + + @classmethod + def poll(cls, context): + return super().poll(context) and hasattr(bpy.context, "selected_objects") + + def execute(self, context): + enable = not all((i.plasma_object.enabled for i in bpy.context.selected_objects)) + for i in context.selected_objects: + i.plasma_object.enabled = enable + return {"FINISHED"} diff --git a/korman/ui/ui_toolbox.py b/korman/ui/ui_toolbox.py index ab7ab1b..1d5297f 100644 --- a/korman/ui/ui_toolbox.py +++ b/korman/ui/ui_toolbox.py @@ -35,6 +35,8 @@ class PlasmaToolboxPanel(ToolboxPanel, bpy.types.Panel): col.label("Plasma Objects:") col.operator("object.plasma_enable_all_objects", icon="OBJECT_DATA", text="Enable All") + all_plasma_objects = all((i.plasma_object.enabled for i in bpy.context.selected_objects)) + col.operator("object.plasma_toggle_objects", icon="VIEW3D", text="Disable Selection" if all_plasma_objects else "Enable Selection") col.label("Convert:") col.operator("object.plasma_convert_plasma_objects", icon="OBJECT_DATA", text="Plasma Objects")