MEL scripts


I played with that here, with minor changes to the actual path and name. It does not work with forward slashes in the file specs.

Change the second line to this:

string $fileWithPath = " O:\\3Dtest\\01.jpg"; 

Note I replaced the forward slashes with TWO back slashes, as a single backslash is an ‘escape’ character in MEL strings.

<* Wes *>


Thank you Wes,

now it is working :slight_smile:


Actually for working with paths in relation Maya -> Windows there is a “toNativePath” command:

Note: Extracted from Maya help:

 string $file = `workspace -q -fn`;[i]
 // Result: D:/Projects/projectOne/scene2 // On Windows[/i]
 string $path = toNativePath( $file );[i]
 // Result: D:\Projects\projectOne\scene2 // On Windows[/i]

So you should do:

 string $fileA = " O:/3Dtest/saveTextureA/03.jpg";
 $fileA = toNativePath( $fileA );

And it would work just fine.

ps. For going the other way Windows -> Maya use “fromNativePath” command.


i’ve read the very first post of this thread, and i found that to have a cubic helper was quite useful. Unfortunatly, the cube is not at the center of the world and have fixed values. So I’ve changed the script a little bit. Tell me if it helps ! (sorry, i’m really a newbie)
four scripts :

  • CreateSplineCube.mel
  • CreateSplineCubePrompt.mel
    and two others for the shelf buttons.

first part, the cube itself (“CreateSplineCube.mel”):

global proc JPL_CubeSpline (int $sizeSide)
	if ($sizeSide > 0) //useful if the user did not type an integer
		curve -d 1
			-p $sizeSide $sizeSide $sizeSide		-p $sizeSide $sizeSide (-$sizeSide)
			-p (-$sizeSide) $sizeSide (-$sizeSide)	-p (-$sizeSide) $sizeSide $sizeSide
			-p $sizeSide $sizeSide $sizeSide 		-p $sizeSide (-$sizeSide) $sizeSide
			-p (-$sizeSide) (-$sizeSide) $sizeSide	-p (-$sizeSide) $sizeSide $sizeSide
			-p (-$sizeSide) $sizeSide (-$sizeSide)	-p (-$sizeSide) (-$sizeSide) (-$sizeSide)
			-p (-$sizeSide) (-$sizeSide) $sizeSide	-p $sizeSide (-$sizeSide) $sizeSide
			-p $sizeSide (-$sizeSide) (-$sizeSide)	-p (-$sizeSide) (-$sizeSide) (-$sizeSide)
			-p (-$sizeSide) $sizeSide (-$sizeSide)	-p $sizeSide $sizeSide (-$sizeSide)
			-p $sizeSide (-$sizeSide) (-$sizeSide)
			-k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16;
		xform -cp;
		rename ControlCube1; //Maya will automatically increment if you create other cubes
	    error "not a valid value. Try again !";

second part, the code that creates a prompt window to set the size of the cube (“CreateSplineCubePrompt.mel”):

global proc JPL_PromptCubeDialog ()
    int $sizeSide;
	string $result = `promptDialog
								-t  "Create a cubic helper"
								-m  ("Please type the size of the cube:")
								-b  "OK" -b "Cancel"
								-db "OK" -cb "Cancel"
								-ds "Cancel"`;

 	if ($result == "OK")
 	    $sizeSide = `promptDialog -q -tx`;
		source "CreateSplineCube.mel"; 
		JPL_CubeSpline ($sizeSide);

The script to launch from the shelf with the prompt window :

source "CreateSplineCubePrompt.mel";
JPL_PromptCubeDialog ();

The last one to create the cube with a fixed value (change “5” by whatever you want) :

source "CreateSplineCube.mel";
JPL_CubeSpline (5);


Just thought I’d put up a simple script I made when I was just starting out… But then I thought I’d add some revisions to make it more user proofed; The concept is quite easily adapted for doing the same task to multiple objects, which is mostly what I did when starting out, especially with certain buttons in Maya that only let you do something to one object at a time.

Usually I abbreviate everything that can be abbreviated (like ls -sl etc) but I left most of this one in full for the less familiar peoples.

This script is for when a lot of duplicates have been positioned etc. but the user wants to replace the UVs on them all, from a UVed copy.
(note that the transferAttributes command leaves history on the object. It also assumes the default UV map, map1, is being copied.)

