Browse Source

Add an operator to reset modifiers to default

pull/38/head
Adam Johnson 9 years ago
parent
commit
0b1c4a4f45
  1. 30
      korman/operators/op_modifier.py
  2. 1
      korman/ui/ui_modifiers.py

30
korman/operators/op_modifier.py

@ -131,6 +131,36 @@ class ModifierRemoveOperator(ModifierOperator, bpy.types.Operator):
return context.window_manager.invoke_props_dialog(self)
class ModifierResetOperator(ModifierOperator, bpy.types.Operator):
bl_idname = "object.plasma_modifier_reset"
bl_label = "Reset the modifier to its default state?"
bl_description = "Reset the modifier to its default state"
active_modifier = IntProperty(name="Modifier Display Order",
default=-1,
options={"HIDDEN"})
def draw(self, context):
pass
def execute(self, context):
assert self.active_modifier >= 0
for i in context.object.plasma_modifiers.modifiers:
if i.display_order == self.active_modifier:
mod = i
break
else:
raise IndexError(self.active_modifier)
props = set(mod.keys()) - {"display_order", "display_name"}
for i in props:
mod.property_unset(i)
return {"FINISHED"}
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)
class ModifierMoveOperator(ModifierOperator):
def swap_modifier_ids(self, mods, s1, s2):
done = 0

1
korman/ui/ui_modifiers.py

@ -77,6 +77,7 @@ class PlasmaModifiersPanel(ModifierButtonsPanel, bpy.types.Panel):
row.operator("object.plasma_modifier_move_up", text="", icon="TRIA_UP").active_modifier = modifier.display_order
row.operator("object.plasma_modifier_move_down", text="", icon="TRIA_DOWN").active_modifier = modifier.display_order
row.operator("object.plasma_modifier_reset", text="", icon="FILE_REFRESH").active_modifier = modifier.display_order
row.operator("object.plasma_modifier_remove", text="", icon="X").active_modifier = modifier.display_order
# Now we return the modifier box, which is populated with the modifier specific properties

Loading…
Cancel
Save