Oct 2009
1 / 4
Oct 2009
Nov 2009

Ok, so I'm totally a n00b at programming but I understand the basic concepts (more in python than mel). I'm trying to create a simple gui for the command line plugin m2mdd. However, there are several flags that are needed for the plugin to work in a way that's actually helpful. Some of those flags being -fps, (self explanatory), -sclm (scale) and -edirp (output dir).
What I'm trying to do is create a simple gui that allows me to type in the desired fps, output dir and scale and have it plug those values into the right flags.

I'm having 2 notable problems (Here's where the noobness comes in).

1) How do I grab the text that's typed into a textField and assign it to a variable?
2) How do I use that variable within the button -command function?

syntax aside, I THINK it would work something like this:

textField: "scale"
    [typed value]: ".01"
textField: "OutputDir"
    

$scale = scale.value
$outdir = OutputDir.value

button -command "m2mdd -edirp$outdir -sclm$scale"

resulting in the equivilent of typing "m2mdd-edirp C:/... -sclm .01" into the mel command line.

Clearly my syntax is all off but that's basically what I'm trying to get at.

Help please?

-David

  • created

    Oct '09
  • last reply

    Nov '09
  • 3

    replies

  • 3.5k

    views

  • 1

    user

Bump 
Nothing? This has to be one of the most basic functions of using a text field, SOMEBODY has to know how to get that data out?

look for the page entitled "Attaching commands to UI elements" in the Maya docs...some useful tips there for passing data into commands from UI elements.

To grab the text you can query the text value:
[example:]
 textField "myTextField" //the text field
    string $value = textField -q -text "myTextField"; //to query that text

(or alternatively store the name in a variable)

  string $tf = textField;
  string $value = textField -q -text $tf;


as for using the value I personally like to pass the textFields name to a simple proc and do the query and issue the command there. I feel it makes it a bit more readable. 
[Example]

proc myProc(string $textField){
    string $value = textField -q -text $textField;
        //command
    print $value;
}

string $win=  window;
string $layout = columnLayout;
    string $tf = textField;
    button -label "run" -c ("myProc($tf)");
showWindow $win;