How can I get a bone position in pose mode ?

(Mehd) #1


I’m trying to write a script for automatic animation, but I’m stuck in getting the bone position in pose mode. Could anyone point me the good method ?

So far, I

  • Get the armature using bpy.context.objects[‘Armature’]
  • Reference the bones by[‘NameOfTheBone’]
  • I’m able to move the bones by script by selecting them through[‘NameOfTheBone’].select = True and bpy.ops.transform.translate/rotate
  • However, I can’t figure out how to get their positions in pose mode

Any tips ?

Thanks a lot !

(<== Lost? Click Me) #2

Hi. If you hover over GUI fields you’ll be shown the relevant bpy for your desired data. So in pose mode mouse over location for instance. Another helpful feature is hidden in the Info window (Top bar mostly, has the File menu). If pulled down it will display alternate paths to data when altered. Try the Scripting layout if my explanation is unclear. In pose mode translate a bone and observe the Info window. Right click anything you want to copy from there for your script.

Info window gave bpy.context.object.pose.bones[“Bone”].location[:]
Hovering the mouse gives