MEL scripts


#61

Hi all,

here is my small Script for creating different nurbs control objects.

//-------------------------------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------------------------------------------//
// SCRIPT: nControlMaker.mel
// AUTHOR: Paul Dreisen
// pauldryzen@web.de
// DATE: December 28, 2002
//
// DESCRIPTION: This script can be used to create controlobjects, which are build out of nurbscurves.
//------------------------------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------------------------------------------//

// start of script

global proc nControlMaker ()
{
// delete existing window

if ( window -exists nCtrl )
deleteUI -window nCtrl;

// create window and layout

window -title “nCtrl” -w 154 -sizeable 0 nCtrl;
columnLayout;

// create buttons

button -l “Box” -c nBox -w 145;
button -l “Box2” -c nBox2 -w 145;
button -l “Locator” -c nLoc -w 145 ;
button -l “Sphere” -c nSphere -w 145 ;
button -l “CLOSE” -c “deleteUI nCtrl” -w 145;

showWindow nCtrl;
}

//-------------------------------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------------------------------------------//

// creation process for the nurbsLocator

global proc nLoc()

{
createNode nurbsCurve;
setAttr -k off “.v”;
setAttr “.cc” -type “nurbsCurve”
1 9 0 no 3
10 0 1 2 3 4 5 6 7 8 9
10
0 1 0
0 0 0
-1 0 0
0 0 0
0 0 -1
0 0 1
0 0 0
1 0 0
0 0 0
0 -1 0
;
pickWalk -d up;
}
//-------------------------------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------------------------------------------//

// creation process for the nurbsBox2

global proc nBox2()
{
createNode nurbsCurve;
setAttr -k off “.v”;
setAttr “.cc” -type “nurbsCurve”
1 13 0 no 3
14 0 1 2 3 4 5 6 7 8 9 10 11 12 13
14
0 1.0504534244537354 0
-0.5 0 0.5
0 -1.0504534244537354 0
-0.5 0 -0.5
0 1.0504534244537354 0
0.5 0 -0.5
0 -1.0504534244537354 0
0.5 0 0.5
0 1.0504534244537354 0
0.5 0 -0.5
0.5 0 0.5
-0.5 0 0.5
-0.5 0 -0.5
0.5 0 -0.5
;
pickWalk -d up;
}

//-------------------------------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------------------------------------------//

// creation process for the nurbsBox

global proc nBox()

{
createNode nurbsCurve;
setAttr -k off “.v”;
setAttr “.cc” -type “nurbsCurve”
1 15 0 no 3
16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
16
-0.5 0.5 -0.5
0.5 0.5 -0.5
0.5 0.5 0.5
-0.5 0.5 0.5
-0.5 0.5 -0.5
-0.5 -0.5 -0.5
-0.5 -0.5 0.5
-0.5 0.5 0.5
-0.5 -0.5 0.5
0.5 -0.5 0.5
0.5 0.5 0.5
0.5 -0.5 0.5
0.5 -0.5 -0.5
0.5 0.5 -0.5
0.5 -0.5 -0.5
-0.5 -0.5 -0.5
;
pickWalk -d up;
}

//-------------------------------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------------------------------------------//

// creation process for the nurbsSphere

global proc nSphere()

