Newbie's Question

ok guys, I try to write a loop script to build and move up the floors of a building. Here's the code,

//start $i at 0
$i = 0;

//loop while $i is less than 20
while($i++ < 20){

//duplicate object(floor)
duplicate pCube1;

//move it up
move 0 $i 0;

}

This script only duplicate, doesn't move.
I'm new to MEL script, though this script is simple, but i really need some help. Thanks.

I'm not sure about this, but atleast in C++ (From what I have read it...), while loop just needs the condition in the ()'s, so it would be like this:
while ($i < 20)
{
...
$i++
}
instead of
while ($i++ <20)
{
...
}
Though I didn't quite understand if it already works... but just thought I would share that :slight_smile:

Then, another solution would propably be that you have to select the object, but I can't remember now the command (Don't have Maya or it's manual at me right now), but you could search for it yourself

I hope I was atleast a bit helpfull?

Yeah, its just that you havent specified which object(s) you want to move, like you have been for duplication.

So to go along w the form of your loop construct, just pop a name into the move command ...

//start $i at 0
$i = 0;

//loop while $i is less than 20
while($i++ < 20){

//duplicate object(floor)
duplicate pCube1;

//move it up
move 0 $i 0 ("pCube" +$i);

}

...so it will tanslate the newly duplicated cube of the current loop. The brackets and quaotations are there so you can build up the string name from both string characters and the $i variable character.

C.

Good Campbell! This is a great line to call the duplicated object!
move 0 $i 0 ("pCube" +$i);

Thanks guys, now I can rest assure I can get some help from this forum next time. Seeya.