0
$\begingroup$

I have those two EnumProperty:

fu3dm_model_gender : bpy.props.EnumProperty(name="Gender", description="Choose model's gender.", items= [('OP1', "Male", ""), ('OP2', "Female", "")])    
fu3dm_model_head : bpy.props.EnumProperty(name="Head", description="Choose model's head.", items= [('OP1', "Generic Male", ""), ('OP2', "Something", "")])

And I want to do this:

If fu3dm_model_gender is OP1 then fu3dm_model_head items to be like this items= [('OP1', "Generic Male", ""), ('OP2', "Something", "")]. Else if fu3dm_model_gender is OP2 then fu3dm_model_head items to be like this items= [('OP1', "Generic Female", ""), ('OP2', "Something Else", "")].

Here is my code:

class fu3dm_WM_OT_Model_Prefs_Operator(bpy.types.Operator):
    bl_idname = "wm.fu3dm_model_prefs"
    bl_label = "Model Preferences"
    bl_description = "Sets model's preferences"

    fu3dm_model_gender : bpy.props.EnumProperty(name="Gender", description="Choose model's gender.", items= [('OP1', "Male", ""), ('OP2', "Female", "")])
    fu3dm_model_head : bpy.props.EnumProperty(name="Head", description="Choose model's head.", items= [('OP1', "Generic Male", ""), ('OP2', "Something", "")])

    def invoke(self, context, event):
        return context.window_manager.invoke_props_dialog(self)
        bpy.ops.wm.fu3dm_model_prefs('INVOKE_DEFAULT')

    def draw(self, context):
        layout = self.layout
        layout.prop(self, "fu3dm_model_gender")
        if self.fu3dm_model_gender == 'OP1':
            # Change "fu3dm_model_head" to "Generic Male" and "Something"
        elif self.fu3dm_model_gender == 'OP2':
            # Change "fu3dm_model_head" to "Generic Female" and "Something Else"
        layout.prop(self, "fu3dm_model_head")

    def execute(self, context):
        pass
        return {"FINISHED"}
$\endgroup$
0

1 Answer 1

1
$\begingroup$

Use EnumProperty callback:

Property Definitions (bpy.props) — Blender Python API

Basically blender will call the function in following way:

list_tuple_callback(scene, context)

The return of your function should look similar with the original item List[(identifier, name, description, icon, number), ...].

$\endgroup$

Not the answer you're looking for? Browse other questions tagged .