(? Anyone know how to paste something into this editor without it being reformatted and losing all it’s indents etc?! How is anyone supposed to put python here I wonder…)
(Edit: Actually, once posted a lot of the formatting is restored. But not all.)

 /////////////////////////////////////////////////// //              transferUVsToAll.mel             //
  //                                               //
  // (Select the prototype to copy UVs from last.) //
  //                                               //
  //     Simple MEL script by Nathan Chisholm      //
   global proc transferUVsToAll () 
      // Store current selection
      $sel = `ls -selection`;
      ///    Error precaution: Verify selection    ///
      if (size($sel)<2) error "Select meshes to copy UVs to, and select the mesh to copy from last.";
      for ($selObj in $sel)
      // Make sure all selected objects are meshes, for UV transferral
          $selShapes = `listRelatives -s $selObj`;
          if ( ! (`objectType -isType mesh $selShapes[0]`)) error ($selObj + " isn't a mesh. Select meshes to copy UVs to, and select the mesh to copy from last.");        
      /// == ---------------------------------- == ///
      // Save the last selected object as the 'prototype' to copy UVs from
      $prototype = $sel[size($sel)-1];
      print("Prototype = " + $prototype);
      // Deselect prototype, leaving all other objects selected, and save new selection
      select -d $prototype;
      $allofthem = `ls -selection`;
      for ($eachthing in $allofthem) 
      // Transfer UVs to each object in turn
          transferAttributes -transferPositions 0 -transferNormals 0 -transferUVs 2 -transferColors 2 -sampleSpace 4 -sourceUvSpace "map1" -targetUvSpace "map1" -searchMethod 3-flipUVs 0 -colorBorders 0 $prototype $eachthing;
          print("Done " + $eachthing + "/n");
      // Reselect all except the prototype, print finish statement
      select $allofthem;
      print("Coffee break over.");
   // Run the defined procedure.


Hi All,

I am looking for a specific Maya script that was highlighted by Eric Miller in a BodyPaint course I took online at Gnomon. The script is part of his Maya - BodyPaint render setup workflow and is very simple. It will update all selected file textures extensions (.bmp, .sgi, etc.) in a Maya scene with a new extension. I am including a screen shot of the script in action from one of his videos.

I have tried searching everywhere with a lot of different keywords but haven’t been able to find it. Also, I posted over at Gnomon but wanted to see if anyone here remembers it? Hopefully someone does. Thanks in advance!



It is called RenameFileExtension with NO SPACES and can be found on Creative Crash. Doh!



Hi all,

I’d like to share this script

It controls all scene lights and Mental Ray Indirect lighting with one UI. Make sure Mental Ray plugin is loaded and your renderer set to Mental Ray.

I hope its ok that I put the link instead of pasting the code.



Hi all,

If you liked my Light Control tool, then download the new version from

I would love to get some feedback from users.



First - great script! Clean and intuitive. I have had an issue with it where, after using it, my attributes window becomes unresponsive. I can scroll it, or open up a section but I don’t see anything happen until I switch tabs then switch back. Not sure if it just me but I have tested it out a few times with the same result.

A few suggestions:

  1. Enhance Light List - See this link for a view of the Mudbox Object List. See how it has toggles for Visibility and Locks? Also, the little arrow above is a filter and could be used to filter lights by type. Maybe more of a small icon route to select all, isolate, etc. You could use some of the Maya Viewport icons or default ones to keep the look consistent.

  2. Filters - Maybe a way to filter the list by name or wildcard?

  3. Look Through Selected - I use this feature a lot, might be nice.

  4. Access to render settings.

  5. Some custom tool like a script to autosetup an area light parented to a spotlight? Or a way to add a custom attribute to a light?

Look forward to more updates. Thanks,



Hi nbreslow,

First off, thank you very much for taking the time to post this, I really appreciate it.

Second, about the problem you have with the attribute editor, I just tried it a few times on different scenes and I didn’t have that problem. If you get the opportunity, try it on another machine and let me know if you find the same problem.

Lastly, I really like all your suggestions and I’ll incorporate them in the new update plus some other features. I have two questions though, I never heard about parenting an arealight to a spotlight, is that to have the spotlight cast shadows and the arealight emit light only? or am I misunderstanding this?

