Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to retrieve an armature by name and access its bones. However, this doesn't work:

armature =["rig"]
bones = armature.bones

It gives the error

'Object' object has no attribute 'bones'`

The "rig" object is found, and the armature variable holds a bpy_struct after the first line executes.

So how do I access the bone data?

share|improve this question
up vote 8 down vote accepted

"rig" is an Object datablock, bone data however is part of an Armature datablock.

What you are looking for is["rig"].data, which is the armature:

# Active object
ob = bpy.context.object

if ob.type == 'ARMATURE':
    armature =

    for bone in armature.bones:

An armature has two bone collections:

  • .bones
  • .edit_bones

Note that .edit_bones are only accessible if the armature is in Edit Mode.
See EditBones, PoseBones, Bone... Bones

There is a third kind of bone data structure for pose bones, which is referenced by the object and not the armature:["rig"].pose.bones
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.