Hi everyone! I'm currently learning how to use MEL to automate some repetitive tasks in my rigging/animation workflow and I've run into a problem. I thought I'd post my script here to see if anyone can point me in the right direction.
Basically, this script is designed to create blendshapes for clothing and accessories to match a rigged character's blendshapes. The character is going to be exported to Unity, which doesn't support wrap deformers, so I've had to come up with another solution to get the clothing to match the body deformation.
The script takes a selection of clothing objects. For each object, it assigns a wrap deformer that connects the object to the main body geometry, enables each body blendshape one at a time, bakes out a new mesh, and then disables the blendshape before moving onto the next one. When all the blendshapes have been baked, it deletes the wrap deformer, assigns all the blendshapes to the clothing object, and connects each blendshape's value to the corresponding blendshape in the main body.
//Apply these steps to each selected object
string $array = `ls -sl`;
string $blendShape = `listAttr -m ("Genesis8FemaleBlendShapes.w")`;
for ($item in $array)
//Create a wrap deformer from base G8F mesh
select -r $item Genesis8FemaleFBXASC046Shape ;
select -r $item;
//Iterate through each blendshape
for($target in $blendShape)
//Get the name of the current object
string $currentBlendShape = $target;
//Enable the blendshape, duplicate and rename the geoemetry, and disable the blendshape
setAttr ("Genesis8FemaleBlendShapes." + $currentBlendShape) 1;
setAttr ("Genesis8FemaleBlendShapes." + $currentBlendShape) 0;
select -r $item;
I've isolated just the first part of the script, which is where the problems seem to be originating. There are two issues-
1) Upon running the script, I get two warning messages:
// Warning: Line 3.31 : Redeclaration of variable "$array" shadows previous declaration at line 1. Previous value will be overwritten by explicit initializer. //
// Warning: Line 4.73 : Redeclaration of variable "$blendShape" shadows previous declaration at line 2. Previous value will be overwritten by explicit initializer. //
2) The script takes more than 10 minutes to run, and on more than one occasion has caused Maya to run out of memory and crash. I am dealing with a large number of blendshapes (between 100-200), but in an earlier version of the script where I specifically called each blendshape by name, the entire script would finish in less than 30 seconds. I'm trying to update the script now so I don't have to edit the script manually every time I add or remove additional blendshapes to the main body.
Does anyone know what these warnings mean and if they're going to cause problems when I run the script? And is there anything I've overlooked that could account for the performance issues?
Thanks in advance