Putting bones on layers

I have a hard time putting a bunch of hard coded bones on specific layers in python. There is almost no information i could find. The only layer related command i found in the api reference is bpy.ops.armature.bone_layer. Is there no better way than select each bone in order to change the layer?

What about :

#With the correct armature selected
bpy.context.object.data.bones['Bone'].layers[0] = False
bpy.context.object.data.bones['Bone'].layers[1] = True

In order to work, you have to be in object mode.

1 Like