Maya Scripts

Scripts for Maya written in MEL and Python

Home Games Software In Your Browser Animation Tutorials Miscellaneous
Here are a bunch of Maya scripts that I wrote that I am releasing to the public. They are confirmed to work in Maya 2016 or later. If you find issues with any of the scripts, tweet the issue at me (@ravbug).

N-Gon detector for Maya

- Language: MEL

This simple program scans any polygonal object and finds any N-Gons. An N-gon is a polygon face that has more than 4 vertices (or 3 if your program doesn't accept quads). To use, select any object or set of objects, launch the script, and press Run. You have the option of having the program consider quads or tris (or both) to be N-Gons. The program will select all the N-Gons and report how many it found. With the N-Gons selected, you can delete them, or assign them a material, etc.

Main Window

 Polygon cube with N-Gons highlighted

Download N-Gon detector

Hidden Object Locator

Language: Python

This program analyzes the camera view and animation and finds objects that are always outside the camera's view. It can also find objects that are always obscured by other objects. It selects these objects, so you can delete them, put them on a display layer, etc. To use, Go into a single-panel layout that shows the view you want to scan. Then deselect everything, c onfigure the view, and press Scan You can also use this script to check an object's geometry to see if there are any faces the camera never sees. Running this script this on environment geometry and then deleting the detected faces can greatly improve render times. Make sure to go enter isolate select and then go into component mode if you decide to do this. Objects whose LOD is set to Template or Reference will confuse the script. Set all objects to a LOD of Normal. Otherwise the script will flag them as being "invisible."

(Right-click -> View image to see the images bigger)

Usage Examples:

The red pipe is selected because it is outside of camera1's view for the entirety of the 120 frames.

Here, the red pipe is not selected because it originated inside the camera view but exited. Because it was once in the camera view, it was not flagged as hidden. (See motion trail)

With Occlusion Search turned off, the green pipe is not selected even though the purple plane is completely blocking it form camera1's view. The red pipe was selected because it remained outside camera1's view.

However, with Occlusion Search enabled, the green pipe is selected because camera1 cannot see it, even though it is 100% inside camera1's frustum. Occlusion Search is disabled by default because sometimes objects such as lights and shadow casting objects are hidden behind other objects but are critical to the look of a scene.
Download Hidden Object Locator

Auto Keyframe Camera Shake Generator

Language: MEL

This simple utility adds customizable jitter to a camera (or any object with translate / rotate channels). Select the objects, launch the script, and press Shake!


Script UI

Animation Curves of camera before shake

Animation curves of camera after intense shake

Animation curves of camera after weak shake
Download Auto Shake Generator

Quad Sphere generator

Language: Python

Creates a sphere that has no triangles or poles (vertex with many edges leading to it). Note: The sphere isn't perfect, so if you know a way to fix the shape, please let me know.


The interface

A quad sphere with the default settings

A quad sphere with 5 divisions
Download Quad Sphere Generator

Batch Attribute Connector

Language: MEL

Bulk direct-connects a set of objects to a master object. Useful for easily setting up direct-drive for a controller, Rig-wide node caching or Rig-wide evaluation disabling.

The script is very simple, so just copy-paste the code into the script editor.


/*
 Created by Ravbug (ravbug.github.io)
 Simple program to mass connect the attributes of one object to many.
*/
//Set the Master object name and attribute name
$master = "Root";
$attr = "Caching";
$attr2 = "caching";

$objs = `ls -sl`;
$full = $master + "." + $attr;
$count = 0;
for ($obj in $objs){
 $exists = `attributeExists $attr2 $obj`;
 if ($exists && $obj != $master){
 $full2 = $obj + "." + $attr2;
 connectAttr $full $full2;
 $count = $count + 1;
 }
}
print ("Connected " + $count + " objects to " + $full);