textScrollList problems

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  05 May 2008
textScrollList problems

I'm trying to create a rig that would be attached to each character. The rig includes a rim light for the eyes and 2 rim lights for the character. I have a nurbs control that can adjust the light attributes and the rotation of the lights. But I would like the rims to be able to find the camera and adjust accordingly.

Below is the script I'm working on for GUI that would allow the user to select a camera from the list and click the button that would select that camera and select the group (2 character rim lights) and aim constrain. I can't get the button to select the camera that would be within the $camSel string.



// Delete Window
if (`window -exists camsListRimAimWindow`) {
deleteUI camsListRimAimWindow;
}
// Window for Camera List
string $camsList[];
string $camSel[];
$camsList = `ls -type camera`;
string $camsListWindow = `window
-title "Camera List Rim Aim Window"
-wh 300 250
camsListRimAimWindow`;
paneLayout -configuration "vertical2";

textScrollList -numberOfRows 8 -allowMultiSelection false
-append $camsList[1] -append $camsList[2] -append $camsList[3]
-append $camsList[4] -append $camsList[5] -append $camsList[6]
-append $camsList[7] -append $camsList[8] -append $camsList[9]
-append $camsList[10] -append $camsList[11] -append $camsList[12]
-append $camsList[13] -append $camsList[14] -append $camsList[15]
"list";
$camSel = `textScrollList -q -si list`;
button -label "Aim Character Rim Lights" -command "select -r $camSel; " ;
showWindow $camsListWindow;



Thanks for any help,
Jason
 
  05 May 2008
Hi Jason,

It;s not picking up the query to the textScrollList becasue you are trying to return whats selected before the user gets a chance to select anything in it..

I've put the selection into a procedure that is called by the button press which then queries the textScrollList...

// Delete Window
   if (`window -exists camsListRimAimWindow`) {
   deleteUI camsListRimAimWindow;
   }
   // Window for Camera List
   string $camsList[];
   string $camSel[];
   $camsList = `ls -type camera`;
   string $camsListWindow = `window
   -title "Camera List Rim Aim Window"
   -wh 300 250
   camsListRimAimWindow`;
   paneLayout -configuration "vertical2";
   
   textScrollList -numberOfRows 8 -allowMultiSelection false
   -append $camsList[1] -append $camsList[2] -append $camsList[3]
   -append $camsList[4] -append $camsList[5] -append $camsList[6]
   -append $camsList[7] -append $camsList[8] -append $camsList[9]
   -append $camsList[10] -append $camsList[11] -append $camsList[12]
   -append $camsList[13] -append $camsList[14] -append $camsList[15]
   list;
   
   //$camSel = `textScrollList -q -si list`;
   
   button -label "Aim Character Rim Lights" -command "buttonAction()" ;
   showWindow $camsListWindow;
   
   global proc buttonAction() {
   	string $camSelect[] = ` textScrollList -q -si list`;
   
   	select -r $camSelect;
   
   }


Cool?

-a


EDIT:

Or.... you could simply put the select and query command directly in to the button command. as in,

button -label "Aim Character Rim Lights" -command "select -r ` textScrollList -q -si list`" ;
  

and blow away the extra procedure all together.
__________________
i dOnt sUffEr fROm inSanIty. I EnJoy eVeRY miNuTe oF iT.

Last edited by digitalandrew : 05 May 2008 at 04:13 PM.
 
  05 May 2008
Thanks digitalandrew, that worked!

I tried to go back in and add a textField and a button that queries what was entered into the textField and that would be the characters name(prefix). Then the rest of the procedures would use the character's name(prefix) + the rest of the information. I keep getting $nameEntry is an undeclared variable, but I can't figure out where to put the declaration? Or is there a different problem in the script?

Thanks,
Jason


//
// Start
//
// Delete Window
if (`window -exists camsListRimAimWindow`) {
deleteUI camsListRimAimWindow;
}
//
// Create window
string $camsList[];
string $camSel[];
$camsList = `ls -type camera`;
string $camsListWindow = `window
-title "Character Rim Light Aimer"
camsListRimAimWindow`;
//
// Layout
columnLayout -columnAttach "both" 5 -rowSpacing 10 -columnWidth 250;
textField -tx "name" charName;
button -label "Prefix Name" -command "charNameEntry()" ;
textScrollList -numberOfRows 8 -allowMultiSelection false
-append $camsList[1] -append $camsList[2] -append $camsList[3]
-append $camsList[4] -append $camsList[5] -append $camsList[6]
-append $camsList[7] -append $camsList[8] -append $camsList[9]
-si "perspShape"
"list";
button -label "Create" -command "createConnection()" ;
button -label "Delete" -command "deleteConnection()" ;
showWindow $camsListWindow;
//
// Procedures
global proc charNameEntry() {
string $nameEntry = `textField -q -t charName`;
}

