Mel passing textFieldGrp text to proc

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
Old 04 April 2013   #1
Mel passing textFieldGrp text to proc

Hey guys and gals,

I am wrote a script that creates a hirarch of groups and want to add a UI that lets the user enter a name for the groups. I don't understand how to geht the test out of my textfield though. The name of the thextfield is passed on the the second procedure correctly but i allway get an error. I am sure the solution is quite simple, I can't figure it out myself though. I'd appreciate if someone coule help me.



global proc jl_groupHirarchyUi ()
{
//create window
$win = "jl_groupHirarchyUI";
if (`window -exists $win`)
deleteUI $win;
window -title "Named Group Hirarchy" $win;
columnLayout -adj true;
//save name of textfield to variable
$textFieldName = `textFieldGrp -l "Character Name:" -text "Editable"`;

//create button with function
$button = `button -l "Go" -c ("checkText\" "+$textFieldName+"\"")`;

showWindow $win;
}


global proc checkText (string $cN)
{
// get the results
string $charName;
print ("\n$cN is: " + $cN + "\n");
$charName = `textFieldGrp -q -tx $cN`;

//execute procedure that creates group hirarchy
$cmd = ("jl_groupHirarchy");
evalEcho $cmd;

}
 
Old 04 April 2013   #2
There is a little error in line 13. It would also be better to get used to declare variables specifying their types.
 
Old 04 April 2013   #3
Thanks zaskar,

I got most of the code from ohter scripts.I'm guessing ("checkText\" "+$textFieldName+"\"")`; ist the part that has the error in it but I honestly don't understand that part at all.
 
Old 04 April 2013   #4
What makes me wonder the most is the fact that the script works. even when I hit the button it prints out the correct name of the thextfield I am tryint to read. I just get // Error: file: C:/Users/.../Documents/maya/2012-x64/prefs/scripts/jl_groupHirarchyUi.mel line 34: Object ' jl_groupHirarchyUI|columnLayout3|textFieldGrp3' not found. / as an error.
 
Old 04 April 2013   #5
That part is simply a procedure call:
checkText "controlFieldName"

but having the control field name inside a string and to hand it over as argument, the procedure call itself has to be a string and it gets:
("checkText \"" + $controlField + "\"");

although if maya knows that the procedure "checkText" receives a string you wouldnt need such a stunt and you can omit the quotation marks:
("checkText " + $controlField);

As you see if you want to put quotation marks into a string you need to use a backslash
string $str = "\"";


now find the error
 
Old 04 April 2013   #6
I kinda get it but not really . It's working though. THX zaskar.
 
Old 04 April 2013   #7
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.
 
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 05:17 AM.


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