Iterating through pose bones in Blender 2.8?

I’m new to python in Blender and I need help! I’ve looked everywhere but I can’t find a way to iterate through pose bones in Blender. I would like to add a Copy Rotation constraint to multiple bones, but the usual line, “for i in C.selected_pose_bones” will just add several constraints to the active bone in the selection.
My code here doesn’t work:

for i in C.selected_pose_bones:
bpy.ops.pose.constraint_add(type=‘COPY_ROTATION’)
i.constraints[“Copy Rotation”].target = bpy.data.objects[“Mougle_Rig”]

I need a way to change the active pose bone in the for loop. However, " C.object.data.bones.active" is read only, so… How would I go about this?

Thanks,
Allen

1 Like