|
I’m trying to write a UI fora selection tool set and am stuck. In our pipeline all our rigs have the same name for controls ie: “rightElbowCtrl”. We reference our rigs into a new animation scene and add a unique namespace so now character one’s controller would be “Character1:rightElbowCtrl” and character 2 “Character2:rightElbowCtrl”
I would like to make a UI with a text field and a button. The button would select an object called “whateverITypeInTheField + rightElbowCtrl”
here’s what I have so far:
////////////////////////////////////////////
global proc selectTools(){
if (`window -ex selectTools`)
{
showWindow selectTools;
return;
}
window -title “Select Tools” selectTools;
rowColumnLayout -nc 2;
text “Namespace Prefix”;
global string $nameSpace = `textField -tx “Type Namespace Prefix Here” -ed 1`;
button -label “Select” -command “selectCtrls()”;
showWindow;
}
global proc getNamespace(){
string $getNamespace = `textField -q -tx $nameSpace`;
}
global proc selectCtrls(){
select ($getNamespace + “armCtrl");
}
//////////////////////////////
however, I get the error
// Error: “$getNamespace” is an undeclared variable.
I’ve clearly defined it earlier. I’ve tried making it a global string and it’s still not working. any help would be GREATLY appreciated.
Thanks!
|
|
|
|
You’re on the right track with making it global, since you’re trying to use the same variable across global procs it will have to be global. In the initial proc try declaring it first, then assigning. Then in the next proc you need to declare it before you can use it. So something like this should work:
global proc getNamespace(){ global string $nameSpace;
global string $getNamespace; $getNamespace = `textField -q -tx $nameSpace`; }
global proc selectCtrls(){ global string $getNamespace; select ($getNamespace + "armCtrl"); }
|
|
|
|
Thanks A TON!
here is what I ended up using to get it to work.
global proc selectTools(){
if (`window -ex selectTools`) {
showWindow selectTools;
return; }
window -title "Select Tools" selectTools; rowColumnLayout -nc 2; text "Namespace Prefix";
global string $nameSpace; $nameSpace = `textField -tx "Type Namespace Prefix Here" -ed 1`; button -label "Select" -command "selectCtrls()"; showWindow; } global proc getNamespace(){ global string $nameSpace;
global string $getNamespace; $getNamespace = `textField -q -tx $nameSpace`; }
global proc selectCtrls(){ global string $nameSpace;
global string $getNamespace; $getNamespace = `textField -q -tx $nameSpace`; select ($getNamespace + "armCtrl"); }
|
|
|