PDA

View Full Version : VERY simple MEL noob question


JimmyMarshall
10-12-2010, 09:26 PM
I'm trying to get back into using MEL after having taken a course of it in school. I've forgotten tons.

All I'm trying to do here is create a script that creates a DisplayLayer and has a txt field pop up to allow me to name it, and then add my selected objects into it.

window -title "Enter Layer Name";
columnLayout -adjustableColumn true;
text -label "Name";
string $layername = `textField`;
button -l "Create and Add to Layer"
-c "createDisplayLayer -name ($layername) -number 1 -empty;";
showWindow;

This is not quite working. For $layername it keeps giving me window1|columnLayout2|textField6 which I assume the name of the text field, not what's IN the text field. I thought using -q would do it but then it gives me // Error: No object name specified. //

I've forgotten how to do this. Help would be appreciated!

NaughtyNathan
10-12-2010, 10:27 PM
the return value of a control (what you are getting when you put it in ``) is the controls name, not its value. If you want the value of a textField you have to QUERY it, e.g:

string $inputText = `textField -q -text fieldControlName`;
however, take a look at the promptDialog MEL command. it does all this in a single neat command, and I'm sure the example code on the command docs is for something exactly like this!

:nathaN

JimmyMarshall
10-12-2010, 10:39 PM
I've got further questions as well if anyone would be kind enough to help. I'm also trying to create a script to:

1. Create a surface shader (Got this part)
2. Attach a mib_amb_occlusion mental ray node to the shader (I can attach it but I can't figure out how to CREATE it in the first place to it can be attached)
3. Put this material onto the selected object (Got this part too)
4. Call the Batch Bake (mental ray) window up for an ambient occlusion texture bake. (Can't figure this out either. Is there a MEL command to call it up or is this a strictly mental ray thing that MEL can't affect?)

JimmyMarshall
10-12-2010, 10:41 PM
the return value of a control (what you are getting when you put it in ``) is the controls name, not its value. If you want the value of a textField you have to QUERY it, e.g:

string $inputText = `textField -q -text fieldControlName`;
however, take a look at the promptDialog MEL command. it does all this in a single neat command, and I'm sure the example code on the command docs is for something exactly like this!

:nathaN

Aha! That did it alright. I'd forgotten all about the prompt dialog. I'll use that instead since I still couldn't get the textfield to work with a query. It kept saying it couldn't find fieldcontrolname.

Thank you very much.

Kobes
10-13-2010, 09:04 AM
Here are the commands that worked for me Jim

// create a mib_amb_occlusion node
mrCreateCustomNode -asTexture "" mib_amb_occlusion;
// open the batch bake(mr) option box
mrBakeToTexture true;


I came to these simply by turning on "echo all commands" in the script editor and going through the steps.

Kobes

JimmyMarshall
10-13-2010, 05:14 PM
Here are the commands that worked for me Jim

// create a mib_amb_occlusion node
mrCreateCustomNode -asTexture "" mib_amb_occlusion;
// open the batch bake(mr) option box
mrBakeToTexture true;


I came to these simply by turning on "echo all commands" in the script editor and going through the steps.

Kobes

My goodness you're right. I was wondering why they weren't showing up and had forgotten about the echo all commands thing. Thanks for the help!

CGTalk Moderation
10-13-2010, 05:14 PM
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.