Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / Query text field for selection?
  RSS 2.0 ATOM  

Query text field for selection?
Rate this thread
 
55339
 
Permlink of this thread  
avatar
  • johnnyz
  • Posted: 04 May 2011 05:08 AM
  • Location: Minneapolis,MN
  • Total Posts: 81
  • Joined: 12 July 2007 05:46 PM

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!



Replies: 0
avatar

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


Replies: 0
avatar
  • johnnyz
  • Posted: 12 May 2011 04:40 AM

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


Replies: 0