{
createNode nurbsCurve;
setAttr -k off “.v”;
setAttr “.cc” -type “nurbsCurve”
1 48 0 no 3
49 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
49
0 1 0
2.8102721927325547e-008 0.92387950420379639 -0.3826833963394165
5.1927056432532481e-008 0.70710676908493042 -0.70710670948028564
6.7845967066659796e-008 0.38268342614173889 -0.92387938499450684
7.3435948877431656e-008 0 -0.99999988079071045
6.7845967066659796e-008 -0.38268342614173889 -0.92387938499450684
5.1927056432532481e-008 -0.70710676908493042 -0.70710670948028564
2.8102721927325547e-008 -0.92387950420379639 -0.3826833963394165
0 -1 0
-9.8768948575411741e-009 -0.92387950420379639 0.38268342614173889
-1.8250119637741591e-008 -0.70710676908493042 0.70710670948028564
-2.384493136275978e-008 -0.38268342614173889 0.92387944459915161
-2.5809567816281742e-008 0 0.99999994039535522
-2.384493136275978e-008 0.38268342614173889 0.92387944459915161
-1.8250119637741591e-008 0.70710676908493042 0.70710670948028564
-9.8768948575411741e-009 0.92387950420379639 0.38268342614173889
0 1 0
0.38268345594406128 0.92387950420379639 0
0.70710676908493042 0.70710676908493042 0
0.92387950420379639 0.38268342614173889 0
1 0 0
0.92387950420379639 -0.38268342614173889 0
0.70710676908493042 -0.70710676908493042 0
0.38268345594406128 -0.92387950420379639 0
0 -1 0
-0.3826833963394165 -0.92387950420379639 -1.8225827957962792e-008
-0.70710670948028564 -0.70710676908493042 -3.367693679479089e-008
-0.92387938499450684 -0.38268342614173889 -4.4001033927543176e-008
-0.99999988079071045 0 -4.7626379284793074e-008
-0.92387938499450684 0.38268342614173889 -4.4001033927543176e-008
-0.70710670948028564 0.70710676908493042 -3.367693679479089e-008
-0.3826833963394165 0.92387950420379639 -1.8225827957962792e-008
0 1 0
2.8102721927325547e-008 0.92387950420379639 -0.3826833963394165
5.1927056432532481e-008 0.70710676908493042 -0.70710670948028564
6.7845967066659796e-008 0.38268342614173889 -0.92387938499450684
7.3435948877431656e-008 0 -0.99999988079071045
0.5 0 -0.86602526903152466
0.86602532863616943 0 -0.49999988079071045
1 0 0
0.86602538824081421 0 0.5
0.49999997019767761 0 0.86602538824081421
-2.5809567816281742e-008 0 0.99999994039535522
-0.5 0 0.86602532863616943
-0.86602532863616943 0 0.49999991059303284
-0.99999988079071045 0 -4.7626379284793074e-008
-0.86602526903152466 0 -0.49999997019767761
-0.49999988079071045 0 -0.86602532863616943
7.3435948877431656e-008 0 -0.99999988079071045
;
pickWalk -d up;

}

// end of script

//-------------------------------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------------------------------------------//
// Copyright Paul Dreisen 2002
//-------------------------------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------------------------------------------//


#62

here is an update for UI_melCmdFinder.mel by Warpcat

paste the code in the Script Editor input field, select it and MMB-drag to shelf and you are ready to search :smiley:


///////////////////////////////////////////////////////////////////////////////// 
// UI_melCmdFinder.mel 
// Author: Warpcat 
//
// update by Alin Sfetcu (Sanctuary) on 28-dec-2002
//   	[email]snct@mymail.ro[/email]
//	http://www.sanctuary.ro (temp closed)
//
// Description 
// ----------------------
// A little window that opens/search the help documentation. 
//
// Usage:
// ----------------------
// Type the mel command you want to find in the text box and use the Enter key. 
//
// Know BUGS:
// ----------------------
// - to do a second search of the same keyword in the same session you must
// refresh then textbox content. I`ve try to fix this using mel without success,
// seems that the "boolean change state" of the text box is changed only on user
// input, not script input.
//
// solution 1 - add an space and delete it
// solution 2 - close the script and open it again
//
// Updates:
// ----------------------
// - fixed the two buttons commands;
// - added a feedback field;
//			(user get a visual notification when keyword is not found);
///////////////////////////////////////////////////////////////////////////////// 

