SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Animation / Mel Scripts & Programming / incrementing variables in loops
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 22-12-2008, 03:18 AM   #1
bendingiscool
Subscriber
 
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, 10:37 AM   #2
BennyK
Registered User
 
BennyK's Avatar
 
Join Date: Oct 2007
Location: IL
Posts: 738
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Not sure about that but I think you have to define the array outside the loop. Have a look into this.
Benny
__________________
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, 05:34 PM   #3
vladimirjp
Subscriber
 
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
Default

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
New Thread

« Previous Thread | Next Thread »

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.