Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   incrementing variables in loops (https://simplymaya.com/forum/showthread.php?t=31600)

bendingiscool 22-12-2008 04:18 AM

incrementing variables in loops
 
Hey, so there a way to create incremented variables inside of loops, for instance...

///////////////////
// select some objects
string $selObjects[] = `ls -sl`;

// loop through items in selection and store their bounding box info
for ($i=0;$i<$selObjects;$i++)
{
float $agentBBox[] = `xform -q -ws -boundingBox ("object_" + $i)`;// cylinder's BBox
}
//////////////////
This will store each objects bounding box once and then overwrite it the next time it goes through the loop, what I would like to do would be to create a new float array each time it goes through the loop.

Many thanks, Chris

BennyK 22-12-2008 11:37 AM

Not sure about that but I think you have to define the array outside the loop. Have a look into this.
Benny

vladimirjp 22-12-2008 06:34 PM

u can create on array outside the loop and store incrementally a bounding box property in each element. u dont have to create a new array each time.


All times are GMT. The time now is 01:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018