MEL scripts


can some body tell me expression for to make camera shake like explosion fx


[right][left]Hi, can anyone please tell me how can I change the order of any particular vertex for any object?.thanks


can anyone please tell me how can i change the order of any particular vertex in any polygon mesh?



he girls n guys! Just want to move this thread up to its initial purpose :]

// a popup on the right float field to make the currentTime the maximum range
popupMenu -p floatField4 -mm 1 -button 3;
menuItem -rp "E" -label "currentTime to range maximum" -command ("playbackOptions -max `currentTime -q`");

just put this in your userSetup.mel.

here is a short video:

I always just wanted to make a simple stroke to do this. Now I have it ^^ yay!
I hope your range-flield is floatField4 as well… unfortunately most of the Maya-elements don’t have dedicated names. But here it wurks well :]


hahahaha!!!this is my first mel script!!!

this procedure will delete all the animations (keyframes, ik effectors and expressions) in all the joints of a skeleton

when making a short film with my partner, the guy who make animation always complain that he cannot delete all the animations of a skeleton at a time…so I write this for him~(:slight_smile:)
a hahahaha~

global proc A_deleteAllKeys(string $A_rootNode)
//delete all keys
string $A_childNodes[]=listRelatives -type joint -allDescendents -fullPath $A_rootNode;
string $A_rN[]={$A_rootNode};
string $A_nodes[]=stringArrayCatenate($A_rN,$A_childNodes);

string $A_node;
for($A_node in $A_nodes)
cutKey $A_node;

//for each node,test if there is an expression, delete it if there is any
string $A_expressions[]=listConnections -type expression $A_node;

delete $A_expressions;

//delete all ik effectors
string $A_ikEffectors[]=listRelatives -type ikEffector -allDescendents -fullPath $A_rootNode;

delete $A_ikEffectors;



Hmm…I made a thread of this but it doesn’t show up…

Anyway, I made a Maya to After Effects script:

It’s a variation on Rob Bredow’s script that converts a selected object or vertex in Maya to 2D screen space in After Effects. I’ve added a GUI to the MEL script for camera selection and enabled multiple selections. If you export two points/objects from Maya the AE script that imports the data will automatically generate a Null with expressions that shows the scaling and rotation between the two points.

Thought I would try to get it out there so I could get some feedback and iron out any bugs. I’m especially interested to see if the tracking remains true across every possible camera setting (h/v aperture, film gate, etc.)


i just wrote this one thought it might be useful its to help when your trying to figure out whats going on with echo all commands, paste a string into the text field then hit the button, if its a mel proc, then that will be open with your default text editor

