I have baked the attached simulation for 500 frames with some keyframes inserted for each object where it follows an animated path after which it free falls according to Blender's rigid body physics. How do I get the location of each of the objects in the scene at frame 500?

This is something I've tried but it outputs the locations at frame 1.

I've attached the .blend file.

import bpy, os

#select all objects in scene

SEL_OBJS = bpy.context.selected_objects

# get path to render output (usually /tmp\)
tempFolder = os.path.abspath (bpy.context.scene.render.filepath)
# make a filename
filename = os.path.join (tempFolder, "sample.txt")
# confirm path exists
os.makedirs(os.path.dirname(filename), exist_ok=True)
# open a file to write to
text_file = open(filename, "w")

#loop through all selected objects
for OBJ in SEL_OBJS:
    text_file.write('OBJECT NAME: '+OBJ.name+'\n')
    text_file.write('COORDINATES: '+str(OBJ.location.x)+', '+str(OBJ.location.y)+', '+str(OBJ.location.z)+'\n')
    text_file.write('ROTATION: '+str(OBJ.rotation_euler.x)+', '+str(OBJ.rotation_euler.y)+', '+str(OBJ.rotation_euler.z)+'\n\n')

# close the file    
  • $\begingroup$ Hey, can you please elaborate? Where do I add this line? $\endgroup$ Oct 19, 2020 at 17:14

1 Answer 1


the obj.location results in the local location, not including parenting relationships. Same goes for the rotation_euler.

loc = OBJ.matrix_world.translation
rot = OBJ.matrix_world.to_euler()
text_file.write('COORDINATES:', str(loc.x), ',', str(loc.y),',', str(loc.z) + '\n')

the matrix_world returns the actual world coordinates of the object after calculating all parenting and constraints.

  • $\begingroup$ Thanks, man. :) $\endgroup$ Oct 19, 2020 at 17:58

You must log in to answer this question.

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