0
$\begingroup$

I write an exporter to retrieve the pose bone matrix for every frame.

The concept looks like this, the code is called from an exporter class via an operation button in the tool shelf:

for action in actions:
    for frame in range(action.frame_range[1]):
        bpy.context.scene.frame_set(frame)
        context.scene.update()

        for poseBone in armature.pose.bones:
            exportMatrix = poseBone.matrix

However, the exported poseBone.matrix values all have the same values from one frame. I checked in the pyhton console if the values change when i manually change the current frame and they do.

What am I missing to update the pose bone matrix after a frame change?

$\endgroup$
  • 1
    $\begingroup$ you're not setting the armature's active action to "action", and "context.scene.update" should probably be "bpy.context.scene.update" $\endgroup$ – HENDRIX Feb 26 '19 at 14:54
0
$\begingroup$

To summerize, I needed to perform these changes:

for action in bpy.data.actions:
    bpy.context.object.animation_data.action = action # sets active action
    for frame in range(numberOfFrames):
        bpy.context.scene.frame_set(frame)
        bpy.context.scene.update()
        for bone in bpy.context.object.data.bones: # instead of armature.pose.bones
            poseBone = armature.pose.bones[bone.name]
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.