SimplyMaya Forums

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

Home / forum / Animation / Mel Scripts & Programming / Help with a Script
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 08-05-2004, 04:53 AM   #1
TheElement
Registered User
 
Join Date: Apr 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with a Script

Hey guys, this is my first post on simplymaya.com, but I heard this is a pretty good forum. Here's the deal: I'm trying to write a script that takes a group of selected objects and sets the translateY for each object equal to the translateZ. In the script below, no matter what I try, I get the error message:

// Error: for ($i = 0, $i < $tempArrSize, $i++){
//
// Error: Syntax error //
// Error: }; //
// Error: Syntax error //

Here's the script. If anyone has any idea how I can fix this, PLEASE help me out. I've tried a post in other forums with little success so I'm running out of resources. Thanks in advance.

//sinfunc: function takes a group of selected objects and
//graphs them according to the equation y = z

global proc sinfunc(){

//stores each selected object in an array

string $sel[];
$sel = `ls -sl`;

//defines some variables and sets the
//$tempArrSize as the number of selected objects

int $tempArrSize;
int $i;
string $tempObj;
$tempArrSize = size($sel);

//Moves through each object in $sel and sets
//the translateY equal to the translateZ

for ($i = 0, $i < $tempArrSize, $i++){
$tempObj = $sel[$i];
setAttr ($tempObj + "." + "translateY") ($tempObj + "." + "translateX");
}
};
TheElement is offline   Reply With Quote
Old 08-05-2004, 05:00 AM   #2
dannyngan
Registered User
 
dannyngan's Avatar
 
Join Date: Dec 2002
Location: Seattle, WA
Posts: 1,154
Thanks: 0
Thanked 1 Time in 1 Post
Default

Looks like you have an extra curly bracket ( } ) at the end of your script. Just delete it.

Also, no need to cross-post in different forums. People will see your one post.
__________________
Danny Ngan
Animator | Amaze Entertainment
my website | my blog | my job
dannyngan is offline   Reply With Quote
Old 08-05-2004, 10:22 PM   #3
TheElement
Registered User
 
Join Date: Apr 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The last curly bracket is to close the procedure, the second to last one is to close the for loop. When I try deleting the last } I this error:

// Error: for ($i = $tempArrSize, $i > 0, $i--){
//
// Error: Syntax error //

Any ideas?
TheElement is offline   Reply With Quote
Old 08-05-2004, 10:29 PM   #4
dannyngan
Registered User
 
dannyngan's Avatar
 
Join Date: Dec 2002
Location: Seattle, WA
Posts: 1,154
Thanks: 0
Thanked 1 Time in 1 Post
Default

The For loops are declared incorrectly. Instead of commas (,) you should use semicolons ( between the loop parameters. So for instance, your for loop should look like this:

Code:
for ($i = $tempArrSize; $i > 0; $i--){......}
__________________
Danny Ngan
Animator | Amaze Entertainment
my website | my blog | my job
dannyngan is offline   Reply With Quote
Old 15-05-2004, 03:08 AM   #5
Nametag
Subscriber
 
Nametag's Avatar
 
Join Date: Apr 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi ive had a quick look at your code and simplified it alittle.
Basically it gets the value of transZ from the current obj and sets transY to the same for each obj in the array.

code:
-----------------------------------------------------------
float $translatez = 0;
string $SelectedObj[] = `ls -sl`;
int $size = size($SelectedObj);

for ($i = 0; $i<$size; $i++)
{
$translatez = `getAttr ($SelectedObj[$i] + ".translateZ")`;
setAttr ($SelectedObj[$i] + ".translateY")$translatez;

}

-------------------------------------------------

Hope this helps
__________________
www.keyframer.co.uk
Nametag 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.