I have a "Redo Panel" with some custom properties and an operator at the end, from which I want to reset all custom properties at their default values. How can I do that?
Here is an example of my code:
class FU3DM_OT_ModelPrefs(bpy.types.Operator):
bl_idname = "fu3dm.model_prefs"
bl_label = "Model"
bl_description = "Blah blah blah"
bl_options = {'REGISTER','UNDO'}
gender : bpy.props.EnumProperty(name="Gender", description="Choose model's gender", items= [('OP1', "Male", ""), ('OP2', "Female", "")], default='OP1')
head_male : bpy.props.EnumProperty(name="Head", description="Choose model's head", items= [('OP1', "Generic Male", ""), ('OP2', "Male", "")], default='OP2')
head_female : bpy.props.EnumProperty(name="Head", description="Choose model's head", items= [('OP1', "Generic Female", ""), ('OP2', "Female", "")], default='OP2')
eyes_color : bpy.props.IntProperty(name="Eyes Color", description="Choose model's eyes color", min=1, max=10, default=1)
skin_color : bpy.props.IntProperty(name="Skin Color", description="Choose model's skin color", min=1, max=10, default=1)
models_show : bpy.props.BoolProperty(name="Show Model", description="Show or hide models", default=1)
class FU3DM_OT_ResetAll(bpy.types.Operator):
bl_idname = "fu3dm.reset_all"
bl_label = "Reset"
bl_description = "Blah blah blah"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
# ???
return {"FINISHED"}
def draw(self, context):
layout = self.layout
# ...
row = layout.row()
row.operator('fu3dm.reset_all')
# ...
def execute(self, context):
# ...
return {"FINISHED"}
bpy.ops.ui.reset_default_button(all=True)
and thisbpy.ops.ui.unset_property_button()
? If yes, I tried several things but it didn't work. Can you please show me an example based on my example code? "Btw noticed the nested operator classes in q code, is that working for you?". Yes for now, it is working!!! I also have some nested functions into a class which work. $\endgroup$operator
) which will reset all properties to their defaults values whenever user wants. $\endgroup$