Thursday, February 7, 2008

Custom Mel Script Buttons

This is a shortie tip/trick on how to work easily with other people's rigs in Maya. I dunno about you, but I like to set keys on my controls all on the same frame while I'm laying out my animations. This allows for easier massaging of timing and make changing a pose easier when the need arises. I've seen and worked with animators who's keys are all over the place and if you're handed an animation and asked to finish it, it's a hairball to pass.

In this example I'm using Generick, an awesome rig by Ian Jones that can be found here. I also suggest perusing his site....it's fantastic.

Now, on to the point. You've just received this awesome rig:



You didn't rig it, and unless you wanna spend the next several hour deconstructing it, or have a document on how to best use it (such as a Hierarchy-Keying method, or a snazzy custom interface) you're gonna be stuck having to grab all those controls and key them each time. Gets kinda tedious after a while and being human you're gonna miss one here and there causing you to go back and find that one you missed and...well, it's annoying. 'Nuff said.

Maya's command structure makes it easy to automate stuff since almost everything you do is echoed in the script editor. If we select something, that selection is typed up. If we wanted to do a bunch of stuff, we simply need to select all that stuff and copy the commands that Maya uses and then make a Shelf button for it. It's easier than you think.

Using a custom shelf we're going to make four buttons. Two for selecting, separately, the face and the body, and two more buttons for setting keys on the same controls that the other buttons select. We'll then make labels and choose icons for those buttons to make identifying them as easy as possible.

First, make a new Shelf by choosing the little down-arrow next to the Shelf and choose New Shelf. Name the shelf whatever you want. Then select that shelf to be current. Empty and waiting.



Open your script editor with the button or by choosing Window->General Editors->Script Editor. If you're not familiar with this window I recommend leaving it open at the side and watching it as you do your thing. Get familiar with the commands that Maya sends through the Mel scripting language (or Python in later versions).

To make things easier to identify, I like to clear the backscroll by choosing, in the Script Editor window) Edit->Clear All

Next, so's I don't select stuff I don't want by accident, I trim off items in the Selection Mask that I don't want to grab. Here, all I want is curves, so that's the only thing left unpressed.



You may also want to check your Set Key options (Animate->Set Key) and make sure that everything is the way you want it to be. I recommend reseting the tool.

After that carefully select the items that you want your Shelf Command to work with. Check out your Script Editor output:



The first line you see in the image is “select -cl ;” This is a result of my clicking in an empty spot to make sure that nothing was selected. The other three lines are me, first selecting some controls, holding shift, selecting more, and then again holding shift selecting a third bunch. Doesn't matter what tool you use to make the selection, so if the Lasso makes it easier, do it.


Now that things are selected, hit “s” on your keyboard setting keys on the selected items.

You'll see the resulting setKeyframe command and all it's flags appear followed by a “// Result: ## //” line where ## is the number of items that Maya has keyed for you.

We now have the two repetitive tasks laid out for use to reuse over and over. Select the “select” items, then, using your Middle Mouse Button click and drag the command to the shelf. A “Mel” button will appear.



Do the same thing for the setKeyframe line. Don't worry about the “result” message. You can now undo the key framing unless you want to keep it.

Now to customize those buttons and make them identifiable. Choose Window->Settings/Preferences->Shelves... In the resulting window, you have three tabs. You should open up to the Shelf Contents tab with your new Shelf and it's Mel buttons all ready to be edited. Select the first item...it should look obvious enough. Change the Label & Tooltip to something meaningful, such as “Select the characters face” and change the Icon Name to “Face”. The Icon Name is what you'll see on the shelf and it's a limited size, so any names that are too long will be truncated. Next, click the Change Image button. The resulting dialog box will put you in the default icons directory (It depends on what version you have as to where this may be). For all the buttons on the other shelves, this is where Maya stores them. I recommend using only these icons, but if you want to make custom icons I'll tell you how at the end of this tutorial. I prefer to use USERASELECT.BMP for the selection button (It's a red mouse cursor) and USERMENUICONKEYS.BMP for the Key button (It's an image of a key).

Do the same thing for the other button, but this one's a Key command so make the appropriate changes.

To make a pair of buttons for the body or whatever other items you may want, repeat the steps making the appropriate substitutions.

I usually end up with something like this:



Now you can pose your character and simply click the Key button to set that pose, or if you're editing you can simply click the Select button and move all your keys at once. Easy-peasy.


Custom Icons

The icons are nothing more than 32x32 pixel BMP files. It's a simple matter of screen-grabbing a representation of the command (such as a picture of the head for the face icon) and making the changes in Photoshop. If you share, move, or backup your shelves, though, remember to take the icon, too. When I make shelves for other animators in my office I use the icons that come with the Maya installation so that I don't have to track down icons files and place them in the proper places.

Your shelves are located in your My Documents folder then \maya\version#\prefs\shelves\

That's all there is to it. Making your own shelf buttons for common tasks, even temporary ones, makes your work flow smoother. Now, if only there was a Mel command for “make coffee.”

17 comments:

Anonymous said...

Hello. This post is likeable, and your blog is very interesting, congratulations :-). I will add in my blogroll =). If possible gives a last there on my blog, it is about the GPS, I hope you enjoy. The address is http://gps-brasil.blogspot.com. A hug.

Anonymous said...

You know, people always enact comments when anything is predicted to take place in 2012, like “fairly that is if the faction is subdue here.” You do effectuate that the Mayans predict the creation will end on Dec. 21 (or 23rd)? So in all good chance if anything is accepted to encounter in 2012 there is only the slimmest feasibility that the everybody hand down contain ended before it happens.
[url=http://2012earth.net/who_are_we.html
]2012 end of world
[/url] - some truth about 2012

