Maya Training

Creating characters In Maya and Zbrush

Maya Training

Creating character renders in Maya 2017 and Arnold

Maya Training

Spach-Alspaugh House the complete courseware
You are here > Home > SimplyMaya Community Forums

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 22-12-2008, 04:18 AM   #1
bendingiscool's Avatar
Join Date: Jul 2006
Location: London
Posts: 567
Thanks: 0
Thanked 1 Time in 1 Post
Default 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
bendingiscool is offline   Reply With Quote
Old 22-12-2008, 11:37 AM   #2
Registered User
BennyK's Avatar
Join Date: Oct 2007
Location: IL
Posts: 738
Thanks: 0
Thanked 3 Times in 3 Posts

Not sure about that but I think you have to define the array outside the loop. Have a look into this.
When in doubt, delete history and freeze transformations.

My latest snake game
(Requires DirectX9 SDK and Framework)
BennyK is offline   Reply With Quote
Old 22-12-2008, 06:34 PM   #3
vladimirjp's Avatar
Join Date: Jun 2003
Location: stuck in the 90's boston, USA
Posts: 1,871
Thanks: 0
Thanked 4 Times in 3 Posts

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.
Image dump
vladimirjp is offline   Reply With Quote

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2017 SimplyMaya - vBulletin® Copyright © 2000-2017, Jelsoft Enterprises Ltd.