How to - Maya - add object to lattice tutorial

Report this File

Missing

Views:

25,853

Updated:

Dec 06, 2010

Readership Level:

Basic

Tags:

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

Maya Versions:

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

Platforms:

linux, mac, windows

Owner:

Language:

English

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

Dashboard_avatar
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.

Dashboard_avatar
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

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

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

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