I’m writing a script to “bake” the absolute positions of an animation into a file.
Unfortunately, even if I update the frame_current of a scene, neither the local nor the absolute locations are updated.
inserting a Scene.update() didn’t help.
Here is a simple test script (Blend scene in attachment):
import bpy
scene = bpy.context.scene
obj = bpy.context.active_object
print("Baking location for object "+obj.name)
for f in range(scene.frame_start, scene.frame_end+1):
scene.frame_current = f
scene.update()
loc = obj.location
abs_loc = obj.matrix_world.translation
print("Frame "+str(f)+" -> loc="+str(obj.location)+" abb_loc="+str(abs_loc))
The output shows the same values for each frame:
Baking location for object Cube
Frame 1 -> loc=<Vector (0.0000, 0.0000, 0.0000)> abb_loc=<Vector (0.0000, 0.0000, 0.0000)>
Frame 2 -> loc=<Vector (0.0000, 0.0000, 0.0000)> abb_loc=<Vector (0.0000, 0.0000, 0.0000)>
...
Frame 25 -> loc=<Vector (0.0000, 0.0000, 0.0000)> abb_loc=<Vector (0.0000, 0.0000, 0.0000)>
How can I solve it?
Attachments
BakeTest.blend (454 KB)