My Mel Script

Untitled-1

script overview

I made a script called “Poses Script”. It assigns different poses to a certain rig, the Terry rig. The script creates a window with a coloured button for each pose. Each button has an icon or a picture of the pose on it. When a button is clicked the Terry rig assumes the pose that is assigned to that button.

I decided to make this script because I like animating and I think it would be very useful to have a script that puts a model in certain key poses at the click of a button.

I listed the steps I thought I would need to take to develop my script-

Make a skeleton
Move it into poses required
Note the orientation values of the joints 
Make a window with buttons 
Make the buttons apply the attributes of the joints of the original skeleton poses to the selected skeleton joints.
 

These are the script goals I thought I would need to achieve in the making of the poses window-

Create procedures or procs for each pose 
Create a window, checking if it exists already and deleting it if it does
Have a button for each pose
Make each button a different colour
Assign an icon of the pose to the buttons as well
Assign a proc to each button starting with reset which tells each joint to assume the values set in the procs
 

Top Down Development Process

In making my mel script I followed these steps

  • 1st I came up with the idea for a script. After a few thoughts like a body deforming automatically on impact rather than bouncing like hard plastic. I then thought of a window with buttons that put a rig in certain poses would be useful for animating which is the part of 3D that I like to do
  • then I put into words the steps that I should take in order as in the first part above
  • Then I started the scripting part- I experimented with creating windows finally choosing a lay out and buttons I like then I started on the serious business of how to script my idea
  • I made a global proc called resetAll to be able to set the base pose with all controls set to 0.
  • I used the xform command to command the script to set transformation values on chosen joints. The Mel command documentation describes the xform command as “This command can be used to query/set any element in a transformation node.”
  • I put the Terry rig into different poses and noted the rotation and translation values of the controls.
  • I rendered each pose with a ratio of 64 x 64 so it would be small for the icons.
  • I saved each pose render as a PNG  in the computer’s documents file under maya, 2014-x64, prefs, icons. I chose PNG because it has an alpha channel and it would leave the background transparent to allow the colour of my buttons to show.
  • Then I made global procs for every pose listing all the translation and rotation values with the xform command. I put the reseAll at the start of each one. This was to zero everything first so that the poses weren’t just going on top of the others.
  • Then I wrote the part of the script for creating the window and the buttons
  • I made an if statement that finds if the window, myWindow, already exists and if it does to delete it
  • I then created a window titled poses and listed the dimensions and named it myWindow
  • I listed the grid layout with the number of columns and dimensions of each cell
  • then I created the buttons
  • gave them a colour using bgc then 3 numbers for red, green and blue values
  • told it which image to use as an icon
  • told it which proc to use
  • at the end I commanded it to show myWindow.
  • now I have a window with coloured buttons which put Terry into a pose when I click on one

 

reflection of script development

In this subject I started as a complete newbie knowing absolutely nothing about scripting. I felt overwhelmed because it is a foreign language and every word used has to be the correct one, spelt right and in the right place, not to mention all the new things like ` ++  and arrays, loops, matrices, ‘if’ statements and procs etc etc etc.

I started reading the text books and found that very helpful along with the notes given in the N drive for each week. I have seen Vince write scripts to assign different colours to a group of many grapes and to change a setting on all things in a scene at once and this impressed me as to the usefulness of scriptingt. I saw Emeliano use command documentation to see how to utilise commands and this influenced me to do the same. This came in useful for seeing how to use xform.

We looked at how Maya works and uses mel scripts “Maya’s user interface, which includes all buttons and menus around the edge of the work area, is built using MEL.” (Mark R. Wilkins, 2005) page 20

Then over the weeks we made things like windows with buttons that do things like turn a propeller or make, move and delete poly objects. We made a global proc to list selected objects and rename them. We discovered switch statements, the switch statement is designed for the situation where you have a single variable that can have several specific values for which you want your script to do different things, and recursion which is when you have a procedure that calls itself repeatedly and made a spiral of spheres of decreasing sizes using this. Then we learnt about loops,  a loop is a series of instructions that repeat until set conditions are reached. “Conditional statements let us decide whether to do something; loops let us do things many times.” (Jennifer Campbell, 2009) p131

Then we had to come up with an idea for a script, something we would like to be done in Maya. A first I thought of having a body deform automatically in a collision, but this seemed a bit too much for my level so Emeliano and I came up with this idea for poses in animating.

In making my mel script I followed the steps listed above and am delighted with the resulting window and they way it makes the Terry rig assume the poses.

Based on what I have learnt in this subject and the influences of my teachers and the writers of the text books I can imagine using scripting in future to simplify and automate things that I want Maya to do. I imagine I would use it in a similar way in animating even to use the xform command and list command to find and list the values of the original joints automatically and even assign it to any number of rigs by assigning variables to the subsequent rigs joint names.

Bibliography

Jennifer Campbell, P. G. J.   M. G. W., 2009. Practical Programming – An Introduction to Computer   Science. Raleigh: Pragmatic Bookshelf.

Mark R. Wilkins, C. K., 2005. MEL Scripting for   Maya Animators. 2nd ed. San Francisco: Elsevier.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s