global proc createConnection() {

if (` objExists ($nameEntry + "_grp_lights_charRims_aimConstraint1")`) {
delete ($nameEntry + "_grp_lights_charRims_aimConstraint1");
}
string $camSelect[] = ` textScrollList -q -si list`;
setAttr ($nameEntry + "_grp_lights_charRims" + ".rx") 0; setAttr ($nameEntry + "_grp_lights_charRims" + ".ry") 0; setAttr ($nameEntry + "_grp_lights_charRims" + ".rz") 0;
select -r $camSelect; pickWalk -d up; select -add ($nameEntry + "_grp_lights_charRims");
aimConstraint -offset 0 0 0 -weight 1 -aimVector 0 0 1 -upVector 0 1 0 -worldUpType "vector" -worldUpVector 0 1 0;
select -cl;
};

global proc deleteConnection() {

if (` objExists ($nameEntry + "_grp_lights_charRims_aimConstraint1"`) {
delete ($nameEntry + "_grp_lights_charRims_aimConstraint1");
setAttr ($nameEntry + "_grp_lights_charRims" + ".rx") 0; setAttr ($nameEntry + "_grp_lights_charRims" + ".ry") 0; setAttr ($nameEntry + "_grp_lights_charRims" + ".rz") 0;
}
};
//
// End
 
  05 May 2008
You're running into a scope problem. When you declare a variable inside a procedure, it only exists inside that procedure. The other procedures will never know about it.

You had $nameEntry declared inside one procedure, thus the other two procedures didn't know about it. What you have to do is declare them again inside the other procs.



 //
 // Start
 //
 // Delete Window
 if (`window -exists camsListRimAimWindow`) {
 	deleteUI camsListRimAimWindow;
 	}
 
 //
 // Create window
 string $camsList[];
 string $camSel[];
 $camsList = `ls -type camera`;
 string $camsListWindow = `window
 -title "Character Rim Light Aimer"
 camsListRimAimWindow`;
 
 //
 // Layout
 columnLayout 
 	-columnAttach "both" 5 
 	-rowSpacing 10 
 	-columnWidth 250
 	columnName;
 
 textField 
 	-tx "name" 
 	charName;
 
 button 
 	-label "Prefix Name" 
 	-command "charNameEntry()" 
 	prefix_button;
 
 textScrollList 
 	-numberOfRows 8 
 	-allowMultiSelection false
 	-append $camsList[1] -append $camsList[2] -append $camsList[3]
 	-append $camsList[4] -append $camsList[5] -append $camsList[6]
 	-append $camsList[7] -append $camsList[8] -append $camsList[9]
 	-si "perspShape"
 	"list";
 
 button 
 	-label "Create" 
 	-command "createConnection()" 
 	create_button;
 
 button 
 	-label "Delete" 
 	-command "deleteConnection()" 
 	delete_button;
 
 showWindow $camsListWindow;
 
 
 //
 // Procedures
 
 
 global proc createConnection() {
 	string $nameEntry = `textField -q -t charName`;
 	if (` objExists ($nameEntry + "_grp_lights_charRims_aimConstraint1")`) {
 		delete ($nameEntry + "_grp_lights_charRims_aimConstraint1");
 		}
 
 	string $camSelect[] = ` textScrollList -q -si list`;
 	setAttr ($nameEntry + "_grp_lights_charRims" + ".rx") 0; setAttr ($nameEntry + "_grp_lights_charRims" + ".ry") 0; setAttr ($nameEntry + "_grp_lights_charRims" + ".rz") 0;
 	select -r $camSelect; pickWalk -d up; select -add ($nameEntry + "_grp_lights_charRims");
 	aimConstraint -offset 0 0 0 -weight 1 -aimVector 0 0 1 -upVector 0 1 0 -worldUpType "vector" -worldUpVector 0 1 0;
 	select -cl;
 	}
 
 global proc deleteConnection() {
 	string $nameEntry = `textField -q -t charName`;
 	if (`objExists ($nameEntry + "_grp_lights_charRims_aimConstraint1")`) {
 		delete ($nameEntry + "_grp_lights_charRims_aimConstraint1");
 		setAttr ($nameEntry + "_grp_lights_charRims" + ".rx") 0; setAttr ($nameEntry + "_grp_lights_charRims" + ".ry") 0; setAttr ($nameEntry + "_grp_lights_charRims" + ".rz") 0;
 		}
 	}
 //
 // End
 
 
 
  05 May 2008
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



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
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 07:11 PM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.