I am trying to get the coordinates of all vertices of a model for each frame of an animation in Blender using python. I have seen a lot of answers from 50 years ago like Iterating vertex of every frame in Blender that don't work and give me the same coordinates in every frame. This looked like a trivial thing that should be accessed by a simple function call or a field, I don't understand why it was like this.
obj = bpy.data.objects[0]
sce = bpy.context.scene
for f in range(sce.frame_start, 250 + 1):
sce.frame_set(f)
m = []
for o in obj[2:]:
o1 = o.to_mesh(preserve_all_data_layers=True)
m.extend([o.matrix_world @ v.co for v in o1.vertices])
outputs.append(m)
In the other post I included, they say that you have to create a mesh for every frame. Although the arguments from their example don't work anymore. The models I use are from Mixamo that have different meshes for different body parts so I had to also iterate over the child objects to get all points of my mesh. The code above results the same points for every frame.