MEL
http://help.autodesk.com/view/MAYAUL/2018/JPN/?guid=GUID-579A6D9F-CB41-4CD9-B9D7-3DB1FD33735D
MELはスクリプトエディタで実行します。
メニュー > 一般エディタ > スクリプトエディタ または右下位置のスクリプトエディタ
コマンドリファレンス
https://help.autodesk.com/cloudhelp/2018/JPN/Maya-Tech-Docs/Commands/index.html
スクリプトエディタの下部ペインにMELスクリプトを入力し、そのスクリプトを選択し、Ctrl+Enterキーを押すと実行します。
以下を下部ペインに入力し、実行してみましょう。ポリゴンの分割ツールが起動し、ツール設定が表示されます。
行の最初に//を付けるとその行のスクリプトは実行されません。
//ポリゴン分割ツール(ツールウインドウを表示)
SplitPolygonToolOptions;
上ペインをクリアする場合は、スクリプトエディタの編集 > ヒストリのクリアを選択します。下ぺインのクリアは、編集 > 入力のクリアを選択します。
★スクリプトエディタのヒストリ> すべてのコマンドのエコーを選択しチェックオンにすると、ほぼすべてのコマンドのヒストリ(履歴)がMELスクリプトで表示されますので
MELスクリクト作成の参考に使用できます。上ペインのヒストリのスクリプトを選択し、下ペインにドラッグ&ドロップするとヒストリのスクリプトを下ペインにコピーすることができます。
以下のMELスクリクトでは選択した頂点の中心の座標、Xは$C_X、Yは$C_Y、Zは$C_Zに代入し、move等の座標を使用したスクリプトで使用することができます。
//選択した頂点を$selVEX1[]に入れておく。
string $selVEX1[]= `ls -sl`;
//頂点選択モードからオブジェクト選択モードに切り替える。
SelectToggleMode;changeSelectMode -object;
//選択されているオブジェクトを$selOBJ1[]に入れておく。
string $selOBJ1[]= `ls -sl`;
//頂点選択モードに切り替える。
SelectToggleMode;
//$selVEX1[]全体を選択する。
select -r $selVEX1;
//複数頂点の中心の座標を取得するためクラスタを作成する。
CreateCluster;
//CSo_に名前を変更する。この名前は他で使用しないでください!
rename "CSo_";
//クラスタ中心座標が複数頂点の中心の座標ですので、Xは$C_X、Yは$C_Y、Zは$C_Zに入れます。
float $C_X = `getAttr CSo_Shape.originX`;
float $C_Y = `getAttr CSo_Shape.originY`;
float $C_Z = `getAttr CSo_Shape.originZ`;
//クラスタは使用しませんのでCSo_を選択し削除します。
select -r CSo_;
doDelete;
このスクリプト実行後、何も起きませんが、複数頂点の中心の座標、Xは$C_X、Yは$C_Y、Zは$C_Zに代入された状態になります。
ロケータなどを選択し以下のスクリプトを実行すると選択した頂点の中心に移動します。
関節位置などを決めるときに便利です。
move -a $C_X $C_Y $C_Z ;
//モデリングするためのツールをまとめたボタン集のウインドウを作成するMEL
window -title "モデリング" -rtf 1;
columnLayout -adjustableColumn true;
gridLayout -numberOfColumns 5 -cellWidth 65 -cellHeight 20;
button -label "Object" -command "changeSelectMode -object;";
button -label "Vertex" -command "SelectVertexMask";
button -label "Edge" -command "SelectEdgeMask;";
button -label "Face" -command "SelectFacetMask;";
button -label "UV" -command "SelectUVMask;";
button -label "OBJECT" -command "manipMoveContext -e -mode 0 Move;manipScaleContext -e -mode 0 Scale;";
button -label "LOCAL" -command "manipMoveContext -e -mode 1 Move;manipRotateContext -e -mode 0 Rotate;manipScaleContext -e -mode 1 Scale;";
button -label "WORLD" -command "manipMoveContext -e -mode 2 Move;manipRotateContext -e -mode 1 Rotate;manipScaleContext -e -mode 2 Scale;";
button -label "NORMAL" -command "manipMoveContext -e -mode 3 Move;manipScaleContext -e -mode 3 Scale;";
button -label "選択面方向" -command "manipMoveContext -edit -mode 10 Move;";
button -label "微調整オフ" -command "strsTweakMode false;";
button -label "微調整オン" -command "strsTweakMode true;";
button -label "シンメトリオフ" -command "ResetReflectionOptions;";
button -label "シンメトリX" -command "reflectionSetMode worldx;";
button -label "ミラー" -command "polyMirrorFace -cutMesh 1 -axis 0 -axisDirection 1 -mergeMode 1 -mergeThresholdType 1 -mergeThreshold 0.001 -mirrorAxis 2 -mirrorPosition 0 -smoothingAngle 30 -flipUVs 0 -ch 1;\n";
button -label "Loopselect" -command "SelectContiguousEdges";
button -label "CutTool" -command "dR_multiCutTool;";
button -label "Splitoption" -command "SplitEdgeRingToolOptions";
button -label "MergeTool" -command "MergeVertexTool";
button -label "Append" -command "setToolTo polyAppendFacetContext ; polyAppendFacetCtx -e -pc `optionVar -q polyKeepFacetsPlanar` polyAppendFacetContext";
setParent..;
showWindow;
-command ""の""の中に入るスクリプトは、shelfアイコンにした後、そのshelfのファイル(Documents\maya\2018\ja_JP\prefsの中のmelデータ)を開き、記載されているスクリプトをコピー&ペーストすれば
ミラー機能の以下のスクリプトを例にとると
polyMirrorFace -cutMesh 1 -axis 0 -axisDirection 1 -mergeMode 1 -mergeThresholdType 1 -mergeThreshold 0.001 -mirrorAxis 2 -mirrorPosition 0 -smoothingAngle 30 -flipUVs 0 -ch 1;
そのshelfのファイルを開き、記載されているスクリプトをコピー&ペーストすれば以下のようになります。
button -label "ミラー" -command "polyMirrorFace -cutMesh 1 -axis 0 -axisDirection 1 -mergeMode 1 -mergeThresholdType 1 -mergeThreshold 0.001 -mirrorAxis 2 -mirrorPosition 0 -smoothingAngle 30 -flipUVs 0 -ch 1;\n";