Getting the location of objects that are on a path?

Hi,

For a visualization I’ve written a script the simulates traffic of people in a space by creating spheres and moving them along a path (with different offsets in time) . Next i’m trying to get some (simulated) sensor data relating to the location of the ‘people’.

I’m having trouble with this as the objects that are constraint by the follow_path contraint keep an origin location of (0,0,0), even though the mesh is obviously moving along the path as intended.
Is there a way to script to find out the true location of the mesh rather than that of the origin?

Thanks

Assume you have the default Cube constrained to a default BezierCurve via a Follow Path constraint.


import bpy

ob = bpy.data.objects.get("Cube")
cu = bpy.data.objects.get("BezierCurve")

print(dir(ob))
new_loc = ob.matrix_world * cu.matrix_world
print(new_loc)
print(dir(new_loc))
t = new_loc.to_translation()
print(t.x,t.y,t.z)

t will contain the X,Y,Z of the cube in world space.

Attachments

27_position_along_path.blend (88.6 KB)