0

I tried to get the location data of a falling cube in a rigid body simulation. Therefore I added a post-frame-handler:

  bpy.app.handlers.frame_change_post.append(my_handler)

and the handler should only print the location of the cube:

def my_handler(scene):
    print("Post  Frame Change", scene.frame_current)
    cube = bpy.data.objects["Cube"]    
    print(f"{cube.location}")

When the animation is played (just by starting timeline animation in Blender), the location will not be updated (in Blender 3.3).

Now my question is: How can I force Blender to update the location data? OR
Could one read other object properties which already are updated while calculating the rigid body simulation (obviously this data must exist, cause they are calculated within the animation) ?

Thank you!

The blend-file of the simulation is here:

Mike75
  • 205
  • 1
  • 7
  • You'll have to use the dependency graph https://blender.stackexchange.com/questions/216149/how-to-get-frame-by-frame-object-location-in-blender-2-8 – Psyonic Dec 03 '22 at 00:48
  • Thanks a lot! That's exactly what I was looking for. Please post it as answer, if you want! – Mike75 Dec 03 '22 at 08:28
  • I just saw that I asked this some time before: https://blender.stackexchange.com/questions/274779/animation-locations-with-python Meanwhile I was working on other stuff so I simply did forget the solution. Nevertheless I think your hint with the dependency graph is so useful, that it is worth to mention it here again. – Mike75 Dec 03 '22 at 09:22
  • All good mate, not my answer so I can't take the credit – Psyonic Dec 05 '22 at 08:56

0 Answers0