global proc UI_melCmdFinder() 
{ 
	if ( `window -exists UI_melCmdFinder` ) { deleteUI UI_melCmdFinder; 	}

	window -t "MEL Command Finder Window" -rtf 1 UI_melCmdFinder; 

	columnLayout -adj 1; 
		textFieldGrp 
                            -l "Mel Command Search:" 
                            -cc EP_showMelHelp
                            -ann "Type the MEL command press the Enter key." 
                                   helpField; 
		separator -h 10;
		text -l "" feedback;
		separator -h 10;
		button -l "Open Mel Command Reference Library" -c EP_showMelLibrary; 
		button -l "Open Node and Attribute Refernce Library" -c EP_showNodeLibrary; 
	showWindow; 
} 

global proc EP_showMelHelp() 
{ 
	string $helpCommand = `textFieldGrp -q -tx helpField`; 

	if ( !(catch (`help -doc $helpCommand`)) ) {
		text -edit -label "" feedback;
	} else {
    		text -edit -label ( "\"" + $helpCommand + "\" - command not found in Help files !") feedback;
	}
} 

global proc EP_showMelLibrary() 
{ 
	showHelp -docs "Commands/index_letters.html"; 
} 

global proc EP_showNodeLibrary() 
{ 
	showHelp -docs "Nodes/index_letters.html"; 
}

UI_melCmdFinder;

hope you enjoy it, and tkx Warpcat for the ideea, hope you will not be offended by this update


#63

nice script pauldryzen

