MEL Scripting - basic input window

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
  01 January 2013
Question MEL Scripting - basic input window

With the recent purchase of Element 3D and its recent update to allow the importing of obj sequences, my team and I have been taking advantage of its ease of use. We've been using Peter Palmer's sequence exporting script to great success, but with the amount of exporting and re-exporting we've been doing, constantly typing the command into the editor has become tedious.

So I took a stab at MEL scripting. I have a decent knowledge of PHP and web-based scripting, but MEL is all so new and confusing. 3 hours of google searches later and varying degrees of hair pulling, I've been able to get a window up, sometimes, but never without error.

What I want is to click a shelf icon that prompts the user for a string 'name', a start frame integer, an end frame integer and a submit button that then feeds back into Palmer's script. For testing, I just set the inputs to echo back before shoehorning the export script into the mix. Could someone take a look at this and tell me why it tells me the variable isn't getting declared... when it obviously is?


if(`window -exists expWindow`){
deleteUI expWindow;
}

window -rtf true -title "Export OBJ Sequence" expWindow;

columnLayout;
intFieldGrp -label "Start Frame" sFrame;
intFieldGrp -label "EndFrame" eFrame;
$fName = `textFieldGrp -label "File Name"`;

button -c build -label "Export";
showWindow expWindow;


global proc build (){

int $sFrame = `intFieldGrp -query -value1 sFrame`;
int $eFrame = `intFieldGrp -query -value1 eFrame`;
print("Frame start= "+ $sFrame +" and Frame end="+ $eFrame + " and file name is " + $fName + "\n");

}


Much thanks
 
  01 January 2013
The variable needs to be explicitly declared global in both the main code and the procedure. This would explain why you are getting the error.

Also, if you want to get the filename you need to query the textFieldGrp with the -text flag. In it's current state you will only be printing out the name of the control.

if(`window -exists expWindow`){
    deleteUI expWindow;
}

window -rtf true -title "Export OBJ Sequence" expWindow;

columnLayout;
intFieldGrp -label "Start Frame" sFrame;
intFieldGrp -label "EndFrame" eFrame;

global string $fName;
$fName = `textFieldGrp -label "File Name"`;

button -c build -label "Export";
showWindow expWindow;


global proc build (){
    
    global string $fName;
    string $text = `textFieldGrp -q -text $fName`;
    
    int $sFrame = `intFieldGrp -query -value1 sFrame`;
    int $eFrame = `intFieldGrp -query -value1 eFrame`;
    print("Frame start= "+ $sFrame +" and Frame end="+ $eFrame + " and file name is " + $text + "\n");

}
 
  01 January 2013
My take on it was that you weren't querying the text field. For example this works :


if(`window -exists expWindow`){
deleteUI expWindow;
}

window -rtf true -title "Export OBJ Sequence" expWindow;

columnLayout;
intFieldGrp -label "Start Frame" sFrame;
intFieldGrp -label "EndFrame" eFrame;
textFieldGrp -label "File Name" nameInput;

button -c build -label "Export";
showWindow expWindow;


global proc build (){

int $sFrame = `intFieldGrp -query -value1 sFrame`;
int $eFrame = `intFieldGrp -query -value1 eFrame`;
string $fName = `textFieldGrp -query -tx nameInput`;
print("Frame start= "+ $sFrame +" and Frame end="+ $eFrame + " and file name is " + $fName + "\n");

}


Cheers,
Brian
 
  01 January 2013
Originally Posted by Horganovski: My take on it was that you weren't querying the text field. For example this works :


That was it. Thanks both for your help. I should have no trouble adding the original procedure in.
 
  01 January 2013
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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
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 11:15 PM.


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