World coordinates of child objects. Vertex parenting


I have an object Plane with 6 vertices. To each vertex I assign another object as child.

Then I apply two keyframes on location to object Plane:

  1. In frame 0 it goes to Z = 5
  2. In frame 81 it goes to Z = 0

I want to know correct global x,y,z coordinates of each Sphere during frames 0 to 81.

Frame 81. Plane and child Spheres
enter image description here


I do not understand which matrix or matrix combination to use to achieve coordinates in this case.

For example for frame 81 I know that Z = 0 for Plane. It is also Z = 0 for all spheres.

I would like to know object Sphere global coordinates. If I code in Blender console:

>>> sp0.matrix_world.to_translation()
Vector((-1.0, -1.0, 0.0))

>>> sp0.location
Vector((-1.0, -1.0, 5.0))

If I write python script and run it I have:

obj =['Sphere']
x,y,z = obj.matrix_world.to_translation()
print("x,y,z ", [x,y,z])
print("setpoint_location ", obj.location)

>>>x,y,z  [-1.0, -1.0, 5.0]
>>>setpoint_location  <Vector (-1.0000, -1.0000, 5.0000)>

Additional info

Code I use to create Spheres and attach it to Plane as child objects on each vertex.

import bpy

def create_objects():
    for i in range(6):
        bpy.ops.mesh.primitive_uv_sphere_add(radius=0.25, enter_editmode=False,location=(i*2., 0, 0))
def allocate_objs(plane, objects):
    for i, vert in enumerate(
        world_matrix = plane.matrix_world
        vertice_coords = world_matrix @
        objects[i].location = vertice_coords

    plane.select_set(True) = plane

objects = [obj for obj in if "Plane" not in]
plane =["Plane"]
#allocate_objs(plane, objects)
obj =['Sphere']

for frame in range(0,100):
    bpy.context.scene.frame_current = frame
    if frame in [0, 81]:
        x,y,z = obj.matrix_world.to_translation()
        print("world matrix \n", obj.matrix_world)
        print("matrix_basis \n", obj.matrix_basis)
        print("matrix_local \n", obj.matrix_local)
        print("matrix_parent_inverse \n", obj.matrix_parent_inverse)
        print("frame ", frame)
        print("x,y,z ", [x,y,z])
        print("setpoint_location ", obj.location)