The same error occurs in the adult dragon file. The following code fixes the problem:
import bpy
import re
id_prefix = “DRAGON”
rig_name = “dragon_rig”
fk_arm_l = [“upper_arm.L”, “forearm.L”, “hand.L”]
fk_arm_r = [“upper_arm.R”, “forearm.R”, “hand.R”]
fk_leg_l = [“thigh.L”, “shin.L”, “foot.L”]
fk_leg_r = [“thigh.R”, “shin.R”, “foot.R”]
ik_arm_l = [“hand_ik.L”, “elbow_target.L”]
ik_arm_r = [“hand_ik.R”, “elbow_target.R”]
ik_leg_l = [“foot_ik.L”, “knee_target.L”, “foot_roll.L”]
ik_leg_r = [“foot_ik.R”, “knee_target.R”, “foot_roll.R”]
fk_spine = [“rib_cage”, “spine.01”, “spine.02”, “spine.03”, “spine.04”]
fk_neck = [“neck”, “neck.01”, “neck.02”, “neck.03”]
fk_head = [“head”, “neck.01”, “neck.02”, “neck.03”]
hand_l = [“finger_pinky.L”, “finger_ring.L”, “finger_middle.L”, “finger_index.L”, “thumb.L”, “palm.L”]
hand_r = [“finger_pinky.R”, “finger_ring.R”, “finger_middle.R”, “finger_index.R”, “thumb.R”, “palm.R”]
toe_l = [“toe.L”]
toe_r = [“toe.R”]
tail = [“tail_ik.01”, “tail_ik.02”, “tail_ik.03”, “tail_ik.04”]
class RigUI(bpy.types.Panel):
bl_space_type = ‘VIEW_3D’
bl_region_type = ‘UI’
bl_label = “Rig Main Properties”
bl_idname = id_prefix + “_PT_rig_ui”
@classmethod
def poll(self, context):
if context.mode != 'POSE':
return False
try:
return (context.active_object.data["rig_name"] == rig_name)
except (AttributeError, KeyError, TypeError):
return False
def draw(self, context):
layout = self.layout
pose_bones = context.active_object.pose.bones
try:
selected_bones = [bone.name for bone in context.selected_pose_bones]
selected_bones += [context.active_pose_bone.name]
except (AttributeError, TypeError):
return
def is_selected(names):
""" Returns whether any of the named bones are selected.
"""
for name in names:
if name in selected_bones:
return True
return False
# IK
if is_selected(fk_arm_l + ik_arm_l):
layout.prop(pose_bones["hand_ik.L"], '["ik"]', text="IK (arm.L)", slider=True)
if is_selected(fk_arm_r + ik_arm_r):
layout.prop(pose_bones["hand_ik.R"], '["ik"]', text="IK (arm.R)", slider=True)
if is_selected(fk_leg_l + ik_leg_l + toe_l):
layout.prop(pose_bones["foot_ik.L"], '["ik"]', text="IK (leg.L)", slider=True)
if is_selected(fk_leg_r + ik_leg_r + toe_r):
layout.prop(pose_bones["foot_ik.R"], '["ik"]', text="IK (leg.R)", slider=True)
# Hinge
if is_selected(fk_arm_l):
layout.prop(pose_bones["upper_arm.L"], '["hinge"]', text="Hinge (arm.L)", slider=True)
if is_selected(fk_arm_r):
layout.prop(pose_bones["upper_arm.R"], '["hinge"]', text="Hinge (arm.R)", slider=True)
if is_selected(fk_leg_l):
layout.prop(pose_bones["thigh.L"], '["hinge"]', text="Hinge (leg.L)", slider=True)
if is_selected(fk_leg_r):
layout.prop(pose_bones["thigh.R"], '["hinge"]', text="Hinge (leg.R)", slider=True)
if is_selected(fk_head):
layout.prop(pose_bones["head"], '["hinge"]', text="Hinge (head)", slider=True)
if is_selected(fk_neck):
layout.prop(pose_bones["neck"], '["hinge"]', text="Hinge (neck)", slider=True)
if is_selected(fk_spine + ["pelvis"]):
layout.prop(pose_bones["rib_cage"], '["hinge"]', text="Hinge (torso)", slider=True)
# Wings hinge
try:
for bone in context.selected_pose_bones:
if "wing" in bone.name:
try:
bone["hinge"]
except KeyError:
pass
else:
layout.prop(bone, '["hinge"]', text="Hinge (" + bone.name + ")", slider=True)
except TypeError:
pass
# Hands
if is_selected(hand_l):
layout.prop(pose_bones["palm.L"], '["spread"]', text="Spread (palm.L)", slider=True)
if is_selected(hand_r):
layout.prop(pose_bones["palm.R"], '["spread"]', text="Spread (palm.R)", slider=True)
# Body
if is_selected(fk_spine + ["hips"]):
layout.prop(pose_bones["rib_cage"], '["pivot_slide"]', text="Pivot Slide (torso)", slider=True)
# Eyes
if is_selected(["eye_target"]):
layout.prop(pose_bones["eye_target"], '["free"]', text="Free (eye_target)", slider=True)
layout.prop(pose_bones["eye_target"], '["pupil_dilate"]', text="Pupil Dilate (eye_target)", slider=True)
# Brow
if is_selected(["brow.R"]):
layout.prop(pose_bones["brow.R"], '["mad"]', text="Mad (brow.R)", slider=True)
if is_selected(["brow.L"]):
layout.prop(pose_bones["brow.L"], '["mad"]', text="Mad (brow.L)", slider=True)
if is_selected(["brow.R"]):
layout.prop(pose_bones["brow.R"], '["sad"]', text="Sad (brow.R)", slider=True)
if is_selected(["brow.L"]):
layout.prop(pose_bones["brow.L"], '["sad"]', text="Sad (brow.L)", slider=True)
if is_selected(["brow.R"]):
layout.prop(pose_bones["brow.R"], '["surp"]', text="Surprise (brow.R)", slider=True)
if is_selected(["brow.L"]):
layout.prop(pose_bones["brow.L"], '["surp"]', text="Surprise (brow.L)", slider=True)
# Nose
if is_selected(["nose.R"]):
layout.prop(pose_bones["nose.R"], '["flare"]', text="Flare (nose.R)", slider=True)
if is_selected(["nose.L"]):
layout.prop(pose_bones["nose.L"], '["flare"]', text="Flare (nose.L)", slider=True)
if is_selected(["nose.R"]):
layout.prop(pose_bones["nose.R"], '["sneer"]', text="Sneer (nose.R)", slider=True)
if is_selected(["nose.L"]):
layout.prop(pose_bones["nose.L"], '["sneer"]', text="Sneer (nose.L)", slider=True)
# Mouth
if is_selected(["mouth.R"]):
layout.prop(pose_bones["mouth.R"], '["up_dn"]', text="Up/Down (mouth.R)", slider=True)
if is_selected(["mouth.L"]):
layout.prop(pose_bones["mouth.L"], '["up_dn"]', text="Up/Down (mouth.L)", slider=True)
if is_selected(["mouth.R"]):
layout.prop(pose_bones["mouth.R"], '["in_bk"]', text="In/Out (mouth.R)", slider=True)
if is_selected(["mouth.L"]):
layout.prop(pose_bones["mouth.L"], '["in_bk"]', text="In/Out (mouth.L)", slider=True)
# Tail
if is_selected(tail):
layout.prop(pose_bones["tail_ik.01"], '["hinge"]', text="Hinge (tail)", slider=True)
layout.prop(pose_bones["tail_ik.01"], '["free"]', text="Free (tail)", slider=True)
try:
for bone in context.selected_pose_bones:
if "tail" in bone.name:
layout.prop(pose_bones["tail.01"], '["ik"]', text="IK (tail)", slider=True)
except TypeError:
pass
## Root
#if is_selected(context, ["root"]):
# layout.prop(pose_bones["root"], '["vis_head"]', text="Head Visibility")
# layout.prop(pose_bones["root"], '["vis_arm_l"]', text="Arm.L Visibility")
# layout.prop(pose_bones["root"], '["vis_arm_r"]', text="Arm.R Visibility")
# layout.prop(pose_bones["root"], '["vis_leg_l"]', text="Leg.L Visibility")
# layout.prop(pose_bones["root"], '["vis_leg_r"]', text="Leg.R Visibility")
class RigUIExtra(bpy.types.Panel):
bl_space_type = ‘VIEW_3D’
bl_region_type = ‘UI’
bl_label = “Rig Extra Properties”
bl_idname = id_prefix + “_PT_rig_ui_extra”