My second question is about the custom attribute, do you mean like “Modify–>Add Attribute…” or are you talking about a specific custom attribute you want?

Thanks again nbreslow, I appreciate your effort very much.



I’ll try the script on my other machine at home and see what’s up and let you know. I use the NEX plugin from draster but I never had a problem with it before not playing nice with other stuff. I also use a bunch of other scripts - not sure what it could be.

Check out this link. This is really what I meant - nice little light setups. Some stuff like this would really enhance your script. Make it more of a light maker/controller. Not sure if this is what your after…just a thought.

Regarding the attribute thing - sometimes it is nice to add in a custom attribute so you have it in case you need to separate things out in a script at render or whatever. Not essential - I mostly use it on objects that should not receive AO but some people might use it for lights. Something like this:

addAttr -at byte -longName miLabel -k 1 -defaultValue 0;

Hope that helps and thank you!



Thank you very much nicholas, that was very educational. Those light setups are so awesome, I will definitely do something similar.

Let me know when you try the script at home.

About the custom attribute, I will add that option as well.


This script allows you to select similar poly objects like the feature in 3ds max. Copy the code and assign it to a hotkey.

// Global proc for selecting similar poly Objects
global proc he_selectSimilar ()
string $newSelection[];
string $selected[] = ls -sl;
int $selVertices[] = polyEvaluate -vertex $selected[0];
float $selecArea[] = polyEvaluate -worldArea $selected[0];
string $allPolyObjects[] =ls -exactType mesh;
for ($each in $allPolyObjects)

int $toCompareVertices[] = `polyEvaluate -vertex $each`;

float $toCompareArea[] = `polyEvaluate -worldArea $each`;

if ($selVertices[0] == $toCompareVertices[0] && floatEq ($selecArea[0], $toCompareArea[0]))

    $newSelection[`size $newSelection`] = $each;


select $newSelection;
clear $newSelection;


hey all,

I'd like to a share a script I made for controlling rotation/scaling/shapes of objects based on a sphere of influence.


Basically, you have a bunch of driven objects, and a base object. Your change the rotation/scale/shape of the base object, and the driven objects takes those properties based on how far away it is from a control sphere object.

To use, select a bunch of objects that you want to be driven, and then select the base object. The base object must be selected last. Run the script, and there will be a sphere at the origin that is your influence object. 

Also, the base object should have frozen transformations for rotate and scale before the script is run.

It's probably simpler to explain with an example, so here's a Maya file. It's an Ascii file from Maya 2011. There's quite a few objects in this scene, so it may take a little time to open.

There are also some controls available on the influence object. 

You can control:
a random amount of rotation and scale for each of the driven objects
the seed for the random number
the outer radius where the influence is 0%
the inner radius where the influence is 100%
a random radius of influence
"Inner Follows Outer" which determines if the inner influence is a percentage of the outer influence

Please let me know if it doesn't work, or if you have any suggestions.


Hi everyone,
im sharing this script i wrote which allows you to do most type of constraints, multiple times.–2


Hi, I want to share a script I wrote, it’s a maya user interface for dualview displays which can wrap all Editors, Panels and Layouts into one maximized window.
(currently without Attribute Editor and Tool Settings)

Comments, suggestions, and bug reports are welcome.


I can’t seem to find this script anywhere, perhaps I’m searching for the wrong keywords. This must exist somewhere.

If you’re familiar with 3D Studio Max, you will know the Lattice Modifier. This is NOT the same as the Lattice Deformer in Maya. What the Lattice Modifier does in 3DS Max is it takes all the edges of a mesh and creates cylinders of the same length and orientation. You can adjust the radius and number of sides. In effect, you are creating a “wireframe copy” of your mesh with actual thickness.

Imagine you model a greenhouse. Select the mesh, click Lattice, and presto! You have a wireframe geometry which you can use as the framework / latticework. This would be useful for many things from making girders, framework for cockpits of older planes, or just cool wireframe renders with actual thickness.

Does anyone know if such a script exists? Thanks in advance for your reply.


I want to work lighting animation in different forms by mel
I need the code or anything can help me
I need this light for virtual fashion show
Please necessary:applause:


Sir, your reply is off topic.