Scripting a lattice armature
Armatures are the recommended way for animating in Blender as they support linking across different .blend
files and other advanced animation features.
Binding a lattice to an armature allows you to animate deformations without switching to Edit Mode to edit grid vertices.
Adding an armature condition
We want armatures to be an optional feature, so we can add another property for that. We set its default value to True
, so an armature is created unless it’s set otherwise:
add_armature: bpy.props.BoolProperty(default=True)
Inside the execute
method, we check for this value and proceed accordingly.
Adding an armature to the scene
Armatures are created in the same way as lattices and other objects:
- Create new data.
- Create a new object using the data created.
Even if it is not strictly required, we set the new armature as the parent of the lattice to ensure consistency between their transforms...