Maya Scripts

Here are a bunch of Maya scripts that I wrote that I am releasing to the public. They are confirmed to work on Maya 2016 or later.

If you find any issues with any of the scripts, add a comment or 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 (or ngons). An N-gon is a polygon face that has more vertices than 4 (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, or put them in a display layer, etc.

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 or put them on a display layer or what have you.

To use, Go into a single-panel layout that shows the view you want to scan. Then deselect everything and

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 found faces can greatly improve render times. Make sure to go into 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.”

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!].

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 have a way to fix the shape, please let me know.

Download Quad Sphere Generator

Batch Attribute Connector

Language: MEL

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

Very simple, so just copy-paste the code into the script editor.

/*
Created by Ravbug (ravbuganimations.com)
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);

Leave a Reply

avatar