I have an EnumProperty (a list) which enables the visibility of three different collections and now I want it to enable different Bools based on what's selected from the list. I can share my example - blend file if possible. For instance, below, I need the cube Bool to appear only when "skin1" is selected from the enum.
import math
import json
import collections
import traceback
from math import pi
from bpy.props import StringProperty
from mathutils import Euler, Matrix, Quaternion, Vector
from rna_prop_ui import rna_idprop_quote_path
rig_id = "Character"
#### CUSTOM PROPERTIES ####
#### SKIN LIST #####
character_skin_list = [('skin1','Skin 1',''),
('skin2','Skin 2',''),
('skin3','Skin 3','')
]
def skin_show_update(self, context):
for skin1 in character_skin_list:
bpy.data.collections[skin1[0]].hide_viewport = not self.show_skin == skin1[0]
return
bpy.types.Armature.show_skin = bpy.props.EnumProperty(items = character_skin_list,
name = "Skin",
description = "Select skin",
update = skin_show_update)
#### CUBE ####
def cube_show_update(self, context):
bpy.data.objects["Cube"].hide_viewport = not self.show_cube
bpy.data.objects["Cube"].hide_render = not self.show_cube
return
bpy.types.Armature.show_cube = bpy.props.BoolProperty(default = True,
name = "Cube",
description = "Show cube",
update = cube_show_update)
#### SPHERE ####
def sphere_show_update(self, context):
bpy.data.objects["Sphere"].hide_viewport = not self.show_sphere
bpy.data.objects["Sphere"].hide_render = not self.show_sphere
return
bpy.types.Armature.show_sphere = bpy.props.BoolProperty(default = True,
name = "Sphere",
description = "Show sphere",
update = sphere_show_update)
#### TORUS ####
def torus_show_update(self, context):
bpy.data.objects["Torus"].hide_viewport = not self.show_torus
bpy.data.objects["Torus"].hide_render = not self.show_torus
return
bpy.types.Armature.show_torus = bpy.props.BoolProperty(default = True,
name = "Torus",
description = "Show torus",
update = torus_show_update)
#### TOGGLES ####
class RigLayersProperties(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Properties"
bl_idname = "VIEW3D_PT_rig_layers_properties_" + rig_id
bl_category = 'Item'
@classmethod
def poll(self, context):
try:
return (context.active_object.data.get("rig_id") == rig_id)
except (AttributeError, KeyError, TypeError):
return False
def draw(self, context):
layout = self.layout
col = layout.column()
row = col.row()
row.prop(context.active_object.data, 'show_skin', toggle=True)
col.separator()
row = col.row()
row.prop(context.active_object.data, 'show_cube', toggle=True)
row = col.row()
row.prop(context.active_object.data, 'show_sphere', toggle=True)
row = col.row()
row.prop(context.active_object.data, 'show_torus', toggle=True)
def register():
bpy.utils.register_class(RigLayersProperties)
def unregister():
bpy.utils.unregister_class(RigLayersProperties)
register() ```