mel ToggleWorldNormalManip.md

00_ToggleWorldNormalManip.md
移動ツールを使っているときに、法線軸とワールド軸を切り替える
ToggleWorldNormalManip.mel
{
    if(`manipMoveContext -q -mode Move` != 2)
        manipMoveContext -e -mode 2 Move;
        else
        manipMoveContext -e -mode 3 Move;
}

mel detachSeparate.md

00_detachSeparate.md
https://www.highend3d.com/maya/script/detachseparate-mel-for-maya

面選択したオブジェクトを別オブジェクトとして分離する
detachSeparate.mel
//detachSeparate.mel v1.1
//Jeff Dobson 7/2/01
//jeffdobs@swbell.net
//
//DESCRIPTION: This script will effectively detach and separate selected faces from a poly mesh.
//Advantages of this script over Maya's built in detach/separate is that this script doesn't create
//a third parent node.  It also allows you to break off only the selected faces as opposed to exploding
//every sub-mesh of an object.
//SETUP:  Create a shelf button or hotkey with the command   detachSeparate;
//ICON:  detachSeparate.bmp
//HISTORY: 7/20/01 - v1.1 -- Changed duplicate command to -un from -rr.  Fixes bug that leaves an extra
        // shape node when script is run on an object with an extrude in its history.


global proc detachSeparate()
{
	string $nameSplitSkip[];
	string $faceNum[];
	string $temp[];
	string $newObj[];
	string $newFaceSel[];

	string $origFaceSel[] = `filterExpand -ex 1 -sm 34`;
	string $origObjShape[] = `listRelatives -p $origFaceSel`;
	string $origObj[] = `listRelatives -p $origObjShape`;
	
	//Get my selected face numbers into $faceNum
	for ($step = 0, $skip = 0; $step < size($origFaceSel); $step++, $skip++)
	{
		tokenize $origFaceSel[$step] "." $temp;
		$nameSplitSkip[$skip] = $temp[0];
		$skip++;
		$nameSplitSkip[$skip] = $temp[1];
		clear $temp;
	}
	
	for ($step2 = 0, $skip2 = 1; $step2 < (size($nameSplitSkip)/2); $step2++, $skip2 = $skip2 + 2)
	{
		$faceNum[$step2] = $nameSplitSkip[$skip2]; //every other value	
	}
	
	//Dupe original object
	$newObj = `duplicate -un $origObj[0]`;
	delete -ch $newObj[0];
	string $newAllFaces[] = `ls ($newObj[0] + ".f[*]")`;
	
	//Make new array for face selection on $newObj
	for ($step3 = 0; $step3 < size($faceNum); $step3++)
	{
		$newFaceSel[$step3] = ($newObj[0] + "." + $faceNum[$step3]);
	}
	
	//Delete original face selection
	delete $origFaceSel;
	
	//Delete inverse face selection on duplicate
	select -r $newAllFaces;
	select -d $newFaceSel;
	delete;
	select -r $newObj[0];
}

mel exec_py.mel

exec_py.mel
global proc exec_python_file(string $py_path){
    string $cmd[];

    $fileId=fopen($py_path,"r");
    string $nextLine = `fgetline $fileId`;
    while ( size( $nextLine ) > 0 ) {
	    appendStringArray $cmd {$nextLine} 1;
	    $nextLine = `fgetline $fileId`;
    }

    string $exec_cmd = stringArrayToString($cmd,"\n");
    python $exec_cmd; 
}

mel Maya迭代关键帧偏移器

Maya迭代关键帧偏移器

keyframe_offsetter.mel
http://blog.cameronleger.com/mel/offsetkeys/

MAYA ITERATIVE KEYFRAME OFFSETTER
This is a small MEL script to copy, paste, and offset keyframes iteratively on multiple objects. First, copy the keyframes from the first object. Then, select the rest of the objects to paste the animation to. The offset value is how many frames to offset the animation for each object. The start value is the frame the entire animation should start on. For each object selected in the order that they are selected, it pastes the animation offset by the amount you chose per each object.
To use this script, you should paste the following into the MEL section of the Script Window, and then execute the code. Or you could drag the selected code in the MEL tab to the Shelf to create a shelf item for it.


if ( `window -exists window` )
	deleteUI window;
window -title "keyOffset" window;
columnLayout;
int $val1 = 0;
int $val2 = 0;
intSliderGrp -label "FrameOffset" -minValue 0 -maxValue 100  -field true -v $val1 refle1;
intSliderGrp - label "StartFrame" -minValue 0 -maxValue 1600 -field true -v $val2 refle2;
rowColumnLayout -numberOfColumns 3;
button -l "EXIT" -c exit;
button -l "COPY" -c copy;
button -l "PASTE" -c sel;
showWindow window ;

proc sel() {
	int $value = `intSliderGrp -q -v refle1`;
	int $value2 = `intSliderGrp -q -v refle2`;
	int $selIndex;
	string $objs[] = `ls -sl`;
	int $offset;
	int $timestart;	for ($selIndex = 0; $selIndex < size($objs); $selIndex++){
		$offset += $value;
		$timestart = $value2 - $value;
		select $objs[$selIndex];
		eval ("pasteKey -time "  +  $timestart +  " -float 0 -option merge -copies 1 -connect 0 -timeOffset "  +  $offset +  " -floatOffset 10 -valueOffset 0") ;
	}};

proc copy() {
	copyKey -time ":" -hierarchy below -controlPoints 0 -shape 1 ;
}

proc exit() {
	deleteUI window;
};

mel 删除字符中的垃圾

删除字符中的垃圾

