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]
Comments
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.
//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
and converted to python:
import maya.cmds as cmds
sel=cmds.ls(selection=True)
lat=sel[-1]
objs=sel[0:-1]
for obj in objs:
cmds.lattice(lat,e=True,geometry=obj)
Write a Comment