Thanks for telling me this with 6 months 'til graduation, folks! I've been cramming for a while and though I'm still intimidated by MEL, I don't hide in a corner and quiver with fear when I come face to face with it. At least not all the time.
Anyway, I was watching a rigging tutorial and the guy made a Renaming Script. I thought it was pretty nifty, but I could never remember what order he selected things in and so I'd make a mistake and rename things in the wrong order. I thought to myself, "Self, why don't you just make a renaming script where all the fields are labeled 'rename ___ to:'?" Plus, I wanted to see if I could do it on my own, without looking at the tutorial again.
So, after a lot of trial and error (and help from a guy on CGTalk) I did. Yay!
Behold, my first MEL Script!
-----
//Renaming Script
//Creates a window
string $RenameWindow = `window -widthHeight 450 200 -rtf true -title "Rename Selected Objects"`;
//Makes the window able to scroll
scrollLayout
-horizontalScrollBarThickness 16
-verticalScrollBarThickness 16;
//Makes the window a row column layout
rowColumnLayout
-numberOfColumns 2 -columnAttach 1 "right" 0
-columnWidth 1 150 -columnWidth 2 250;
//Queries selections
string $sel[] = `ls -sl`;
//For loop - so we can access and apply the command to each selected object individually
for ($each in $sel) {
//Name Field Label - Acquires and lists the original name of the selected objects
text -label ("Rename " + $each + " to:");
//Renaming Field - Allow the selected object to be renamed
nameField -o $each;
}
//Button on the window for closing the Renaming Window
button -l "RENAME!" -c "deleteUI -window $RenameWindow";
//This shows the Renaming Window
showWindow $RenameWindow;
-----
Have I done something that hasn't already been done 530950394208539 times before? Nope. But I did it, and I understand what it does and I can recreate it if I need to. That's the fun thing ^^;
~Melissa
No comments:
Post a Comment