deljunk.mel
proc deljunk(string $rootJointName, string $characterName)
{
    select $rootJointName;
    select -hi; 
    $SHJoints = `ls -sl -type "joint"`;
    string $each;
    for ($each in $SHJoints)
    {
        delete -constraints $each;
    }

    select $rootJointName;
    parent -w;
    select -hi RRM_MAIN;
    $rig = `ls -sl`;
    lockNode -lock off $rig;
    delete $characterName;
    select `ls -typ joint`;
    select -tgl `ls -typ mesh`;
    InvertSelection;
    doDelete;
} 

deljunk("*SH_ROOTJ", "apparatus");

mel 示例mel脚本

示例mel脚本

sample.mel
// Made by Yohan Kim 1/2/2016

global proc int IsInfantry(string $characterName)
{
    return $characterName == "apinfantry" || $characterName == "flamethrower";
}

global proc int IsFlamethrower(string $characterName)
{
    return ($UnitName_A2F == "apinfantry" ||  $UnitName_A2F == "missileinfantry" ||  $UnitName_A2F == "sniper" ||  $UnitName_A2F == "tankkiller");
}

global proc int IsMagPulse(string $characterName)
{
    return ($UnitName_A2F == "blackwatch" ||  $UnitName_A2F == "hastatussniper" ||  $UnitName_A2F == "hivegunner" ||  $UnitName_A2F == "isomerranger" ||  $UnitName_A2F == "shocktrooper" ||  $UnitName_A2F == "sonicravager");
}

global proc int IsMiniGunner(string $characterName)
{
    return ($UnitName_A2F == "assaultinfantry" ||  $UnitName_A2F == "attrooper" ||  $UnitName_A2F == "grenadier" ||  $UnitName_A2F == "ranger");
}

global proc int IsSwarmTrooper(string $characterName)
{
    return $UnitName_A2F == "distruptor" || $UnitName_A2F == "aircleaner" ||  $UnitName_A2F == "blastcannoner" ||  $UnitName_A2F == "disruptorranger" ||  $UnitName_A2F == "flechetteinfantry" ||  $UnitName_A2F == "greenwavesniper" ||  $UnitName_A2F == "impactenforcer" ||  $UnitName_A2F == "railgunsniper" ||  $UnitName_A2F == "hivegunner"  ||  $UnitName_A2F == "cloudshredder" ||  $UnitName_A2F == "infernotrooper" );
}

proc characterName()
{
    if (IsFlamethrower(UnitName_A2F)) 
    {
        $Group_Infantry_for_path = $flamethrower_Name;
    }

    else if (IsMagPulse(UnitName_A2F)) 
    {
        $Group_Infantry_for_path = $magpulseranger_Name;
    }

    else if (IsMiniGunner(UnitName_A2F)) 
    {
        $Group_Infantry_for_path = $minigunner_Name;
    }

    else if (IsSwarmTrooper(UnitName_A2F)) 
    {
        $Group_Infantry_for_path = $swarmtrooper_Name;
    }

    else 
    {
        $Group_Infantry_for_path = $UnitName_A2F;
    }
}

mel setDrivenKey.mel

setDrivenKey.mel
setDrivenKeyframe -itt "linear" -ott "linear" -dv 15  -v $value -cd ($driver + ".rotateY") ($driven + ".translateZ");

mel selectCV.mel

selectCV.mel
select -r "curve1.cv[*]";

mel physicalLight2PointLight.mel

physicalLight2PointLight.mel
//Here is a small script to automate the creation of a point light. It creates a point light with a connected Physical Light. Alternatively it connects a physical Light to the selected Lights.

proc string create_Physical_Light(int $interior){
 string $sel_lights[] = `ls -sl -dag -leaf -lights`;
 string $phyLight = `mrCreateCustomNode -asUtility "" physical_light`;
 string $blackbody;
 
 if ($interior) {
 $blackbody = `mrCreateCustomNode -asUtility "" mib_blackbody`;
 } else {
 $blackbody = `mrCreateCustomNode -asUtility "" mib_cie_d`;
 }
 setAttr ($blackbody+".intensity") 1000;
 connectAttr -force ($blackbody+".outValue") ($phyLight+".color");
 
 if (0 == size ($sel_lights) ){
 $sel_lights[0] = `pointLight`;

}
 
 for ($light in $sel_lights){
 connectAttr -force ($phyLight+".message") ($light+".miLightShader");
 }
 return $phyLight;
}
 
create_Physical_Light(false);

mel 这是一个自动创建点光源的小脚本。它创建了一个连接物理光源的点光源。或者它

这是一个自动创建点光源的小脚本。它创建了一个连接物理光源的点光源。或者,它将物理光连接到选定的灯光。

physicalLight2PointLight.mel
//Here is a small script to automate the creation of a point light. It creates a point light with a connected Physical Light. Alternatively it connects a physical Light to the selected Lights.

proc string create_Physical_Light(int $interior){
 string $sel_lights[] = `ls -sl -dag -leaf -lights`;
 string $phyLight = `mrCreateCustomNode -asUtility "" physical_light`;
 string $blackbody;
 
 if ($interior) {
 $blackbody = `mrCreateCustomNode -asUtility "" mib_blackbody`;
 } else {
 $blackbody = `mrCreateCustomNode -asUtility "" mib_cie_d`;
 }
 setAttr ($blackbody+".intensity") 1000;
 connectAttr -force ($blackbody+".outValue") ($phyLight+".color");
 
 if (0 == size ($sel_lights) ){
 $sel_lights[0] = `pointLight`;

}
 
 for ($light in $sel_lights){
 connectAttr -force ($phyLight+".message") ($light+".miLightShader");
 }
 return $phyLight;
}
 
create_Physical_Light(false);