The Lattice modifier is used to simplify the process of deforming high-poly meshes using simple wireframe objects with a few points – lattice. The lattice is superimposed on the mesh and associated with it, after which, by manipulating its point, we can deform the mesh itself. We can access the coordinates of the lattice points with the Blender Python API through its “points” property.
Let’s add a sphere to the scene (shift + a – Mesh – UV Sphere).
Next, add a lattice object (shift + a – Lattice) and increase its size so that it covers the entire sphere.
Append the Lattice modifier to the sphere. In the “Object” field of the modifier, set the previously added lattice object
Now we can access the lattice object from the UV Sphere mesh – the currently active object.
1 2 3 4 |
lattice = bpy.context.object.modifiers[0].object print(lattice) # bpy.data.objects['Lattice'] |
The list of points of the Lattice object can be obtained through its “points” property.
1 2 3 |
bpy.context.object.modifiers[0].object.data.points[:] # [bpy.data.lattices['Lattice'].points[0], bpy.data.lattices['Lattice'].points[1], ...] |
Walking through the list of the Lattice object points, we can get a list of their coordinates:
1 2 3 |
[p.co for p in bpy.context.object.modifiers[0].object.data.points] # [Vector((-0.5, -0.5, -0.5)), Vector((0.5, -0.5, -0.5)), ...] |
For exporting or another use.