I’m using Blender 2.5 and trying to figure out how to get a bone’s current keyframe location/rotation.
I’ve been looking around the API, but can’t seem to find anything. Can anyone help?
I’m using Blender 2.5 and trying to figure out how to get a bone’s current keyframe location/rotation.
I’ve been looking around the API, but can’t seem to find anything. Can anyone help?
it depends; what do you mean by your use of the word “current”?
Hi Mardok45
For the following you will need to replace “Armature” with the name of your armature object, and “jaw” etc
posebone = bpy.objects[“Armature”].pose.bones[“jaw”] will give you reference to the jaw bone… you can get its x location with posebone.location[0] for instance.
You can also access action fcurves using bpy.objects[“Armature”].action.fcurves. Each fcurve has a data_path property and an array_index. So for the above there will be an fcurve with ‘pose.bones[“jaw”].location’ as a data_path and array_index 0. The fcurve has a handy evaluate method that lets you get the value for any given frame. There is also a keyframe_points collection in the curve which has the frame,value pairs for the keyframes.
Lastly take a look at this thread http://blenderartists.org/forum/showthread.php?t=204516 the visual transform matrix there will give you the “final product” if your bones are involved in IK and the like.
AAAARRRRGH! I didn’t see the pose module! Hours of looking and it was right under my nose.
Thanks a lot batFINGER.
edit: there is a difference between Object and single-bones in posemode …
if i use a object like the default cube, i get entries in the fcurve visual-location,
but the animation does not use those entries … -? any clues?
Hi,
I’m quoted so i feel i need to respond … but am a little confused. I havent used visualLoc/Rot etc much at all. My understanding is that visual takes into account the constraints… or more to the point gives the properties of where it lies on your screen in your scene so to speak.
there is a difference between Object and single-bones in posemode …
if i use a object like the default cube, i get entries in the fcurve visual-location,
but the animation does not use those entries … -? any clues?
I’d need an example.