PDA

View Full Version : newbie questions regarding MEL



RuiQi
10-05-2010, 09:12 AM
Hi forum , i have gone through Digital Tutor's Introduction to MEL and since I've had C++ and C training before, its quite easy for me to grasp the knowledge regarding MEL.
Before i proceed onto Python for MEL , there are certain doubts that i have and i hope the forum can enlighten me :)

Qn 1:
----------------------------------------------------------------
window -rtf true -title "Name " myWindow;
............
showWindow myWindow;

As taught in DT , this is the command that creates a window. I am confused at the purpose of "myWindow" .
Is there any other purpose to it other then to "showWindow myWindow" ?
-----------------------------------------------------------------

Qn 2: Lesson 10
-----------------------------------------------------------------
window -title "Name" -rtf true myControl;
rowLayout -nc 3;
button -label "Translate" -c "attrRemover t" myTransT;
button -label "Rotate" -c "attrRemover r" myTransR;
button -label "Scale" -c "attrRemover s" myTransS;
showWindow myControl;

proc attrRemover(string $myInput)
{
for($myNode in $mySelection)
setAttr -k false ($myNode + "." + $myInput + x);
setAttr -k false ($myNode + "." + $myInput + y);
setAttr -k false ($myNode + "." + $myInput + z);
}

What is the purpose of myTranstT ? From what i have tried , removing that from the code doesn't have any impact.
-----------------------------------------------------------------

Qn 3:
-----------------------------------------------------------------
Lastly , how i try to understand the program is by going through what are the INPUTS when the code is executed. However ..
string $mySelection[] = `ls -sl`
string $shads[] = `ls -mat`;

Exactly what are the inputs that go into $mySelection when this code is executed ? Just the "object" ITSELF if it is selected by the user ?
I have the same exact doubt for $shads[] ..
-----------------------------------------------------------------

I hope that wasn't too much questions from a MEL beginner :)
Please help me DT forumers :)

THNKR
10-05-2010, 11:42 AM
Qn 1:
----------------------------------------------------------------
window -rtf true -title "Name " myWindow;
............
showWindow myWindow;

As taught in DT , this is the command that creates a window. I am confused at the purpose of "myWindow" .
Is there any other purpose to it other then to "showWindow myWindow" ?



The window command returns a string; that is the name of the window. If you specify a name, that's the value it will return as well. If you don't, Maya will name the window, as in the example below:

string $win = `window`;
// Result: window1 //




Qn 2: Lesson 10
-----------------------------------------------------------------
window -title "Name" -rtf true myControl;
rowLayout -nc 3;
button -label "Translate" -c "attrRemover t" myTransT;
button -label "Rotate" -c "attrRemover r" myTransR;
button -label "Scale" -c "attrRemover s" myTransS;
showWindow myControl;

proc attrRemover(string $myInput)
{
for($myNode in $mySelection)
setAttr -k false ($myNode + "." + $myInput + x);
setAttr -k false ($myNode + "." + $myInput + y);
setAttr -k false ($myNode + "." + $myInput + z);
}

What is the purpose of myTranstT ? From what i have tried , removing that from the code doesn't have any impact.
-----------------------------------------------------------------



Same as above, it's good practice to keep track of te names of stuff that you create.



Qn 3:
-----------------------------------------------------------------
Lastly , how i try to understand the program is by going through what are the INPUTS when the code is executed. However ..
string $mySelection[] = `ls -sl`
string $shads[] = `ls -mat`;

Exactly what are the inputs that go into $mySelection when this code is executed ? Just the "object" ITSELF if it is selected by the user ?
I have the same exact doubt for $shads[] ..



The `` gives you the return value. ls -sl returns a string array with the names of all selected nodes, and that's what you assign to $mySelection[];

stwert
10-05-2010, 11:47 AM
Just to follow up on THNKR's answers, the purpose of having names for windows and buttons etc. is so that you can modify them, query them, basically have a way to access and change their information and attributes.

Qn3: ls = list; -sl = selected; -mat = material; so in other words, return a list of all selected objects, or in the second case, return a list of all materials. Since they're string arrays, they are names, not necessarily the nodes themselves, but obviously you use the names to access the attributes of the nodes. Hope that helps.