global proc whatIsIt(){
  if (`window -ex whatIsit`)
  	deleteUI whatIsit;
  window -menuBar 1 -t "What Is It" whatIsit;
  menu -l "Help";
  	menuItem -l "About" -c "aboutWhatIsIt()";
  $form = `formLayout`;
  	$tf = `textField whatIsTextField`;
  	$btn = `button -w 50 -l "?" -c "openIfMelProc( textField(\"-q\", \"-tx\", \"whatIsTextField\"))"`;
  formLayout -e
  	-af $tf "top" 0
  	-af $tf "left" 0
  	-af $tf "bottom" 0
  	-ac $tf "right" 0 $btn
  	-af $btn "right" 0
  	-af $btn "top" 0
  	-af $btn "bottom" 0
  showWindow whatIsit;
  global proc openIfMelProc(string $text)
  $whatIs = whatIs( $text );
  if ($whatIs == "Command")
  	print "Command
  else if ($whatIs == "Unknown")
  	print "Unknown
  	$path = stringToStringArray($whatIs, ":");
  	if (size($path) == 3)
  		print "Script
  		system("load " + $path[1] + ":" + toNativePath($path[2]));
  		print "Unknown
  global proc aboutWhatIsIt(){
  if (`window -ex "aboutWisitWin"`)
  	deleteUI aboutWisitWin;
  window -s 0 -t "About" aboutWisitWin;
  text -l "
paste a string into
the text field and
then press the button
there are 3 possible

1. Command
2. Unknown
3. Mel Proc

if the result is a
mel proc then that
script will be opened
with your default
text editor

James Drew";
  showWindow aboutWisitWin;
  window -e -wh 146 290 aboutWisitWin;


this is my first test with qt, is a maya to nuke camera exporter that i wrote some weeks ago, and now i put an interface in qt

the files are here

you must uncompress the file in my documents folder and you will get a new shelf with the script


No idea if this exists anywhere (I’m sure it does.) or if it’s already been discussed here (I’m sure it has!) but here’s a script that copies user defined attributes from one object to another, even if they don’t exist on the destination object.

This is something I’ve wanted for like the last 10 years, but have been too lazy to build. I had some free time today, so I wrote it and will share it with you!

  //	Created by Jake Helms
  //	2010/04/18
  //	This script copies user defined attributes
  //	from one object to another.
  //	To use:
  //	CopyUserDefinedAttributes "sourceObject" "destinationObject";
  //	Limitations:
  //	- Currently only supports the basic Maya attribute types
  //	- Does not support short names or nice name overrides
  //	Feel free to expand the functionality and re-share!
  global proc CopyUserDefinedAttributes ( string $from , string $to )
  	string $ln_to 	= `longNameOf($to)`;
  	string $attrListFrom[] 	= `listAttr -userDefined $from`;
  	string $attrListTo[] 	= `listAttr -userDefined $to`;
  	// This removes destination attributes that are about to be copied
  	// if they exist on the source. This prevents attribute clashing.
  	for ( $attr in $attrListTo ) {
  		if ( `stringArrayContains $attr $attrListFrom`){
  			deleteAttr -at $attr $to;
  	for ( $attr in $attrListFrom ) {
  		string $attrType = `getAttr -type ($from + "." + $attr)`;
  		// vectors
  		if ( $attrType == "double3" ) {
  			float $val[] = `getAttr ($from + "." + $attr)`;
  			addAttr -ln $attr -at "double3" $ln_to;
  		// integers
  		if ( $attrType == "long" ) {
  			int $val = `getAttr ($from + "." + $attr)`;
  			string $cmd = ("addAttr -ln " + $attr + " -at long ");
  			if (`attributeQuery -node $from -minExists $attr`){
  				float $min[] = `attributeQuery -node $from -min $attr`;
  				$cmd += ("-min " + $min[0] + " ");
  			if (`attributeQuery -node $from -maxExists $attr`){
  				float $max[] = `attributeQuery -node $from -max $attr`;
  				$cmd += ("-max " + $max[0] + " ");
  			$cmd += ("-dv " + $val + " " + $ln_to);
  			eval $cmd;
  		// strings
  		if ( $attrType == "string" ){
  			string $val = `getAttr ($from + "." + $attr)`;
  			addAttr -ln $attr -dt "string" $ln_to;
  			setAttr -type "string" ($to + "." + $attr) $val;
  		// floats (doubles)
  		if ( $attrType == "double" ) {
  			float $val = `getAttr ($from + "." + $attr)`;
  			string $cmd = ("addAttr -ln " + $attr + " -at double ");
  			if (`attributeQuery -node $from -minExists $attr`){
  				float $min[] = `attributeQuery -node $from -min $attr`;
  				$cmd += ("-min " + $min[0] + " ");
  			if (`attributeQuery -node $from -maxExists $attr`){
  				float $max[] = `attributeQuery -node $from -max $attr`;
  				$cmd += ("-max " + $max[0] + " ");
  			string $parent[] = `attributeQuery -node $from -listParent $attr`;
  			if (`size $parent` == 1){
  				$cmd += ("-p " + $parent[0] + " ");
  			$cmd += ("-dv " + $val + " " + $ln_to);
  			eval $cmd;
  		// Booleans
  		if ( $attrType == "bool" ){
  			int $val = `getAttr ($from + "." + $attr)`;
  			addAttr -ln $attr -at "bool" $ln_to;
  			setAttr ($to + "." + $attr) $val;
  		// enumerated lists
  		if ( $attrType == "enum" ){
  			int $val = `getAttr ($from + "." + $attr)`;
  			string $enumList[] = `attributeQuery -node $from -listEnum $attr`;
  			string $enum = ($enumList[0] + ":");
  			addAttr -ln $attr -at "enum" -en $enum $ln_to;
  			setAttr ($to + "." + $attr) $val;

Let me know if it doesn’t work for some reason. Didn’t get to test it will all node types.


Hey mayaScripters! Check this out:

a script that can freeze scale even if there are animation plugs attached:
Wanted this for years :]

	string $sel[] = `ls -sl -tr -l`;
	string $children[], $curve, $curves[3], $tIn, $cOut;
	for ($t in $sel)
		$curves = {};
		string $ds[3] = {"x","y","z"};
		// browse each scale-plug, disconnect anims, scale 1/x, remember them
		for ($i = 0; $i < 3; $i++)
			$tIn = ($t + ".s" + $ds[$i]);
			$curve = getStringArrayItem0(`keyframe -q -name -at $tIn`);
			if ($curve != "")
				$cOut = $curve + ".output";

				disconnectAttr $cOut $tIn;
				scaleKey -iub false -vs (1 / getAttr($cOut)) -vp 0 $curve;
			$curves[$i] = $curve;

		// now freeze scale
		makeIdentity -apply 1 -t 0 -r 0 -s 1 -n 0 $t;

		// reattach the anim curves if there are any
		for ($i = 0; $i < 3; $i++)
			$tIn = ($t + ".s" + $ds[$i]);
			$curve = $curves[$i];
			if ($curve != "")
				$cOut = $curve + ".output";

				connectAttr $cOut $tIn;

I will make it hierarchy aware another time…


Hi friends great efforts by all , well i need small help from u guys ,

m planing to list all the render layers from current scene n print them on MEL window UI , n so dat i can copy all the renderlayers once instead of doing it one by one ,

i am able to get all renderlayers printed in script editor by ls sl -type renderLayers technique ,
but wondering if i can get dem all printed one some MEL window interface so dat i can copy dem ,

my first post looking for some help , thanks all


eh? why can’t you just copy from the script editor…?


yes i can copy from de script editor , but the person who dont know sripts diffcult for dem n explain dem everytime , so i want to make a proper tool interface whr one can click button n all render layers get printed in window so dat it would b easy for everybody to just copy the data .

handleScriptEditorAction "maximizeHistory";
handleScriptEditorAction "clearHistory";
print "//Curent Render Layers

print `ls -type "renderLayer"`;

try that :thumbsup:


good one … but friend i reached till here v can get output printed in script editor ,
but i want to make a interface for this script , which i am planing , with one window which would have one button which clicks , so that it prints the all render layers in that window itself in some text fields or something similar , so that we can copy ,
I am getting lots of ways to get all render layer printed in scrip editor but want to make a interface window ,
hope you getting my point , m newbie so you guys can suggest is dis possible to do so ,

thanks ,

help -doc text;

should be able to get all you need to know from there :slight_smile:


hey ya i tried that , if at all i could able to get my print output render layers in window but not able to copy anything , so need to find some output layout in which i can also copy data which it prints , similar like text fields but it just take input data… m vry confused , or anybody can try to make script for this …


if you are hoping to “Copy” by RMB-clicking and picking “Copy” you are going to be disappointed. Only the script Editor allows this. All other copying is done by pressing Ctrl-C (on windows anyway) and that should work on any text-based UI fields.

I assume you already know that basics of making a window and layouts Harjit?

You should really start a proper post of your own on this.



Thnks for all your comments , i know i can copy ctrl+c in text fields , and i also know the basic of window making and layout , but problem is i am not able to get what i am looking for
not able to get render layers printed on UI interface and then copy it ,

i am sori but first time i am talking help from forums , so plz forgive any mistakes ,


This script creates shelf buttons and procedures for copying the translate, rotate, scale and pivot point of one object onto multiple objects. This script is based on original scripts by ewerybody and is my first finished script :slight_smile:

I’ve attached it as a zip file, as it consists of 2 scripts, a readme and 4 icon image.s

Let me know if there are any issues or have any feedback :smiley:

Note: This script is optimized for Maya 2011