Browse Source

Fix #260.

Adds the ability to reset and/or delete all modifiers on a single
blender object.
pull/268/head
Adam Johnson 3 years ago
parent
commit
9884e7a061
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 23
      korman/operators/op_modifier.py
  2. 3
      korman/ui/ui_modifiers.py

23
korman/operators/op_modifier.py

@ -220,11 +220,13 @@ class ModifierRemoveOperator(ModifierOperator, bpy.types.Operator):
return {"FINISHED"} return {"FINISHED"}
def invoke(self, context, event): def invoke(self, context, event):
assert self.active_modifier >= -1
mods = context.object.plasma_modifiers mods = context.object.plasma_modifiers
self.mods2delete.clear() self.mods2delete.clear()
want2delete = OrderedSet() want2delete = OrderedSet()
if self.active_modifier == -1:
want2delete.update((i.pl_id for i in context.object.plasma_modifiers.modifiers))
else:
want2delete.add(self._get_modifier(context).pl_id) want2delete.add(self._get_modifier(context).pl_id)
# Here's the rub # Here's the rub
@ -249,8 +251,8 @@ class ModifierRemoveOperator(ModifierOperator, bpy.types.Operator):
class ModifierResetOperator(ModifierOperator, bpy.types.Operator): class ModifierResetOperator(ModifierOperator, bpy.types.Operator):
bl_idname = "object.plasma_modifier_reset" bl_idname = "object.plasma_modifier_reset"
bl_label = "Reset the modifier to its default state?" bl_label = "Reset the modifier(s) to the default state?"
bl_description = "Reset the modifier to its default state" bl_description = "Reset the modifier(s) to the default state"
active_modifier = IntProperty(name="Modifier Display Order", active_modifier = IntProperty(name="Modifier Display Order",
default=-1, default=-1,
@ -260,13 +262,18 @@ class ModifierResetOperator(ModifierOperator, bpy.types.Operator):
pass pass
def execute(self, context): def execute(self, context):
assert self.active_modifier >= 0 if self.active_modifier == -1:
mod = self._get_modifier(context) for i in context.object.plasma_modifiers.modifiers:
props = set(mod.keys()) - {"display_order", "display_name"} self._reset(i)
for i in props: else:
mod.property_unset(i) self._reset(self._get_modifier(context))
return {"FINISHED"} return {"FINISHED"}
def _reset(self, modifier):
props = set(modifier.keys()) - {"display_order", "display_name"}
for i in props:
modifier.property_unset(i)
def invoke(self, context, event): def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self) return context.window_manager.invoke_props_dialog(self)

3
korman/ui/ui_modifiers.py

@ -99,3 +99,6 @@ class PlasmaModifiersSpecialMenu(ModifierButtonsPanel, bpy.types.Menu):
layout.separator() layout.separator()
layout.operator("object.plasma_modifier_copy", icon="COPYDOWN", text="Copy Modifiers").active_modifier = -1 layout.operator("object.plasma_modifier_copy", icon="COPYDOWN", text="Copy Modifiers").active_modifier = -1
layout.operator("object.plasma_modifier_paste", icon="PASTEDOWN", text="Paste Modifier(s)") layout.operator("object.plasma_modifier_paste", icon="PASTEDOWN", text="Paste Modifier(s)")
layout.separator()
layout.operator("object.plasma_modifier_reset", text="Reset Modifiers", icon="FILE_REFRESH").active_modifier = -1
layout.operator("object.plasma_modifier_remove", text="Remove Modifiers", icon="X").active_modifier = -1

Loading…
Cancel
Save