Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

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 08-05-2004, 05: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, 06: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, 11: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, 11: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, 04: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

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-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.