Finding the armature owning a bone I'm trying to write a script that constructs a transformation from a bone to an object (for "attaching" objects to animated armatures in a game engine). I can easily find the currently selected bone to construct the transformation from, using bpy.context.selected_pose_bones, but I cannot find any way to find the armature that owns the bone (which I need in order to calculate relative locations).

Does anyone know how to do this?
You can use the id_data property for one of the selected bones (you only need one because it's not currently possible to select multiple bones from different armatures at the same time). It should be as simple as the following:

context.selected_pose_bones[0].id_data


If you want just the armature's name:

context.selected_pose_bones[0].id_data.name