location of a parent bone

I have an armature with a few bones. There are empties that are parented to the bones. I am trying to get the location of the parent bones


import Blender

# get all objects
objects = Blender.Object.Get()
# go through all the bojects
for bObject in objects:
    # work only with empties
    if (bObject.getType() == "Empty"):
        # get position of the empty
        location=bObject.getLocation()
        # check if empty has a parent
        if bObject.getParent():
            # we assume that the parent is a bone
            parentBoneName=bObject.getParentBoneName()
            # get bone object
            parentBoneObj=bObject.getParent().data.bones[parentBoneName]
            # get location of the parent bone
            parentBone=parentBoneObj.getLoc()

The last line causes the error:

Traceback (most recent call last):
  File "<string>", line 35, in ?
AttributeError: 'Bone' object has no attribute 'getLoc'

What am I doing wrong there? Thx.

pose location or rest location?

Rest location.

Use the docs to find out properties, here are recent ones built from CVS.
http://members.optusnet.com.au/cjbarton/BPY_API/

try replace
parentBone=parentBoneObj.getLoc()
with
parentBone=parentBoneObj.head[‘ARMATURESPACE’]

Thanks ideasman42! It did the trick.