PDA

View Full Version : Strange Errors


Apophis3d
02-07-2008, 11:59 PM
Well this is odd i am getting a syntax error after moving my script which is a work in progress. From a computer at my college to my computer at home. Both of which are running Maya2008.

Maybe I just need an extra set of eyes I might be overlooking something simple.

global proc lights(string $obj)
{
//Varables
string $sel[] = `ls -lt`;
int $num = `size($sel)`;

//creates circle
circle -normal 0 1 0 -name lightSwitch;

//Adds attribute
addAttr -ln "LightBrightness" -at double |lightSwitch;
setAttr -e-keyable true |lightSwitch.LightBrightness;

//locks out unused attributes
setAttr -lock true -keyable false "lightSwitch.sx";
setAttr -lock true -keyable false "lightSwitch.sy";
setAttr -lock true -keyable false "lightSwitch.sz";
setAttr -lock true -keyable false "lightSwitch.rx";
setAttr -lock true -keyable false "lightSwitch.ry";
setAttr -lock true -keyable false "lightSwitch.rz";

//selects lights
if ($num == 0);
error "Nothing selected";






}

Apophis3d
02-08-2008, 12:05 AM
oh the error it gives is Line2.7: Wrong number of arguments on call to lights

goleafsgo
02-08-2008, 12:46 AM
if ($num == 0); <- the semicolon finishes the statement so the next line, which is an error call, will always execute.

Just get rid of the ; and it should work.

Apophis3d
02-08-2008, 12:55 AM
did not work now it's telling me
// Error: line 2: Number of arguments on call to lights does not match number of parameters in procedure definition. //

goleafsgo
02-08-2008, 01:04 AM
Well that sounds like it's whoever is calling your proc is not passing it the object..what does the calling code look like?

Apophis3d
02-08-2008, 01:17 AM
Ok I just went and revised it and made it work right. However when I add the (string $obj) it messes up bigtime.

global proc lights(string $obj)
{
//Varables
string $sel[] = `ls -lt`;
int $num = `size($sel)`;

//creates circle
string $cir[] = `circle -normal 0 1 0 -name lightSwitch`;

//Adds attribute
string $cir[] = `addAttr -ln "LightBrightness" -at double |lightSwitch`;
string $cir[] = `setAttr -e-keyable true |lightSwitch.LightBrightness`;

//locks out unused attributes
string $cir[] = `setAttr -lock true -keyable false "lightSwitch.sx"`;
string $cir[] = `setAttr -lock true -keyable false "lightSwitch.sy"`;
string $cir[] = `setAttr -lock true -keyable false "lightSwitch.sz"`;
string $cir[] = `setAttr -lock true -keyable false "lightSwitch.rx"`;
string $cir[] = `setAttr -lock true -keyable false "lightSwitch.ry"`;
string $cir[] = `setAttr -lock true -keyable false "lightSwitch.rz"`;

//selects lights
if ($num == 0)
error "Nothing selected";






}


Here is what i am trying to do for my homework assignment

HOMEWORK

Create a MEL script which finds all of the lights in a scene, and creates a single control object that will drive all of the light intensities with a single custom attribute. Include an argument in your global procedure that allows the user to name the new controller object. Produce an error message if there are no lights in the scene.



I think I have to take that string OBJ and somehow make it control the name of the object that the script creates. The user is suposed to be able to name the circle. Right now I was bypassing it by using the -name LightSwitch.

CGTalk Moderation
02-08-2008, 01:17 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.