How to do PoseBone.children? I got an armature, with bones connected, so everything set up just fine. I want to get a bone's children through the .pose.

Like:

v = objects["armature"]
a = v.pose.bones[0] #got the root bone


Then I want to go through the children recursively. Only problem is that a is a PoseBone and has only .child property.

Only way I found to get all the children is like a.bone.children then get all of their .name and find them in v. That is "fine"...

My question to the more experienced bpy fans is that if there is a better way to get this set of bones?
The children attribute is a convenience property, That is to say - Blender doesn't store a list of children for each bone, This attribute has just been added to some types since its such a common task.

Objects have this, but as you have noticed, not pose bones.

This can be monkey-patched in with:

import bpy

def pose_bone_children(self):
    obj = self.id_data
    pbones = obj.pose.bones
    self_bone = self.bone
    return tuple(pbones[bone.name] for bone in obj.data.bones
                 if bone.parent == self_bone)

# Add the property to the class at runtime
bpy.types.PoseBone.children = property(pose_bone_children)


Note that this will be included in 2.69, Committed r60407