How to - Maya - add object to lattice tutorial

Report this File





Dec 06, 2010

Readership Level:



maya, mel, script, lattice, object, add, geometry

Maya Versions:

6.x, 7.x, 8.x, 2008, 2009, 9.x, 2010, 2011


linux, mac, windows




The following is a quick and easy tutorial that shows you how to add objects to a lattice in Maya. It is useful if you already have geometry with a lattice applied and need to add extra objects to the lattice. Also useful if you want to position geometry in a particular way in relation to the lattice before connecting the two together.

Firstly you need to create your lattice -
  • Make sure you are on the animation menu set then goto – Create Deformers > Lattice and open up the dialog box.
  • Set the number of divisions of the lattice that you require.
  • Set the behaviour of the lattice on points outside of the lattice from the drop-down box.

Next position your object where you want it in relation to the lattice.

Select the lattice, then the objects.

Open up the script editor

Type in the following -

string $selSet[] = `ls -sl`;
string $lattice = $selSet[0];
string $object = $selSet[1];
lattice -e -g $object $lattice;

Highlight the MEL code and hit enter (the one beside the keypad, not the main one).

[This can be repeated for as many objects as you wish]


Dec 06, 2010
Post id: 13209
Report this comment to moderators [SPAM]

Yeah, you could either do that, or go into the Window -> Relationship Editos -> Deformers Sets, then choose your set for your lattice.

Muche easier with script though.

Feb 16, 2011
Post id: 13831
Report this comment to moderators [SPAM]

//even better with a quick for loop (only 2 extra lines)
//select all objects you wanna add to lattice then shift select the lattice last

string $selSet[] = `ls -sl`;
int $size = `size ($selSet)` ;
select -d $selSet[$size-1] ;
string $sel = `ls -sl` ;
string $lattice = $selSet[$size-1] ;
for ($s in $sel) { lattice -e -g $s $lattice ; }

//should work, haven't checked, ain't got Maya on laptop but just giving you general idea

Oct 25, 2012
Post id: 17020
Report this comment to moderators [SPAM]

and converted to python:

import maya.cmds as cmds

for obj in objs:

Write a Comment

You must be logged in and have verified your email address to leave a comment. Login or create an account