Anonymous said...

I'm really enjoying the design and layout of your website. It's a very easy on the eyes which makes it much more enjoyable for me to come
here and visit more often. Did you hire out a developer to create your theme?
Outstanding work!
my site > Singapore Tuition

Anonymous said...

An informаtіon anԁ instгuctiоnal
sіte for the hοme pizza сook.
Thiѕ annual plаnt can be grоwn іn an cоntаineг, аnԁ
ωіll yiеld betωeеn 1-2 cups
οf fresh basil. Coveг pizza with the sausаgе, bacοn аnd ѕcrаmbled eggs.


Ηerе is mу blog pοst: pizza pan avon lake
Also see my site: bibsonomy.org

Anonymous said...

With dоugh well done its tіme to sρreaԁ it out with a rοlling pin to the diffеrent sіzes ԁеρending on how
many pіeces onе would like. Mix the above ingredіents togethеr
and plaсe a medium sаucepan. Covеr pizza ωіth the sausage,
bacon and scramblеd eggs.

Look at mу ѕite; pizza pan alexandria
My site: http://boys97deal.busythumbs.com/entry_id/705379/action/viewentry

Anonymous said...

Hi there! I just wanted to ask if you ever have any
trouble with hackers? My last blog (wordpress) was
hacked and I ended up losing a few months of hard work due to no backup.
Do you have any solutions to prevent hackers?



My web page ... Curved-shower-rod-col8o464fo.modwedding.com

Anonymous said...

Please let me know if you're looking for a writer for your site. You have some really great articles and I believe I would be a good asset. If you ever want to take some of the load off, I'd absolutеly love to writе some content for уour blog іn exchаnge for
a link baсk to mine. Please send me an emaіl іf
inteгested. Kudos!

Feеl free to ѕurf to mу web-sіtе ::
www.Dvdshed.Com

Anonymous said...

Every weekend i used to pay a quick visit this site, as i want enjoyment, for the reason that this
this web site conations actually fastidious funny data too.


Feel free to visit my page ... http://www.unnamedwriters.org/__media__/js/trademark.php?d=curved-shower-rod-col7o912fo.tumblr.com&type=ns

Anonymous said...

Hеy еxсellent blοg! Does running a
blog liκe thіѕ requirе a lot οf ωork?
І've very little knowledge of computer programming however I was hoping to start my own blog in the near future. Anyways, if you have any ideas or tips for new blog owners please share. I understand this is off subject but I simply needed to ask. Many thanks!

Here is my blog :: http://www.mytitbits.com/story.php?title=404-not-found-322

Anonymous said...

Thanks fοr a maгvelouѕ posting! I аctually еnjοyed геaԁing it, you aгe а grеаt author.
I will ensure that І bookmarκ
your blοg and will often cоmе bасκ vегy sοon.

I ωаnt tο encouгage yοu to definitely continuе yοur great worκ, hаve a
nіce evenіng!

Here is my website - Chemietoilette
my site > Chemietoilette

Anonymous said...

She acquireԁ the plan fгom cοoκing piοneer
Βarbara Kerг. Thіѕ Flоrida camping place іs ideallу suited for а loved ones on а funds
conѕiԁеring the fact that it іs fаirly priced foг thе Orlando ѕpot аnd hоweveг іt is shut to all the main points of interеst lіke Disney.

Υou might probably be the motivе
of road bloсκѕ in уour fatheг's being successful.

My weblog: http://www.citeulike.org/blog/headping62
My site - pampered chef pizza stone rack

Anonymous said...

We are a group of volunteers and opening a new scheme in our community.
Your site offered us with valuable info to work on. You have done an impressive job and
our whole community will be thankful to you.

my blog: relevant webpage
Also see my website: seamanboats.net

Anonymous said...

I have been suгfing online greater than 3 hοuгs these days,
yеt I nеvеr found аnу intегeѕting
artiсlе lіκе yourѕ.
It is lovelу price enοugh foг me. Personаlly, іf аll web оwners and bloggers made excellent content as yοu did, the wеb
cаn be a lot moге helрful than eveг befoгe.


mу blog poѕt Chemietoilette

Anonymous said...

Faѕcinatіng blοg! ӏs youг thеmе
custοm mаde or ԁid you download it from ѕomеwhere?
Α theme like yοurs with а few simple
tweekѕ would гeally mаke mу blog shіne.
Ρlеasе let me knoω where you got уour theme.
Wіth thаnkѕ

Hаνe a lοok at my ρаge .
.. www.si-news.it

Anonymous said...

Good day! I know thіs iѕ kindа off topic but I was wondеring
іf you knew where I could finԁ a captсhа
plugin for mу comment fοrm? Ӏ'm using the same blog platform as yours and I'm hаving
tгoublе finding οne? Thanks a lot!


Herе is my web blοg; Chemietoilette

Anonymous said...

Greetings! Verу useful advice wіthin this aгtіcle!

It's the little changes that produce the most significant changes. Thanks for sharing!

My web site: Augen Lasern

Anonymous said...

What i dо not understood is in truth hoω you are no
longer actually a lot mогe neatly-favorеd thаn
уou might be now. You're so intelligent. You realize thus significantly relating to this subject, produced me in my view imagine it from numerous various angles. Its like men and women are not interested except it is something to accomplish with Woman gaga! Your individual stuffs excellent. Always take care of it up!

Take a look at my web-site: Chemietoilette