FORUMS TUTORIALS FEATURES VIDEOS PODCASTS EVENTS SERVICES NEWSLETTER NEWS BLOGS
 MAYA: MAYA Forum MAYA Tutorials MAYA

# Re: MEL: assign a unique multiplier

COW Forums : MAYA

 Re: MEL: assign a unique multiplierby Steve Sayer on Apr 13, 2005 at 8:22:12 pm

[Geoff Bailey] "Lastly, none of this solves my original problem (thanks for the other comments, though): how to avoid 1200 expressions."

EEEK.

Sorry, I mistook the focus of your original post.

Good heavens, Geoff, only one expression should be needed.

What you want to do is create an iterative loop that will step through all your layers automatically, incrementing the offset for each. Try something like the following. This example uses four NURBS spheres, the first one keyframed manually:
```int \$i;
vector \$position = <<0,0,0>>;
for (\$i = 2; \$i < 5; \$i++)
{
string \$object = ("nurbsSphere" + \$i);

float \$offset = \$i * 3;

float \$valueX = `getAttr -time (frame - \$offset) nurbsSphere1.translateX`;
float \$valueY = `getAttr -time (frame - \$offset) nurbsSphere1.translateY`;
float \$valueZ = `getAttr -time (frame - \$offset) nurbsSphere1.translateZ`;

vector \$position = <<\$valueX, \$valueY, \$valueZ>>;

eval("setAttr " + \$object + ".translate " + \$position);
}
```
The key here is using commands nested in a 'for' loop.

The incremenent integer \$i counts up as the 'for' loop iterates, and the 'getAttr' and 'eval' commands incorporate the resulting offset into each iteration of the read-and-set attribute operations.

Hmmm, I see Joaquin has posted a reply. I don't know exactly what you're doing with layers and instances; hopefully something that I've posted here will turn out to be useful. Post again if I haven't explained anything well enough.

-Steve