Phlok
10-02-2009, 12:55 PM
Hi,
in my expression, I want to translate some spheres. So I first put them all into an array and in a for- loop there are some operations done.
Unfortunately, I always get syntax errors:
string $spheres[] = `ls -type geometryShape`;
int $offset = frame - $frmStart;
for($i = 0; $i <= $offset; $i++)
{
float $posY = $spheres[$i].translateY;
if($posY < $yMax)
{
$spheres[$i].translateY = $posY + smoothstep($yStart, $yMax, $posY);
}
else
{
$spheres[$i].translateY = $posY - smoothstep($yStart, $yMax, $posY);
if($spheres[$i].translateY < 0)
{
$spheres[$i].translateY == 0;
}
}
}
Maya don't like this $spheres[$i].translateYand I really do not see, why that is so.
Coming from an object oriented programming language, it feels really disturbing not to be able to just have an array of sphere objects but of strings identifiying those sphere objects.
So now I want to call the translateX variable of the spheres via that array but all I get is a syntax error. So how do I do that correctly with MEL?
in my expression, I want to translate some spheres. So I first put them all into an array and in a for- loop there are some operations done.
Unfortunately, I always get syntax errors:
string $spheres[] = `ls -type geometryShape`;
int $offset = frame - $frmStart;
for($i = 0; $i <= $offset; $i++)
{
float $posY = $spheres[$i].translateY;
if($posY < $yMax)
{
$spheres[$i].translateY = $posY + smoothstep($yStart, $yMax, $posY);
}
else
{
$spheres[$i].translateY = $posY - smoothstep($yStart, $yMax, $posY);
if($spheres[$i].translateY < 0)
{
$spheres[$i].translateY == 0;
}
}
}
Maya don't like this $spheres[$i].translateYand I really do not see, why that is so.
Coming from an object oriented programming language, it feels really disturbing not to be able to just have an array of sphere objects but of strings identifiying those sphere objects.
So now I want to call the translateX variable of the spheres via that array but all I get is a syntax error. So how do I do that correctly with MEL?
