Dynamic Lattice Script (first script I've made WIP)

Creates lattice and orients it in the direction you want automatically and scales it appropriately.
It does NOT take rotation data from the mesh meaning this works even if you select "apply rotation"

Rather it analyzes the mesh based on the vertices. There may be other lattice addons that do this but I am not aware of them (I hope there isn’t, I want to be the first one). They all seem to create a lattice at orients itself into default global coordinates or copies the rotation of the mesh.

Works with:

  1. Object in Object mode
  2. Object in Edit mode (selected vertices)
  3. Multiple objects in Object mode
  4. Multiple objects in Edit mode (selected vertices)

Potential problems and work I need to do:

  1. Doesn’t apply the lattice modifier to the mesh but this should be an easy task
  2. I don’t know how to code a user interface
  3. May give weird results if the mesh has uneven vertex density
  4. Meshes may also stick out of lattice if it’s too far away from the others
  5. Due to the fact that this analyzes vertices, performance may suffer greatly for meshes with high vertex count
  6. Take into account modifier vertices as Michael_Knubben suggested

Test Meshes:

Single Objects:

Multi Objects:

Multi Object Edit Mode:

3 Likes

Does this one take into account mirror/array modifiers? A previous script I used would only place the lattice along the original geometry, ignoring the extra geometry created by the modifiers.

I haven’t thought about that. The difficulty in implementation would depend on whether the Blender stores the modifier vertices so I can have access to it.

1 Like