btw i`ve release a new update for camSwitcher v4.6 (hosted on highend3d), the script is way to big to put it in here, give it a try

tkx


#64

Here is another script I made.

Have fun :slight_smile:

//-------------------------------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------------------------------------------//
// SCRIPT: attrMaker
// AUTHOR: Paul Dreisen
// pauldryzen@web.de
// DATE: December 29, 2002
//
// DESCRIPTION: This script can be used to add extra attributes to all selected objects.
// Just put the whole Script into the shelf
//------------------------------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------------------------------------------//

// start of script

window -title “attribute Maker” -wh 320 104 -sizeable 0 attrMaker;$form = formLayout -nd 100;

$col = columnLayout -adj true;
textFieldGrp -label “Enter attribute name here” -cw 2 160 attrName; floatFieldGrp -nf 2 -label “Enter Min/Max here” -v1 -5 -v2 10 attrMinMax;
setParent $form;
$b1 = button -label "Go" -command "addAttrCallback";
$b2 = button -label "Close" -command "deleteUI attrMaker";

formLayout -edit
-attachForm $col “top” 5
-attachForm $col “left” 5
-attachForm $col “right” 5
-attachNone $col “bottom”

-attachNone $b1 "top"
-attachForm $b1 "left" 5
-attachPosition $b1 "right" 2 50
-attachForm $b1 "bottom" 5

-attachNone $b2 "top"
-attachPosition $b2 "left" 2 50 
-attachForm $b2 "right" 5
-attachForm $b2 "bottom" 5

$form;

showWindow attrMaker;

global proc addAttrCallback() { string $attr = textFieldGrp -q -text attrName; float $min = floatFieldGrp -q -v1 attrMinMax; float $max = floatFieldGrp -q -v2 attrMinMax;

if (size(`ls -sl`))
{ 	string $sel[] = `ls -sl`;
for ($obj in $sel) 
	{ 		addAttr -ln $attr -at double -dv 0 -min $min -max $max -keyable true $obj;
	}
}
	else
{
	warning "no object selected, please select one";
} }

// end of script

//-------------------------------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------------------------------------------//
// Copyright Paul Dreisen 2002
//-------------------------------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------------------------------------------//


#65

Byron’s Automatic Unwrap Tools

I made a script that allows to automatically unwrap a polygonal object.

You define the cuts, and/or create special Zones to control the Flow of the UVMesh und click a Button … et voilà .

You can download it here because its to big to post it:

http://www.highend3d.com/maya/mel/?section=polygon#2075

Bests
Sebastian


#66

my pointconstraint. let the object stays where it was. just select all targets, shift select the object, run the script.

dwPointConst


#67

Hi,
This script will allow you to generate, from your base mesh, a “smoothed” object with “smoothed out” uvs.
It’s a beta version because there are limitations. please refer to the readme.txt

French web page:

http://perso.wanadoo.fr/coyhot/Code_SmoothUV.htm

Direct download links ( readme.txt in english )

SmoothUV v.0.9b for Maya 4.0

SmoothUV v.0.9b for Maya 4.5


#68

a couple of useful tools for doing belnd shapes for character animation:


#69

hey guys
just wondering if anybody can help me out with this i am looking for a script called --jsOrientJointUI.mel-- i cant find it anywhere
the script helps in aligning the joint orientation during character setup
thanks in advance
code_z3@yahoo.com


#70

for any body interested in facial animation

http://www.supersnail.com/port/faces/2index.html


#71

You can get the script here:

www-viz.tamu.edu/students/gavin/617/jointPage4.htm

although, the site seems down at the moment. Good article too…

Jay


#72

thankx jay
but dude that site has been down for ages
does any body know any more sites whr i can get this script from

Disce quasi semper victurus; vive quasi cras moriturus"
[Learn as if you were going to live forever; live as if you were going to die tomorrow.]


#73

nope, not ages, and matter of fact, it seems to be back up now. give it another try…

Jay


#74

Hey,

I just have a question concerning MEL.

I would like to make a mel script that executes when I select an object. So basically when I select a locator, it executes a script. How would I go about doing this? Is it possible?

Please help!! Thanks.

loked


#75

There is an MEL-Command which creates a “scriptJob”. Everytime a certain event occours, your script will be executed.

I think, the “selection changed” event will be fine for you.

Please refer to the manual for further information :slight_smile: .

Bests
Byron


#76

Thats exactly what I was looking for. Thanks ALOT:bounce:


#77

Okay, DUMB question:

Where is the SCRIPTS directory? I ask because I have the following scripts folders:

C:\Documents and Settings\Steve\My Documents\maya\4.5\scripts
C:\Documents and Settings\Steve\My Documents\maya\scripts
C:\Program Files\AliasWavefront\Maya4.5\scripts
C:\Program Files\AliasWavefront\mental ray for Maya 1.5\scripts

I assume the first folder is the one you are referring to, but why does AW keep reusing this directory name? Makes it confusing.

-=STZ=-


#78

Originally posted by stunndman
[B]i thought i pass this on

"…

This script detects and removes mRay for Maya nodes from your scene.

Copy the lines below in a text file and save it as mrayNodesCleanup.mel in
your scripts folder.
Start maya, load the scene and type mrayNodesCleanup in the command line.
A dialog should appear.

Hope this helps!

M-

Start from the next line >>>>>>>>>>>>

[/B]

Hi Stunndman

I tried to delete the MR nodes from my files, but it aint working for me. I get this >>>>// Error: Cannot find procedure “mrayNodesCleanup”. //

I put the .mel file in the G:/applications/aliaswavefront/maya 4.5/scripts

Thanks in advance

clarix


#79

due to request i have looked up the original thread and packaged the latest version of the script which was posted by Michele Borghi - i will post it on highend3d.com but meanwhile you can get it from http://alienbit.com/shared/GOARemoveMentalRayNodes.mel

// Description: Removes Mental Ray for Maya 1.5 nodes from the loaded scene. The MR 1.5 for Maya (Mayatomr.mll) plugin has be loaded.
// Usage: Open your scene and run GOARemoveMentalRayNodes in your script editor. Save your scene - et voilà.


#80

[QUOTE]Originally posted by stzaske
[B]Okay, DUMB question:

Where is the SCRIPTS directory? I ask because I have the following scripts folders:

C:\Documents and Settings\Steve\My Documents\maya\4.5\scripts
C:\Documents and Settings\Steve\My Documents\maya\scripts
C:\Program Files\AliasWavefront\Maya4.5\scripts
C:\Program Files\AliasWavefront\mental ray for Maya 1.5\scripts

I assume the first folder is the one you are referring to, but why does AW keep reusing this directory name? Makes it confusing.

-=STZ=- [/B][/QUOTE

I kinda gave up, is not workin for me] :thumbsdow