How to get a bone's roll (Blender 2.58)

How can I find an armature bone’s roll value? Everything I read tells me there’s a “roll” attribute in this Bone structure ( http://www.blender.org/documentation/blender_python_api_2_59_2/bpy.types.Bone.html#bpy.types.Bone ), but it doesn’t exist. Python says: “AttributeError: ‘Bone’ object has no attribute ‘roll’”.

The EditBone structure apparently has a roll attribute, but my Armature’s “edit_bones” collection is empty. Can I get to them?

That data structure is only populated when you are in Edit Mode for your armature. Get the armature into edit mode then check the data structure. It gets cleared out again when you leave Edit Mode.

How do I do that?

You can either run your script when you are in edit mode (i.e. select your armature and hit ‘TAB’ to go into Edit Mode) or you can use:


bpy.ops.object.mode_set(mode='EDIT')

To put the current active object into Edit Mode. This is the same call that Blender makes when you hit ‘TAB’.