PDA

View Full Version : command flag problems


Zodrac
10-17-2005, 11:45 PM
I'm having a problem with the -changeCommand flag on a checkbox.

What i'm trying to accomplish is a checkbox which runs a proc but also sends along an array when it's status is changed.

But i keep getting this error message.

// Error: RayTraceCheck($lightList); //
// Error: Line 1.25: "$lightList" is an undeclared variable. //

but i know the $lightList variable is declared it's just when the -changeCommand flag tries to use the variable it doesn't work.

The code below is just outtakes of the whole script so don't worry about anything else but the -changeCommand part. Unless you know a better way to do what i'm trying to accomplish.

I would appreciate any help.

//Zodrac

global proc Ambient_RayShadow_Controls(string $lightList[])
{
//-=Creates the use raytrace shadow checkbox=-
//**************************************************************************************************
string $RayShadow_Checkbox = `checkBox -label "Use Ray Trace Shadows"
-align "left"
-changeCommand "RayTraceCheck($lightList);"
-parent Ambient_RayShadow_Form`;
//**************************************************************************************************

//-=Positions all controls=-
//**************************************************************************************************
formLayout -edit
-attachForm $RayShadow_Checkbox "top" 10
-attachForm $RayShadow_Checkbox "left" 96
Ambient_RayShadow_Form;
//**************************************************************************************************
}

global proc RayTraceCheck(string $lightList[])
{
........
}

Robert Bateman
10-18-2005, 11:27 AM
Yeah, when the callback gets called, $lightList is no longer defined - it's only within the function Ambient_RayShadow_Controls. You can hack it to provide all of the arguments to the function within the mel, or find somewhere else to store those items (i'd suggest looking at the sets command to make the array into a set, eg "myLightListSet". This will allow your callback to easily access hat list of lights.

global proc Ambient_RayShadow_Controls(string $lightList[])
{
string $command = "{\nstring $HackItems[]={";
int $first=0;
for( $light in $lightList ) {
// ignore comma first time round
if($first==0) $first=1;
else
$command = $command + ",";

$command = $command + "\"" + $light + "\"";
}
$command = $command + "};\nRayTraceCheck( $HackItems );\n}";

// might want to print $command here to see what has happened....

string $RayShadow_Checkbox = `checkBox -label "Use Ray Trace Shadows"
-align "left"
-changeCommand $command
-parent Ambient_RayShadow_Form`;

//-=Positions all controls=-
//**************************************************************************************************
formLayout -edit
-attachForm $RayShadow_Checkbox "top" 10
-attachForm $RayShadow_Checkbox "left" 96
Ambient_RayShadow_Form;
//**************************************************************************************************
}

global proc RayTraceCheck(string $lightList[])
{
........
}

CGTalk Moderation
10-18-2005, 11:27 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.