.comment-link {margin-left:.6em;}


Wednesday, August 16, 2006

Talk to Maya

WOW! This looks like it could be really interesting. I hope to try it tomorrow. It's a plug-in that allows you to issue commands to Maya via your microphone and voice recognition.

Tuesday, June 06, 2006

Batching in MEL

People speak of "batching" in Maya. All this means is let the computer do the repetitive work for you. For a specific example, lets say that half way through the animation phase, your art director decides the main character of your game really needs to have a green hat to "communicate the angst of the characters plight to the player better".

For each animation already complete, you'll need to import a hat model and then constrain it to the characters head. This is the boring monotonous part of production. Help MEL help you. Maya doesn't have a built in Batch function, but it is easy enough to quickly code something up.

This example will demonstate the code I like to use for simple batching. You can utilize these concepts to automate which ever tasks it is you'll need to perform to a list of files.

string $fullPathAndName = `fileDialog`;
string $sourcePath = dirname($fullPathAndName);
string $sourcePath = ($sourcePath + "/");
string $myFiles[] = `getFileList -fld $sourcePath -filespec "*.mb"`;
for ($eachFile in $myFiles)
//your tasks go here
print ("Done doing stuff for all the files in this directory " + "\"" + $sourcePath + "\"" + "!" + "\n");

Let's break that down into bit sized chucks of understanding ...

string $fullPathAndName = `fileDialog`;

The fileDialog command launches an 'Open' window. By selecting any file in that directory, the script will now know the network path AND filename of whatever file is chosen. Store that in the $fullPathAndName variable.

Next you need to get just the path to the file so you and MEL know what directory to work on. Luckily Maya has a built in dirname command. You provide the command a full path and filename string and it will automatically return just the directory path. Store that in the $sourcePath variable.

The one drawback to the dirname command is it doesn't include the trailing "/" at the end so you'll have to reassign the $sourcePath variable to include its current contents plus the trailing "/". This line string $sourcePath = ($sourcePath + "/"); does exactly that.

Now you know the directory to process. Next you'll tell Maya to look at all the files in that directory and store them in a list. string $myFiles[] = `getFileList -fld $sourcePath -filespec "*.mb"`; is the key here. The command getFileList does what it says, you're telling MEL where to get the files from by the -fld $sourcePath bit. I am sure you can guess that the -fld is short for folder. Use a string array called $myFiles[] or something similar to store the files.

At this point its just simple for loops and other custom code to do what you like to each file. In our example, you'd import the hat, return the character to the bind pose, constrain the hat to the head, and "be kind and rewind" the animation. Lastly, you can print out a report of what happened. If you use error checking properly, you can even note what files failed for whatever reason. More on error checking later as it deserves a post all it's own.

PS- I (Chad) have moved my blog over to here.

Wednesday, September 14, 2005

Sorry Bryan


Wednesday, September 07, 2005

Master Class Notes

If you were at the Motion Builder Master Class I (Chad) co-presented this year at siggraph and are missing the final notes, let me know by commenting and I'll see what I can do to get them to you.


Thursday, September 01, 2005

Workflow improvements: Connection Editor

I work with the connection editor almost continuously throughout the day and I got to thinking that it would save me a lot of time if the connection editor would just open up based on a selection with things already loaded. So here we go:

I decided that I would like it to load the first selection to the left side of the connection editor, as I always have it set to from -> to. Then anything else selected would open on the right side.

// SCRIPT: ijConnectionEditor
// AUTHOR: Ian Jones - mel@shrtcww.com
// DATE: September 1, 2005
// Version: 1.0
// DESCRIPTION: Opens the connection editor and loads left/right side based on
// a selection
// ASSUMPTIONS: Connection Editor is set to: from -> to
global proc ijConnectionEditor()
// Save the current selection/size
string $selection[] = `ls -sl`;
int $numSelections = `size($selection)`;


// If selection[0] exists: load to the left side of the CE
if ( $numSelections > 0 )nodeOutliner -e -replace ( $selection[0] ) connectWindow|tl|cwForm|connectWindowPane|leftSideCW;

// If selection[1] exists: load to the right side of the CE
if ( $numSelections > 1 ) nodeOutliner -e -replace ( $selection[1] ) connectWindow|tl|cwForm|connectWindowPane|rightSideCW;

// If more than 2 objects selected
// add additional to the right side.
if ( $numSelections > 1 )
for( $n=2; $n<($numSelections ); $n++ )
nodeOutliner -e -addObject $selection[( $n )] connectWindow|tl|cwForm|connectWindowPane|rightSideCW;

Already saving me a bunch of time. Hope you enjoy.

Monday, August 29, 2005

Batches? We DO need stinking batches

First off, thanks to Josh and Ian for the posts. We're running the gamut from workflow enhacements to full on UI creation. Booya.

I am tinkering with my next post, which I hope to have up by this weekend. I want to talk a bit about creating a batch script.

Do you have a lot of files that you need to alter in the same way? Do you wish that there was a way to automatically process all these files at once? Well batching is for you!

More soon.


Monday, August 22, 2005


Just a quickie... literally.

Here's something i have in my custom modeling marking menu that toggles on the quickdragselect option in the preferences. I don't *think* there's another way to turn it on and off quickly without going into the prefs, so this proves to be super handy when i'm manipulating verts. It's even better when you envoke the soft mod tool.

if (`selectPref -q -cld`)
selectPref -cld 0;
selectPref -cld 1;

For those that don't know what clickdragselect is, it basically lets you click and drag (with move, rotate, or scale), as opposed to clicking, letting go, then middle mouse dragging the selection.

Hmm.. can that code be even more simplified?