Enum and "if" help

Guys, I have a list, an EnumProperty and I want it to proc different toggles (BoolProperties) to appear based on what’s selected from the list.

In particular, the enum property is supposed to have skins for a character (different collections) and each skin has its own clothing parts whose viewport visibility is controlled by the Bool properties (skin1 for example might have gloves and skin2 doesn’t have gloves but has a hat).

For example a bool :

    
    bpy.data.objects["skin2_hat"].hide_viewport = not self.show_hat
    bpy.data.objects["skin2_hat"].hide_render = not self.show_hat
        
    return

bpy.types.Armature.show_hat = bpy.props.BoolProperty(default = True,
                                                            name = "Hat",
                                                            description = "Hat on/off",
                                                            update = hat_show_update)``` 

So I need this bool property for the hat to appear only when the skin2 is selected from the list (the enum prop).

you’ll need to override your panel or operator’s draw method. I don’t have time at the moment for an in-depth example, but if you open up one of the example scripts for drawing panels it should give you an idea of how to do it.

Given the limited detail in your original post I may be over complicating what I believe to be your end goal.

Filtering objects within a collection based on brockmann’s answer to blender stack exchange question https://blender.stackexchange.com/questions/234199/creating-drop-down-lists-for-the-objects-in-collections

import bpy
from bpy.props import PointerProperty

def filter_callback(self, object):
    return self in object.users_collection

class TEST_PT_main_panel(bpy.types.Panel):
    bl_label = "My Panel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "clothing"

    def draw(self, context):
        scene = context.scene
        layout = self.layout
        col = layout.column()
        
        col.prop(scene, "my_collection")
        
        if scene.my_collection:
            col.prop(scene.my_collection, "my_active_object")

def register():
    bpy.types.Scene.my_collection = PointerProperty(
        name="Collection",
        type=bpy.types.Collection)
    bpy.types.Collection.my_active_object = PointerProperty(
        name="Object",
        type=bpy.types.Object,
        poll=filter_callback)

def unregister():
    del bpy.types.Scene.my_collection
    del bpy.types.Collection.my_active_object

If your character is a single mesh object with vertex groups you can set up the pointers for that as well; this is just a rough concept and the string name of the group is what the further operations are based on.

Within my file I have 2 copies of a base model. (Sorry its not detailed i was more focused on the script)

Once a collection is selected (Body or Body.001) an object selection becomes available based on the filtered objects within that collection.

def get_torso_objs(torso_coll_names):
    torso_objs = []

    for coll in torso_coll_names:
        for obj in bpy.data.collections[coll].objects:
            if obj not in torso_objs:
                torso_objs.append(obj)
    return torso_objs
class TEST_PT_torso_subpanel(bpy.types.Panel):
    bl_label = "Torso Sub Panel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "clothing"
    bl_parent_id = "TEST_PT_main_panel"

    @classmethod
    def poll(cls, context):
        cond1 = context.scene.my_collection
        if cond1:
            cond2 = context.scene.my_collection['my_active_object']
            if cond2:
                return context.scene.my_collection['my_active_object'].name == 'Torso'
        else:
            return False

    def draw(self, context):
        scene = context.scene
        layout = self.layout
        col = layout.column()
        row = layout.row()
        torso_coll_names = ['Shirts', 'Vests', 'Backpacks']

        col.label(text="Torso stuff")
        objs = get_torso_objs(torso_coll_names)

object selection

Selecting a component object (in this case) allows the corresponding subpanel to be displayed by satisfying the poll condition in the panel class.

class TEST_PT_leg_subpanel(bpy.types.Panel):
    bl_label = "Leg Sub Panel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "clothing"
    bl_parent_id = "TEST_PT_main_panel"

    @classmethod
    def poll(cls, context):
        cond1 = context.scene.my_collection
        if cond1:
            cond2 = context.scene.my_collection['my_active_object']
            if cond2:
                return context.scene.my_collection['my_active_object'].name == 'Leg'
        else:
            return False

    def draw(self, context):
        scene = context.scene
        layout = self.layout
        col = layout.column()
        
        col.label(text="Leg stuff")

It is important to verify that both the collection and object are valid selections as nul/empty values for these can cause eratic results when showing/hiding the subpanels.

menu selections

Once a named object is selected and the subpanel becomes available it allows access to toggle the show/hide of desired objects from other collections.

    def draw(self, context):
        scene = context.scene
        layout = self.layout
        col = layout.column()
        row = layout.row()
        torso_coll_names = ['Shirts', 'Vests', 'Backpacks']
        
        col.label(text="Torso stuff")
        objs = get_torso_objs(torso_coll_names)
        for obj in objs:
            row = col.row()
            toggle_hide = row.operator(
                'mesh.hide_item',
                text = obj.name,
                )
            toggle_hide.item_name = obj.name
            row.prop(obj, "hide_viewport", text="")
            row.prop(obj, "hide_render", text="")

torso selected

A generic operator is then used (by passing the string name of each acceptable object) to perform the show hide toggle. (I included the individual properties on each row to both verify operation overall and ensure they are both maintained in sync)

class TEST_OT_toggle_hide(bpy.types.Operator):
    """toggle hide selected mesh"""
    bl_idname = "mesh.hide_item"
    bl_label = "Hide mesh"
    bl_options = {'REGISTER', 'UNDO'}

    item_name: bpy.props.StringProperty(
        name="Mesh Primitive",
        description="mesh to toggle hidden",
        default="",
    )

    def execute(self, context):
        status = bpy.data.objects[self.item_name].hide_viewport
        bpy.data.objects[self.item_name].hide_viewport = not status
        bpy.data.objects[self.item_name].hide_render = not status
        return {'FINISHED'}

operation

Overall script below:

bl_info = {
    "name": "Test Clothing Addon",
    "author": "Nezumi",
    "version": (0, 0, 1),
    "blender": (2, 92, 0),
    "location": "View3D > UI > clothing",
    "description": "",
    "warning": "",
    "wiki_url": "",
    "category": "Development",
    "support": "TESTING"
}

import bpy
from bpy.props import PointerProperty


def filter_callback(self, object):
    return self in object.users_collection


class TEST_PT_main_panel(bpy.types.Panel):
    bl_label = "My Panel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "clothing"

    def draw(self, context):
        scene = context.scene
        layout = self.layout
        col = layout.column()

        col.prop(scene, "my_collection")

        if scene.my_collection:
            col.prop(scene.my_collection, "my_active_object")


class TEST_PT_arm_subpanel(bpy.types.Panel):
    bl_label = "Arm Sub Panel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "clothing"
    bl_parent_id = "TEST_PT_main_panel"

    @classmethod
    def poll(cls, context):
        cond1 = context.scene.my_collection
        if cond1:
            cond2 = context.scene.my_collection['my_active_object']
            if cond2:
                return context.scene.my_collection['my_active_object'].name == 'Arm'
        else:
            return False

    def draw(self, context):
        scene = context.scene
        layout = self.layout
        col = layout.column()

        col.label(text="Arm stuff")


class TEST_PT_head_subpanel(bpy.types.Panel):
    bl_label = "Head Sub Panel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "clothing"
    bl_parent_id = "TEST_PT_main_panel"

    @classmethod
    def poll(cls, context):
        cond1 = context.scene.my_collection
        if cond1:
            cond2 = context.scene.my_collection['my_active_object']
            if cond2:
                return context.scene.my_collection['my_active_object'].name == 'Head'
        else:
            return False

    def draw(self, context):
        scene = context.scene
        layout = self.layout
        col = layout.column()

        col.label(text="Head stuff")


class TEST_PT_leg_subpanel(bpy.types.Panel):
    bl_label = "Leg Sub Panel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "clothing"
    bl_parent_id = "TEST_PT_main_panel"

    @classmethod
    def poll(cls, context):
        cond1 = context.scene.my_collection
        if cond1:
            cond2 = context.scene.my_collection['my_active_object']
            if cond2:
                return context.scene.my_collection['my_active_object'].name == 'Leg'
        else:
            return False

    def draw(self, context):
        scene = context.scene
        layout = self.layout
        col = layout.column()

        col.label(text="Leg stuff")


class TEST_OT_toggle_hide(bpy.types.Operator):
    """toggle hide selected mesh"""
    bl_idname = "mesh.hide_item"
    bl_label = "Hide mesh"
    bl_options = {'REGISTER', 'UNDO'}

    item_name: bpy.props.StringProperty(
        name="Mesh Primitive",
        description="mesh to toggle hidden",
        default="",
    )

    def execute(self, context):
        status = bpy.data.objects[self.item_name].hide_viewport
        bpy.data.objects[self.item_name].hide_viewport = not status
        bpy.data.objects[self.item_name].hide_render = not status
        return {'FINISHED'}


def get_torso_objs(torso_coll_names):
    torso_objs = []

    for coll in torso_coll_names:
        for obj in bpy.data.collections[coll].objects:
            if obj not in torso_objs:
                torso_objs.append(obj)
    return torso_objs


class TEST_PT_torso_subpanel(bpy.types.Panel):
    bl_label = "Torso Sub Panel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "clothing"
    bl_parent_id = "TEST_PT_main_panel"

    @classmethod
    def poll(cls, context):
        cond1 = context.scene.my_collection
        if cond1:
            cond2 = context.scene.my_collection['my_active_object']
            if cond2:
                return context.scene.my_collection['my_active_object'].name == 'Torso'
        else:
            return False

    def draw(self, context):
        scene = context.scene
        layout = self.layout
        col = layout.column()
        row = layout.row()
        torso_coll_names = ['Shirts', 'Vests', 'Backpacks']

        col.label(text="Torso stuff")
        objs = get_torso_objs(torso_coll_names)
        for obj in objs:
            row = col.row()
            toggle_hide = row.operator(
                'mesh.hide_item',
                text=obj.name,
                )
            toggle_hide.item_name = obj.name
            row.prop(obj, "hide_viewport", text="")
            row.prop(obj, "hide_render", text="")


class TEST_PT_torso2_subpanel(bpy.types.Panel):
    bl_label = "Torso2 Sub Panel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "clothing"
    bl_parent_id = "TEST_PT_main_panel"

    @classmethod
    def poll(cls, context):
        cond1 = context.scene.my_collection
        if cond1:
            cond2 = context.scene.my_collection['my_active_object']
            if cond2:
                return context.scene.my_collection['my_active_object'].name == 'Torso.001'
        else:
            return False

    def draw(self, context):
        scene = context.scene
        layout = self.layout
        col = layout.column()
        row = layout.row()
        torso_coll_names = ['Vests', 'Backpacks']

        col.label(text="Torso2 stuff")
        objs = get_torso_objs(torso_coll_names)
        for obj in objs:
            row = col.row()
            toggle_hide = row.operator(
                'mesh.hide_item',
                text=obj.name,
                )
            toggle_hide.item_name = obj.name
            row.prop(obj, "hide_viewport", text="")
            row.prop(obj, "hide_render", text="")


classes = [
    TEST_OT_toggle_hide,
    TEST_PT_main_panel,
    TEST_PT_torso2_subpanel,
    TEST_PT_arm_subpanel,
    TEST_PT_head_subpanel,
    TEST_PT_leg_subpanel,
    TEST_PT_torso_subpanel
    ]


def register():
    bpy.types.Scene.my_collection = PointerProperty(
        name="Collection",
        type=bpy.types.Collection)
    bpy.types.Collection.my_active_object = PointerProperty(
        name="Object",
        type=bpy.types.Object,
        poll=filter_callback)

    for cls in classes:
        bpy.utils.register_class(cls)


def unregister():
    for cls in classes:
        bpy.utils.unregister_class(cls)
    del bpy.types.Scene.my_collection
    del bpy.types.Collection.my_active_object

if __name__ == "__main__":
    register()

Please keep in mind this is intended as a reference and could use alot of cleanup and optimization.
man.blend (1.2 MB)

Nice! Thank you for your trouble! Your solution works too! I also asked around stackexchange and I went with this solution https://blender.stackexchange.com/questions/256640/how-to-make-enum-proc-specific-bools (I provided more details there though). Thank you again :slight_smile: