I'm trying to export animation data, but my bones never get updated from keyframe to keyframe. This is how I iterate over my actions and keyframes:

for action in bpy.data.actions:
    armature.animation_data.action = action
    while {'FINISHED'} == bpy.ops.screen.keyframe_jump():
        for boneName in bones_index:
            bone = armature.pose.bones[boneName]
            mat = glob_mat * mathutils.Matrix(bone.matrix)

The 'mat' variable is the bone matrix for each bone. Per frame, the 'mat' variable doesn't seem to change. For example, if I only look at the bone "Leg", the leg pose matrix doesn't seem to change keyframe to keyframe. The matrix is the correct matrix for frame 0, and it is different from my base pose. Am I not getting the pose matrices correctly? Or am I not correctly changing the scene? In the blender console, bpy.ops.screen.keyframe_jump() does exactly what I want, so I don't think that's the issue.

  • $\begingroup$ Well, you are in luck I think. CodemanX just answered this for someone else a few days ago and the code is very easy to work with. blender.stackexchange.com/questions/8387/… $\endgroup$ Apr 12, 2014 at 18:33
  • $\begingroup$ @MarcClintDion If a question seems to be asking the same thing as a previous question, feel free to cast a "close as duplicate" vote. $\endgroup$
    – gandalf3
    Apr 12, 2014 at 20:05
  • $\begingroup$ @gandalf3 it's not exactly the same (but very close). That in that thread, their solution was going from the start frame to the end frame (iterating over every single frame). What I want is to iterate over key frames. That's why bpy.ops.screen.keyframe_jump() is used. It jumps to the next key frame. That seems to work, and the code I have works perfectly in the interactive console. However, when I put it in a text file and run it from there, the pose bones are stuck in the pose of the first frame. I even call bpy.context.scene.update(), but that didn't seem to help $\endgroup$ Apr 12, 2014 at 22:50

1 Answer 1


On some further investigation, and looking at other threads, I solved my issue by using the following method to update the scene.


So now I'm thinking there is a bug in how bpy.ops.screen.keyframe_jump() is implemented. The line I added should theoretically do nothing (ie. setting the current frame to the current frame should be a no op). The strange thing is that my original implementation worked in the interactive console, but not when I put it in a text/export file and run it from there.

  • $\begingroup$ you're a life saver $\endgroup$
    – Jagoly
    Jul 31, 2017 at 13:12

Not the answer you're looking for? Browse other questions tagged .