My Mel Script


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.


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.

dynamics homework week 6- walking on rock, sand and mud

These are the steps I did to make 1 surface react like rock, sand then mud as a guy walked over them:

  • select ground, soft/rigid bodies tab, create soft body options, duplicate make copy soft, create.
  • with the timeline at the beginning select the particles, then soft/rigid bodies tab, create springs.
  • I copied the guy with duplicate special and duplicate input graph ticked and deleted all but the feet and made these collide with the ground then hid them at the end.
  • created clusters to move vertices on the feet up that were going under the ground and causing points of the ground to drag up.
  • set conserve on the particles shape node to 0 to stop the momentum or the continuing movement after the feet have passed on.
  • oversamples, which is in solvers tab, set to 4 for more accurate simulation
  • created selection sets for rock, sand and mud particles.Changed the goal per pp in the component editor for each surface- rock to 1, sand to .2, mud to 0, which makes the deformation occur or not and to varying degrees.  Put the goal weight on the particle shape node to 1 so that it multiplies by these new settings.
  • (Originally I tried to achieve different surface attributes by seperating the 3 parts of the ground geo but rereading Chris’s notes reminded me about the above method).
  • set keys to animate the conserve on the particles to change for the different surfaces as he walks over them- 0 for the rock and sand and .8 for the mud so that it will slowly move back after being disturbed
  • and here are renders of the footprints on the surface types which I have coloured with a ramp



settings on the particle shape nodeImage

different particles goal pp settings in the component editor for each surface type

  • here it is

dynamics homework week 3- biplanes

I had to make a scene of a mass biplanes flying.

I made a volume emitter into a flattish rectangle, with rate of 2 per second ( this was a good amount of planes flying by) and instanced the biplane to the particles so the particles now look like the biplane. The biplanes emitted sideways so I rotated the original -90 in Y direction so that it points in the X direction and they came out straight. I had to break the connection of the rotate X on the prop to rotate the plane group and freeze the transformations so then I reanimated it to rotate after. 

planes emitting sideways (the original and the rectangle can be seen underneath):


I had the speed random too high on the emitter and some were not even moving. I noticed that they flew out at an ok speed but slowed down and I could not alter the emission speed so I put in a gravity field and made it go in the X direction at a strength of 6. I tried varying strengths and this had them flying at a good speed.

the emitter settings:biplane1

The particles have conserve weight of.98, max count -1 so there is no limit on the number of planes.

particle settings:


I tried an expression in the position’ attribute as below but the movements were too uniform they all went up and down at the same time.

vector $pos = particleShape2.position;

particleShape2.position = <<$pos.x, $pos.y+sin(time)/2, $pos.z>>;

A much better way to get them to move randomly was a turbulence field set at about 5. Higher values had them rotating too wildly and at a higher gravity magnitude it was really wild, there would have been far too many crashes.

turbulence field settings:biplane4

Aim direction set to velocity has them facing the way they are flying and turning.

instancer particle settings (note aim direction):biplane3

At the end I replaced the gravity field with a uniform field to see if that was better. I liked the effect, it pulled them forward and seemed to stop them wobbling so much. I set it at a magnitude of 20 and they speed up a bit as they go further. I also upped the disturbance to 10 so you can see more variation in the way they go up and down, the uniform field coped better with this than the gravity field and it wasn’t so wobbly.

uniform field settings:


I finally changed the lifespan on the particle to 6 and they die just off screen so there aren’t too many where they can’t be seen. and hid the original geo.


I put an expression in the mass attribute to vary the particles weights between .8 and 1.2 and in a uniform field this will vary their speed and I increased emission rate to 4 from 2 so there are more planes.