I am trying to create a rig UI script, so far it works almost great, what i want it to do is if a cetain set of bones is selected then it shows controls for them. so far this works great with only one set of controls. the problem starts when i add multiple controls. I think i know why this happens I just need a workaround without having to create more than one class
import bpy
class showButtons(bpy.types.Panel):
bl_label = "Rig Layers"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
@classmethod
def poll(self, context):
return (bpy.context.active_object == bpy.data.objects["Ninja_Rig"])
def draw(self, context):
layout = self.layout
row = layout.row()
row.label("Left Arm")
row.prop(context.active_object.data, "layers", index=21, toggle=True, text="Deform")
row = layout.row()
row.prop(context.active_object.data, "layers", index=24, toggle=True, text="FK")
row.prop(context.active_object.data, "layers", index=16, toggle=True, text="IK")
row = layout.row()
row.label("Left Leg")
row.prop(context.active_object.data, "layers", index=22, toggle=True, text="Deform")
row = layout.row()
row.prop(context.active_object.data, "layers", index=25, toggle=True, text="FK")
row.prop(context.active_object.data, "layers", index=17, toggle=True, text="IK")
row = layout.row()
row.label("Right Arm")
row.prop(context.active_object.data, "layers", index=5, toggle=True, text="Deform")
row = layout.row()
row.prop(context.active_object.data, "layers", index=8, toggle=True, text="FK")
row.prop(context.active_object.data, "layers", index=0, toggle=True, text="IK")
row = layout.row()
row.label("Right Leg")
row.prop(context.active_object.data, "layers", index=6, toggle=True, text="Deform")
row = layout.row()
row.prop(context.active_object.data, "layers", index=9, toggle=True, text="FK")
row.prop(context.active_object.data, "layers", index=1, toggle=True, text="IK")
row = layout.row()
row.label("Head")
row.prop(context.active_object.data, "layers", index=23, toggle=True, text="Deform")
row = layout.row()
row.prop(context.active_object.data, "layers", index=26, toggle=True, text="FK")
row.prop(context.active_object.data, "layers", index=18, toggle=True, text="IK")
row = layout.row()
row.label("Spine")
row.prop(context.active_object.data, "layers", index=7, toggle=True, text="Deform")
row = layout.row()
row.prop(context.active_object.data, "layers", index=10, toggle=True, text="FK")
row.prop(context.active_object.data, "layers", index=2, toggle=True, text="IK")
row = layout.row()
row.label("Root")
row.prop(context.active_object.data, "layers", index=31, toggle=True, text="Root")
class showSliders(bpy.types.Panel):
bl_label = "IK Strength"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
@classmethod
def poll(self, context):
armL = ["Hand_IK.L", "Hand_FK.L", "ElbowTarget_IK.L"]
return(bpy.context.active_object == bpy.data.objects["Ninja_Rig"] and bpy.context.active_bone.name in armL)
def draw(self, context):
layout = self.layout
row = layout.row()
row.prop(context.active_object.data, '["Left Arm"]', slider=True, text="Left Arm")
@classmethod
def poll(self, context):
legL = ["Ankle_IK.L", "Toes_IK.L", "Heel_IK.L", "KneeTarget_IK.L", "Foot_FK.L"]
return(bpy.context.active_object == bpy.data.objects["Ninja_Rig"] and bpy.context.active_bone.name in legL)
def draw(self, context):
layout = self.layout
row = layout.row()
row.prop(context.active_object.data, '["Left Leg"]', slider=True, text="Left Leg")
@classmethod
def poll(self, context):
armR = ["Hand_IK.R", "Hand_FK.R", "ElbowTarget_IK.R"]
return(bpy.context.acrive_object == bpy.data.objects["Ninja_Rig"] and bpy.context.active_bone.name in armR)
def draw(self, context):
layout = self.layout
row = layout.row()
row.prop(context.active_object.data, '["Right Arm"]', slider=True, text="Right Arm")
@classmethod
def poll(self, context):
legR = ["Ankle_IK.R", "Toes_IK.R", "Heel_IK.R", "KneeTarget_IK.R", "Foot_FK.R"]
return(bpy.context.active_object == bpy.data.objects["Ninja_Rig"] and bpy.context.active_bone.name in legR)
def draw(self, context):
layout = self.layout
row = layout.row()
row.prop(context.active_object.data, '["Right Leg"]', slider=True, text="Right Leg")
@classmethod
def poll(self, context):
head = ["Neck_IK", "HeadTarget_IK", "Head_FK"]
return(bpy.context.active_object == bpy.data.objects["Ninja_Rig"] and bpy.context.active_bone.name in head)
def draw(self, context):
layout = self.layout
row = layout.row()
row.prop(context.active_object.data, '["Head"]', slider=True, text="Head")
@classmethod
def poll(self, context):
spine = ["LowerTorso_FK", "UpperTorso_FK", "SpineTarget_IK", "TorsoTarget_IK"]
return(bpy.context.active_object == bpy.data.objects["Ninja_Rig"] and bpy.context.active_bone.name in spine)
def draw(self, context):
layout = self.layout
row = layout.row()
row.prop(context.active_object.data, '["Spine"]', slider=True, text="Spine")
I need a work around for the def polls and the def draws having the same name and still do what i want it to do