Introduction to Maya - Modeling Fundamentals Vol 2
This course will look in the fundamentals of modeling in Maya with an emphasis on creating good topology. It's aimed at people that have some modeling experience in Maya but are having trouble with complex objects.
# 1 08-05-2004 , 04:53 AM
Registered User
Join Date: Apr 2003
Posts: 19

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");
}
};

# 2 08-05-2004 , 05:00 AM
dannyngan's Avatar
Registered User
Join Date: Dec 2002
Location: Seattle, WA
Posts: 1,154
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. user added image


Danny Ngan
Animator | Amaze Entertainment
my website | my blog | my job
# 3 08-05-2004 , 10:22 PM
Registered User
Join Date: Apr 2003
Posts: 19
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?

# 4 08-05-2004 , 10:29 PM
dannyngan's Avatar
Registered User
Join Date: Dec 2002
Location: Seattle, WA
Posts: 1,154
The For loops are declared incorrectly. Instead of commas (,) you should use semicolons (user added image 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
# 5 15-05-2004 , 03:08 AM
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 user added image

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads