View Full Version : Melscript help please

01 January 2007, 05:21 AM
Im suprised no love of melscript in a graphics forum?

Anyways hope someone can help me..

Im trying to get the user to input a float in the user infterface. Im haveing trouble getting
that value (from the user) so i can use it (example scale an object).

Here are some of the things Ive tried.

// this one you can see what im trying to do (but the string to float doesnt work)////////
string $Winname = `window -title "Creating Objects" -menuBar true -widthHeight 450 200`;

global float $fltX = 1.0;
string $myFloatFieldGrp = `floatFieldGrp -label "X"`;
floatFieldGrp -q -value $myFloatFieldGrp;

$fltX = $myFloatFieldGrp;
button -label "Set Scale" -command "scale -r $fltX 1 1";
showWindow $Winname;

// a few more try's////////////////

global float $fltX;

$fltX = `floatFieldGrp -label "X" -value1 test`; // <- problem child
// i have also tried getting the value from "test"
// i guessing floatFieldGrp only returns boolean

button -label "Set Scale" -command "scale -r $fltX 1 1";

// here is another i tried
floatFieldGrp -label "X" -value1 1.1 test;

float $test = `floatfieldGrp -q -float float(test)`;

// and another trial

string $myFloatFieldGrp = `floatFieldGrp -label "mudda"`;

floatFieldGrp -q -value $myFloatFieldGrp;


$fltX = float($myFloatFieldGrp);

01 January 2007, 10:17 PM

I think you have more chances to receive an answer in the Maya MEL ( sub-forum.

01 January 2007, 02:30 AM
You're not querying the floatFieldGrp result correctly. Well, you are, but in query mode, floatFieldGrp returns the value of the float field. It doesn't pass it into the variable you supply as the argument, as you seem to be assuming in some of your examples. For instance, in your last example, when you do this:
$fltX = float($myFloatFieldGrp);
What you're really doing is converting the name of your floatFieldGrp to a floating point value, which really doesn't make sense.

Also, be careful with the return type when querying the value of a floatFieldGrp, because it is an array, and as such must be passed into a float array.

string $myWindow = `window -title "test"`;


string $myFloatFieldGrp = `floatFieldGrp -label "myfloat"`;

showWindow $myWindow;

float $queriedValue[] = `floatFieldGrp -q -value $myFloatFieldGrp`;

print $queriedValue[0];

The exception to this is if the separate values within the floatFieldGrp are queried directly, in which case the return type is just a float, not an array. So, you can do this instead:

float $queriedVal = `floatFieldGrp -q -value1 $myFloatFieldGrp`;

The points to take away from this is that, when in query mode, a 'field' command returns the queried value - which is different than passing a value into a command. So, you store that queried value in a variable. The string argument $myFloatFieldGrp passes the name of the floatFieldGrp into the expression. So it's just like using explicitly named controllers in the following fashion:

floatFieldGrp -label "myFloat" -name "floatFieldGrpExample";

float $queriedValues[] = `floatFieldGrp -q -value floatFieldGrpExample`;

CGTalk Moderation
01 January 2007, 02:30 AM
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.