# Extract object properties from animation for each frame

I am an absolute beginner, please forgive me if this is a basic question. I am using Blender 2.91.

So I have n objects one in the middle and others surrounding it and the one in the middle is the parent of everything else. I am rotating the middle one using keyframes that results in the others revolving around it. Now I am playing it using python and have a handler for frame change. Here I want to extract object properties like location and position of each object for each frame.

Currently I am using obj.rotation_euler and obj.location to fetch the properties, but I get same values for all frames. (I am doing this inside the handler, so I presume it has the current frame properties in the ‘scene’ param?)

So can you please tell me how to extract these properties per frame. Note, I need to do some mathematical calculation with the values , if that makes any difference.

Will be grateful for any help.

Edit 1 :

def process_obj_location(scene):
if scene.frame_current in frame_read_counter:
return
print(f"\nProcessing object location for frame : {str(scene.frame_current)}")
# for obj in bpy.context.scene.objects:
for obj in scene.objects:
if obj.type == 'MESH':
location = obj.location
object_instance = scene_objects_dict.get(obj.name, None)
object_instance.set_location(location)

frame_read_counter.append(scene.frame_current)
print(f"Finished processing locations for frame {str(scene.frame_current)}")

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

• Showing your code will help us writing an answer. Basically you have to multiply (@ operator) local coordinates by matrix_world property of the object. Feb 7, 2021 at 23:32
• Hi. Actually I was not sure which part of the code to post, however I have added what I think is relevant. Thanks for your reply. Can you please tell me how to use the matrix_world. It says 'NameError: name 'matrix_world' is not defined' to me. I did 'location = obj.location@matrix_world' Feb 8, 2021 at 0:02
• Finally understood what you meant :').. loc = obj.matrix_world@obj.location worked! Thank you! How can I select your answer as the correct one? Feb 8, 2021 at 0:17

## 1 Answer

I haven't tested your code, but if everything else works, you will be fine after replacing

location = obj.location


with

location = obj.location @ obj.matrix_world

• Or simply location = ob.matrix_world.translation Feb 8, 2021 at 11:46