# How to get the new location of an object after a lattice deform?

I am using a lattice to displace an object and I would like the new location of the object after the lattice deform happens. I am trying to do this through the Blender API. ob is my sphere. ob.location is still giving me 0,0,0 and when I look at the 3D Viewport it also shows 0,0,0.

• Closed and re-opened, See. blender.stackexchange.com/questions/146559/… As can be seen in image above the origin is not moved, the mesh is modified wrt to the original origin. Link shows how to get the modified mesh & hence coordinates. The "new" origin can be calculated from these. For case of sphere above could look at half way between pole verts, But (big but) will depend on lattice deform (and other modifiers) ... Would consider using a constraint approach. Constrain an empty to copy location Jun 8, 2021 at 11:10
• of vertex group. blender.stackexchange.com/questions/139640/… Jun 8, 2021 at 11:11

I had to select each object, apply the modifier to my object, reset my origin to the center of mass, finally deselect the object. Repeat for all objects with the modifier.

bpy.ops.object.select_all(action = 'DESELECT')

for ob in collection.objects:
if ob.type == "MESH":
for modifier in ob.modifiers:
ob.select_set(True)
bpy.context.view_layer.objects.active = ob
bpy.ops.object.modifier_apply(modifier = modifier.name)
bpy.ops.object.origin_set(type = 'ORIGIN_CENTER_OF_MASS')
bpy.ops.object.select_all(action = 'DESELECT')