I wanted to know in each frame a specific bone location by name. The difficulty laid on getting the bone position from the pose array.
is very performance-hungry to do in the script for each frame. I'd suggest reading the data of evaluated FCurves for bones directly.
E.g. this will evaluate the FCurve Y value at frame 7. For exporting animation, you only need to evaluate keyframes.
For that you have to first select the armature and the armature only
#Armature & bone names armatureN = "Armature" boneN = "Hand.control R" for obj in bpy.data.objects: obj.select_set(False) bpy.data.objects[armatureN].select_set(True)
Once we have the armature selected, we can loop through every frame, printing the bone position from the bones array that is in the armature's pose. We get the tail, but there are other attributes we can get from the bone.
for f in range(scene.frame_start, scene.frame_end+1): scene.frame_set(f) print("Frame " + str(f) + ": ") # This can be head, tail, center... # More info: https://docs.blender.org/api/current/bpy.types.PoseBone.html?highlight=bpy%20bone#bpy.types.PoseBone.bone bone = armature.pose.bones[boneN].tail # Since Blender 2.8 you multiply matrices with @ not with * bonePos = armature.matrix_world @ bone print(bonePos) #This may be useful to visualize the location that you have got #bpy.ops.mesh.primitive_cube_add(size = 0.1, location=bonePos) #armature.pose.bones[boneN]
In order to get the rotation you'll have to follow the link that is commented in the code, or you can click here