| Naughty's MEL Scripts | |
All of the following MEL scripts were designed and written by me sometime between 2001-2003
while at Genepool Software. As Genepool is now defunct I'm making the scripts public domain
which means they're all now totally free to download and use in whatever capacity you like.
You can distribute them, modify them, pass them on to your friends or pass them off as your
own work if you like! Most of them would not have been possible without the help and support
of all the great guys who contribute to the Maya and MEL discussion forums on
www.highend3d.com, the best web resource
for anything Maya and MEL related. All of these MEL scripts contain full descriptions,
instructions and usage examples in their headers and I've tried to leave in most of the
comments and debug print statements (//commented out) where appropriate in case you want to
see how they work or modify them. Each of the script description boxes below indicates which versions of Maya it will work on (in the top-right) but as they are all fairly simple scripts there's a good chance they'll work on any version of Maya. If you successfully use any script on a different version of Maya than that listed, please let me know so I can update the information accordingly. The only exceptions to this are the "Replacements" which I can guarentee will NOT work on other versions and should only be used with the specified version. Any suggestions, bugs or ideas please feel free to contact me at: naughty_genepool@hotmail.com (This email address can also be found in the script headers). |
|
Download a ZIP containing all the Scripts on this page -
maya.zip -
( 45 files - 26 Mar 04 )
|
|
| Modelling Scripts | back to top |
| cookieCutter.mel | [ 4.5 ] |
CookieCutter takes two polyMesh objects and traces a split path along the first (base object)
based on the intersection of the second (cutter object). This proc is extremely
basic, I've only been able to achieve this split by using Maya's default BOOLEAN
functions, so don't say you haven't been warned! :) To use, select two mesh objects,
the "base" first (the one you want to split), and then the "cutter" object. Then
just execute cookieCutter. NB: DOESN'T work on non-intersecting objects (duh!).
It also messes up objects with children quite a bit too..
|
![]() |
| curveToPoly.mel | [ 4.5 ] |
This tool converts any selected NURBS curves into polygon meshes via a small UI dialog.
It also displays a dynamic preview of the resulting polygon mesh so you can adjust the vertex
count/resolution for the desired result before you commit to it. This tool is not quite 100%
right at present as there seems to be a strange glitch in Maya's "rebuildCurve" function. But,
it works pretty well for normal use, and it's still better than doing it manually.
|
![]() |
| detachSeparate.mel | [ 4.5 ] |
This script allows you to detach the selected faces from any selected objects.
Detached faces become a new, seperate object but retain their original name,
position, pivot, material, vtx colors, etc.. It bypasses all Maya's default
"separate" functions and all the transform history nonsense that goes with it.
N.B. It doesn't work on instances.
|
![]() |
| extrudeEdgeUVs.mel | [ 4.5 ] |
This script extrudes the selected edges and tries to preserve the UV mapping present
along the initial edge. Maya's default edge extrude function just normalises the UV
mapping on the newly created face which is of use to neither man nor beast.
This script tries to address this issue. This script essentially SUBDIVIDES the
selected edge(s), moves the vertices out and polySplits a new edge where the old one
was. The UV space is stretched out in such a way that the new face has a square mapping
area. This is hard to explain properly, just try it and see, it's how extruding SHOULD
work... There are still a couple of known "issues" :), occasionally the UV extrude
direction is inverted, and multiple adjacent extrudes don't get sewn together. These
things should be fixed in a later version... This script requires another script
splitByVertex.mel to work.
|
![]() |
| flattenCombine.mel | [ 4.5 ] |
This script is a "Super-Combine" function. It combines all selected polygon
geometry into a single object. It performs the same basic function as the
regular Maya "combine" command but it bypasses all Maya's transform history
nonsense and avoids all the other annoying complications that go with it. As
well as a clean combine, flattenCombine preserves the name, pivot position and
heirarchy (DAG) position of the original object (which can even be a nul
transform (empty group)). flattenCombine will even attempt to preserve the
original object's translation position (sometime's unsuccessfully! :( )
|
![]() |
| nathangulate.mel | [ 4.5 ] |
This proc works like "quadrangulate" but it doesn't stop at 4-sided polys... It
makes every continuous planar poly into a single poly, removing all the planar edges
and their vertices which lie across it. It is a super clean-up poly reducer
that doesn't actually change the shape or form of your object, but simply removes
any polygons that are unnecessary to it's topology. A single input parameter defines
the angle of tolerance at which planarity is assumed so you can even poligonize non-planar
faces.
|
![]() |
| polyCycleUVs.mel | [ 4.5 ] |
This script will CYCLE the UVs of ANY selected Polygons (individually). Every UV around
the selected polygon's edge is relocated in turn to the previous UV's position. This has the
visual effect of rotating the polygon's UV area without actually changing the UV area's shape
or position. This function is a MUST have if you use the texture editor for mapping individual
faces, especially if you ever use Maya's "copy & paste UVs" functions. Some of the procs in
this script come directly from A|W's "rotateUVsByVertex.mel" (\AW\Scripts\Others\polyRotateUVsByVertex.MEL)
but hacked and modified a bit so they're actually some f**kin' use..! polyCycleUVs requires polyUVExtract.mel to work correctly. You may also find it usefult to grab switchComponent.mel if you'd like it to work (properly) on any other component selections besides faces. |
![]() |
| polyNormalRandomize.mel | [ 4.5 ] |
This quick hack randomizes the (individual) normals of every selected face, giving a rough, uneven
appearance to objects. It was originally designed to make environment mapping look better
on flat shaded (unsmoothed) polys, but it works pretty well to roughen up the smoothing
on hi-res models and gives quite an interesting look to some flat shaded objects. Having
said that though, it's not exactly quick. In fact it can take about 10 seconds to randomize
about a 100 quads... so I wouldn't advise running it on more than a handful of faces at a time.
|
![]() |
| polySplitByVertex.mel | [ 4.5 ] |
This is a bit of a dodgy hack to allow "real-time" splitting from vertex to vertex. It does work
fine if you use it correctly but it's not very elegant or robust. Execute polySplitByVertex and
then keep shift-clicking vertices. each time TWO or more are selected it will split between them.
If you start with NO vertices selected it does a pretty good job of following where you go and
de-selecting previously used vertices. It uses a scriptjob to follow your selection and this scriptJob
MUST be killed when you've finished otherwise it'll keep on trying to split with each further
selection you make. Pressing F8 to return to object mode when you've finished splitting will kill
the job and de-activate the splitting. This script uses another script
splitByVertex.mel to perform the actual splitting.
|
![]() |
| polyUVExtract.mel | [ 4.5 ] |
This script 'cuts' the selected poly faces from their UV shell, allowing you to
move them around in UV space without affecting the UVs of any adjacent connected
faces. The initially selected and cut faces are also returned as a UV selection to
allow instant movement after the extraction.
|
![]() |
| randomizer.mel | [ 4.5 ] |
Randomizer is a basic UI tool that allows you to easily randomize the position,
rotation and scale of any selected objects (at the object level). Great for jumbling
up arrays of objects like trees & rocks or items on a desktop etc.. Extra options
allow you to randomize about World Space (instead of around the objects local axis),
lock the XYZ scales of objects and avoid negative scales (so objects don't flip
inside-out). Not much more to say, does exactly what it says on the tin.
|
![]() |
| rotatePivotViaObject.mel | [ 4.5 ] |
This script allows you to forcefully rotate an objects Pivot. Maya does already
allow you to rotate pivots but it isn't a "true" rotation, it's just adding some
kind of axis-rotation offset, and consequently doesn't quite cut it (for my money
anyway) as the object axis no longer represents the objects local axis. Besides,
if you are exporting data out of Maya then more likely than not you'll need true
pivot rotation values and not just Maya's local axis offsets. This proc works by
rotating the OBJECT and then re-aligning all its vertices back to their original
positions. Consequently it only works on polygon mesh objects.
|
![]() |
| snapUVToGrid.mel | [ 4.5 ] |
This script simply moves every selected UV to it's nearest grid point (based on current UV grid settings).
|
![]() |
| snapVertexToAverage.mel | [ 4.5 ] |
This script simply moves every selected Vertex to the average centerpoint of the
entire selection. It does this by calculating the selection's bounding box,
calculating this bounding box's center then moving each vertex to that position.
|
![]() |
| snapVertexToGrid.mel | [ 4.5 ] |
This script simply moves every selected vertex to it's nearest grid point (based on current grid settings).
|
![]() |
| snapVertexToNearest.mel | [ 4.5 ] |
This script simply moves every selected vertex to it's nearest neighbouring
vertex (within the given distance) ignoring other selected vertices. The proc checks every UNSELECTED vertex in the
object(s) within proximity to your vertex(s) so it can be quite slow if you have
close-by objects with a lot of vertices (100+). The number of objects in the scene
doesn't affect the speed as they are ignored if they are more than the specified
distance away. If you have complex geometry but it is split into multiple objects
this proc will actually run much faster.
|
![]() |
| splitByVertex.mel | [ 4.5 ] |
This script splits faces between selected vertices (though not over existing edges)
It saves you having to use edge/vtx snap while using the polySplit tool and also
allows continuous unbroken splitting across vertex junctions, which is impossible
to do with the polySplit tool. splitByVertex currently uses a very lazy and stupid method
of trying to split every single selected vertex with every other selected vertex (rather
than doing some basic face-connection checking to speed up the process greatly). The next
version will include this optimization and may even be complete by the time you read this...
There is also an interactive version of this script:
polySplitByVertex.mel, which allows you to continuously
select vertices and have them split in real time as you go.
|
![]() |
| UI and Display Scripts | back to top |
| changeShelf.mel | [ 4.5 ] |
This script allows you to cycle forwards and backwards through your shelves. The
best way to facilitate this would be assigning it to two hotkeys ( [PgUp] and [PgDn]
would be a good choice!).
The script also has another 'hidden' function, designed as a complement to the
RMB context stuff I've done. Any shelves whose name starts with "user" are
automatically SKIPPED when using "changeShelf".
|
![]() |
| fileNodeRename.mel | [ 4.5 ] |
This script renames the selected file nodes with either their file's filename
or their parent shader's name. If no file nodes are selected it will rename ALL
of them.
|
![]() |
| graphSelectedFaces.mel | [ 4.5 ] |
This script opens the hypershade window and displays whichever shaders are
being used by the currently selected polygons/objects.
Pretty straightforward really but pretty goddamn essential.. why Maya doesn't
do this already is anyone's guess...
|
![]() |
| gridSize.mel | [ 4.5 ] |
This script allows you to cycle through several preset grid spacings allowing for
easy dynamic grid doubling/halving (using hotkeys). It was designed primarily for
game level builders which is why the presets are all power2 sizes (2,4,8,16,32,etc..)
and not Maya's default decimal sizes. It works in any viewport, including the UV
Texture Editor, depending on which viewport the cursor is over. It also prints out
grid size feedback on the output line after each execution.
|
![]() |
| hideSelectedFaces.mel | [ 4.5 ] |
This script allows you to hide polygon faces in individual viewports. Because
Maya only has a "Show Only Selected (isolate)" function and not a "hide selected" function,
I have to actually isolate everything EXCEPT the selected "hidden" polygons.
The consequence of this is that it can actually take a couple of seconds to hide the
selected faces if there are a LOT of DAG nodes (objects) in your scene (800+).
If you use my RMB context scripts you can access the hiding and unhiding of polys
from there, otherwise you'll just have to assign it to a hotkey or shelf button or something.
|
![]() |
| listMaps.mel | [ 4.5 ] |
This procedure lists the node name, pixel sizes and filename(inc. path) of any selected
file nodes (texture maps) in the script editor. If no file nodes are selected it will
simply list ALL of them. Reported data is tab aligned to make copying the text into
a batch file or wherever else you want a bit easier.
|
![]() |
| mergeMaterials.mel | [ 4.5 ] |
Replaces all selected materials(shaders) with the FIRST material selected. Useful for quickly
replacing materials or cleaning up (used) duplicate shaders.
Just pick the shader you want to keep, then select any number of other shaders that you want
to replace with it and then execute mergeMaterials. All the selected shaders are deleted except
the first. N.B. a "Delete Unused Nodes" is performed.
|
![]() |
| nudge.mel | [ 4.5 ] |
Moves the selected objects or poly components in a 2D, viewport-relative
direction by a given amount, based on the current grid spacing. Designed
to be assigned to hotkeys for easy offset movement of objects and components
without having to switch tools or fiddle around with snap settings.
Nudge is primarily designed for working in ortho and texture viewports but it
does actually work in perspective viewports too, EXCEPT when the camera is
upside-down or has a non-zero Z rotation (don't ask!). Nudge will even move
UVs around in a geometry viewport! This script is great when used in conjunction
with gridSize.mel
|
![]() |
| installNudge.mel | |
This script doesn't actually have a usable function per se, it is designed to be run only once
to assign the 12 hotkeys for use with the nudge tool. The hotkeys it
assigns/replaces are: [CTRL-cursors], [ALT-cursors] and [CTRL-ALT-cursors] which nudge by 1,
half and 4 grid squares respectively. These keys can be easily edited within this script or
changed in the hotkey editor once installed.
|
|
| revealPeers.mel | [ 4.5 ] |
This script will recursively SHOW (unhide) all siblings (and children) of the
current selection. When bound to a hotkey it's a nice way of unhiding the
various levels of a heirarchy straight from the viewport as you work, without
having to flick back and forward to/from the outliner or hypergraph.
|
![]() |
| selectShadedFaces.mel | [ 4.5 ] |
Selects any faces from within the current selection that use the specified shader.
selectShadedFaces was designed to be executed from the HyperShade RMB menu as it
needs a single shader for its input. Make any kind of component or object selection
and then execute this script. Any faces in the original selection that DON'T use the
specified shader will be deselected.
This function provides a simple and effective method of selecting shaded faces
only in certain objects, without selecting every face in the entire scene that uses
the shader.
|
![]() |
| switchComponent.mel | [ 4.5 ] |
This proc is a combination of Maya's default polygon component switching (found on keys F9-F12)
and the "Convert Selection To..." functions, but with a more sophisticated
conversion process that makes it much more useful. In fact, I've remapped my F9-F12
keys to this function and it makes switching components a much more time-saving
and enjoyable experience.
|
![]() |
| Helper and Debug Scripts | back to top |
| protractor.mel | [ 4.5 ] |
This proc creates a simple protractor tool. It's meant to look and act like
Maya's distance measure tool but it's not quite as slick... it does the
job adequately though. My protractors consist of 3 connected locators which you can
select, move around, snap, etc.. and the protractor's angle readouts update on-the-fly.
Each protractor displays BOTH acute and obtuse angles simultaneously and you can create
as many protractors as you like.
|
![]() |
| unfreeze.mel | [ 4.5 ] |
This script performs the opposite of a "freeze Transformations" (makeIdentity) on all
selected objects. Select any number of objects and execute. Their translation values
will change to reflect their actual world space positions although the objects won't
actually move. It does work on parent objects but it won't quite work on individual
child objects... I'm looking into that but it's a bit more complex than the easy
'force' method I'm currently using.
|
![]() |
| vertexDebugger.mel | [ 4.5 ] |
Vertex Debugger (vD) is a simple tool to help users get useful information
about the vertices in a scene which is either un-accessable to those not fully
fluent in MEL, difficult to interpret or simply too tedious to extract.
The vD allows users to find vertices at specific world-space coordinates or within
specified ranges, browse through lists of vertices and clamp vertices to
specific axis positions. It also has a few other useful features like displaying
bounding box extents for vertices. It has full tabbed instructions built into the
UI explaining each feature and function in detail with examples. This is a great
game developer tool, especially for debugging level geometry.
|
![]() |
| vertexLocator.mel | [ 4.5 ] |
This proc creates a "mini" locator at the position of any selected vertex.
It's designed to emulate 3D Studio (& MAXs) facility to create 'isolated'
vertices (verts not connected to an edge or face). They can be useful for
creating, then moving or mirroring a vertex layout/array (instead of
duplicating/templating a whole object for vertex reference). They can also
be snapped, and snapped to, just like real vertices.
|
![]() |
| Game Development Scripts | back to top |
| boundingBox.mel | [ 4.5 ] |
Coming soon...
|
|
| convexHull.mel | [ 4.5 ] |
Coming soon...
|
|
| exportToMap.mel | [ 4.5 ] |
Coming soon...
|
|
| spriteGlow.mel | [ 4.5 ] |
Coming soon...
|
|
| Scripting Tools | back to top |
| getUserScriptsDir.mel | [ 4.5 ] |
This proc returns the current user's (global) scripts folder. Not the version specific script folder
(eg C:\docs\user\MyDocs\maya\4.5\scripts\), that `getEnv` returns, but the global script folder that
all versions of Maya can see (eg C:\docs\user\MyDocs\maya\scripts\). Maya's doesn't seem to have a
pointer to this folder. until now.
|
![]() |
| openProc.mel | [ 4.5 ] |
This function is a kind of super "whatIs". Type "openProc proc_name" and it will instantly launch
the given MEL script into your default text editor (or whatever you have MEL files associated with).
If the specified "proc name" is not a MEL script it will launch the help file for that command instead.
|
![]() |
| removeInvalid.mel | [ 4.5 ] |
This proc returns a valid "Maya name" string from a supplied string. It basically strips out any
characters that would be invalid in a node name. It has two modes of operation, the first simply
strips the offending chars from the string, and the second mode replaces them with an underscore.
It even handles numbers at the start of the string (not allowed in Maya) by inserting an underscore
in front.
|
![]() |
| sourcer.mel | [ 4.5 ] |
This is a handy little tool I find very useful while I'm developing a new script or tweaking an
existing one. It's a simple dialog box that allows you to input the name of a MEL script (as well
as additional parameters the script may require) and each time you press the dialog's button it
will source the specified file and execute it (using the supplied parameters). It also saves the
contents of the input fields between sessions so it will always bring up the last used entries.
|
![]() |
| Replacements | back to top |
These "replacement" scripts are all modified versions of existing A|W scripts that ship with Maya and
make up part of Maya's default User Interface. They are designed to replace your existing scripts and
include such things as minor 'bug' fixes, enhancements and extra features. Each script description
below explains what has been modified in each case. Because each of these scripts is meant to replace
an existing run-time script they are VERSION SPECIFIC. The chance of them working on any other version
of Maya than that listed is extremely slim and trying to do so could actually cause a serious problem
with Maya. Because these replacements are version specific, they should not be copied into the common scripts folder: e.g. ...\My Documents\maya\scripts\but placed into the version specific scripts folder: e.g. ...\My Documents\Maya\4.5\scripts\If you don't like the new replacement, or it causes a problem you can simply delete it from your scripts folder. DO NOT ACTUALLY REPLACE YOUR EXISTING INSTALLED A|W SCRIPTS e.g. C:\AW\Maya4.5\scripts\others\ |
|
| buildHypergraphNodePopupMenuItems.mel | [ 4.5 ] |
Using this script adds an extra menuItem to the pop-up menu when RMB-clicking on a texture
(fileNode) in the hyperShade panel. It displays the texture's filename along with it's pixel
dimensions. e.g:
|
|
| buildObjectMenuItemsNow.mel | [ 4.5 ] |
Using this script adds two extra commands to the pop-up menu when RMB-clicking on nothing in a
model viewport; "Grid toggle" and "Light Toggle" which toggle display of the grid and lights
respectively in the current viewport. It also adds a handle to the custom userMenu, if one exists.
added "Show All Faces" option to support my hideFaces.mel
(see dagMenuProc.mel below for more info on the userMenu)
|
|
|
dagMenuProc.mel
(requires: createContextMenu.mel / naughtyUIProcs.mel) |
[ 4.5 ] |
Maya's dagMenuProc script controls Right-Mouse-Button clicking on objects in the model viewports.
This replacement version does the same job but has a stack of new context features added.
Feature #1: The object name (first menu item) now also displays the objects "type" and is now a sub-menu containing an "isolate" function and copy & paste functions for 3D position, heirarchy position and pivot position. (*scripters: the "type" is passed to the menu creation proc so you can add your own object context menu Items extremely easily!) Feature #2: Component selection Context Menus. If you RMB click on a vertex selection you get a new, customizable pop-up menu containing vertex commands. If you RMB click on a face selection you get a customizable pop-up menu containing face commands. The same goes for edges and UVs. Each context menu can be converted into a shelf and then easily edited by the user, all the changes being instantly reflected in the pop-up menu. Feature #3: It supports a totally custom built new sub-menu that will only appear if a shelf called "userMenu" exists. This new sub-menu appears on the RMB pop-up and contains all the items on the "userMenu" shelf allowing you to create a "favorites" menu that is quickly accessible from your RMB menu. Feature #4: A new "Configure..." menu item gives you the option to toggle on/off any of the available RMB menu items including all the default Maya items/sub-menus. This configuration remains from session to session. The first time you use this replacement script, all your RMB menu items will be OFF, so you will need to customize your menu straight away using this feature. Feature #5: The Materials Menu has been enhanced: the material name is now displayed, and the attribute function works on the SELECTED face(s) now rather than the entire object. Feature #6: The actions menu has had "Center Pivot" added and the "Template" command has been turned into a single toggle, rather than two seperate on/off commands. Feature #7: I've added a "Hide Faces" option to the compass (component) marking menu whenever faces are selected. Needs hideSelectedFaces.mel to actually perform the face hiding. |
|
| initAfter.mel / initHUDScripts.mel | [ 4.5 ] |
These two scripts modify the "poly count" HUD display, adding an object counter and a triangle
counter. The object counter has three values, the fisrt is the number of DAG objects in the entire
scene. The second is the number of poly geometry objects in the entire scene and the third value
is the number of DAG objects currently selected. The triangle counter is just two values, the number
of triangles in the entire scene and the number of triangles in the selected object(s). HOWEVER, the
triangle counter only lists values for whole objects I'm afraid, so if you've got 2 quads selected
on a cube object, the triangle counter will list 12 triangles and NOT 4. Triangle counts ignore
intermediate objects. I also disabled the UV counts as I felt there was too much info on the HUD with
my additions and I couldn't see who would want to use those anyway..? You can always turn the UV
count back on by editing the initAfter.mel file (comments inside it tell you how to). You MUST have
both of these files for the new HUD to work.
|
|
| OutlinerEdMenu.mel | [ 4.5 ] |
This replacement adds a host of new functions to the outliner's RMB pop-up menu. Firstly, it adds a handle
to the userMenu (see dagMenuProc).
Secondly, it adds a handle to a "Rename Selected..." script. My default is to use Ben Wronskys excellent "rNamer.mel" (available from www.highend3d.com) but if you have your own prefered rename script you can always edit this script or copy your existing script and rename it as "rNamer.mel". The next addition I've made is a collection of organizational options; Grouping, Sets and Layers. The Grouping submenu allows you to group, ungroup, unparent and "cut" and "paste" the selected objects. These "cut&paste" functions are simply to move objects from one DAG (heirarchy) position to another without having to use the (sometimes awkward) MMB dragging. You can also define custom group names for quick grouping under commonly used names. The Sets submenu allows you to quickly place the selected objects into new or existing (quick) sets, remove the selection from any sets they are currently members of, empty existing sets as well as removing empty ones. The "Add to.." menu has a "create new set" option and the "Remove from" menu intelligently lists only those sets that the selection belongs to. The Layers submenu allows you to quickly send objects to existing Layers as well as allowing you to remove them from their current layer. This it does properly, deleting any links to a layer, rather than Maya's default method of simply assinging the object to the "defaultLayer" which I find very annoying. The last major addition I have made (besides shuffling around the "Select Children" and "Reveal Selected" items, is to add two new view methods, found in the "View Options > Graph" submenu. The first is "Selected" which makes the outliner HIDE all the objects that aren't currently selected. This feature is not dynamic so once you've "graphed" the selection the outliner will continue to show just these items. It's kind of like the "Isolate" viewport function, but for the outliner. Try it, you'll love it. The second is "Layers" which makes the outliner display only the existing layers and their members. This mode allows you to see at a glance which objects belong to each layer and, although you can't use it to actually edit the membership, you can use it in conjunction with the aforementioned "Layers" submenu for this kind of functionality. |
|
| statusLine.mel | [ 4.5 ] |
Coming soon...
|
|
| texturePanel.mel | [ 4.5 ] |
Coming soon...
|
|