コメントの部分は読み飛ばされて、実行されません。
コメントは 2 種類あります。
//
/* */
matrix 以外は配列にすることができます。
if , while , do while , for の条件部分は、 0 , false , off 以外のものが与えられたときに成り立ちます。
int $x = 3;
if($x > 1)
{
print ("$x is greater than 1\n");
}
string $s = "test";
if($s == "test")
{
print ("$s is test\n");
}
int $x = 2;
switch($x)
{
case 1 :
print "$x is 1\n";
break;
case 2 :
print "$x is 2\n";
break;
default :
print "x is not 1 or 2\n";
}
string $s = "test1";
switch($s)
{
case "test1" :
print "$s is test1\n";
break;
case "test2" :
print "$s is test2\n";
break;
default :
print "x is not test1 or test2\n";
}
int $i = 0;
while($i < 3)
{
print ($i + "\n");
$i++;
}
int $i = 0;
do
{
print ($i + "\n");
$i++;
} while($i < 3)
int $i;
for($i = 0; $i < 3; $i++)
{
print ($i + "\n");
}
string $str[3] = { "aaa", "bbb", "ccc" };
for( $val in $str)
{
print($val + "\n");
}
select nurbsSphere1;
select -tgl curve1;
pathAnimation -startTimeU 0 -endTimeU 300;
[...] の部分はは省略可能です。
[global] proc [返り値の型] <手続きの名前>( [引数, ...] )
{
[MEL文]
[return 返り値;]
}
nameCommand -annotation "Make Sphere and Move"
-command "sphere; move 1 2 3;"
makeSphereAndMoveCommand;
hotkey -k "c" -ctl -name makeSphereAndMoveCommand; // Ctrl + c キーにホットキーを登録
変換される型 | |||||
---|---|---|---|---|---|
int | float | string | vector | matrix | |
int | OK | OK | OK | <<$i, $i, $i>> | NONE |
float | 整数部分 | OK | OK | <<$f, $f, $f>> | NONE |
string | 整数部分(数字でなければ0) | OK(数字でなければ0) | OK | OK(vectorかfloatでなければ0) | NONE |
vector | ベクトルの長さの整数部分 | ベクトルの長さ | 3つのfloat | OK | OK([1][3]のみ) |
matrix | ベクトルの長さの整数部分([1][3]より小さい時) | ベクトルの長さ([1][3]より小さい時) | NONE | OK([1][3]より小さい時) | OK |
値 | フォーマット | 拡張子 | 注意 |
---|---|---|---|
1 | SoftImage | .pic | * |
2 | WaveFront | .rla | * |
3 | TIFF | .tif | * |
4 | TIFF16 | .tif | * |
5 | SGI | .sgi | * |
6 | Alias | .als | * |
7 | Maya | .iff | デフォールト |
8 | JPEG | .jpg | * |
9 | PostScript | .eps | * |
10 | Maya 16 | .iff | * |
11 | Codak Cineon | .cin | * |
12 | Abekas NTSC or PAL | .yuv | * |
13 | SGI 16 | .iff | * |
19 | TARGA | .tga | * |
20 | BMP | .bmp | * |
21 | SGI MV | .mv | * |
22 | QT (QuickTime) | .mov | * |
23 | AVI | .avi | * |
30 | MACPAINT | .pntg | * |
31 | PHOTOSHOP | .psd | * |
32 | PNG | .png | * |
33 | QUICKDRAW | .pict | * |
34 | QTIMAGE | .qtif | * |
35 | DDS | .dds | * |
36 | DDS | .dds | * |
50 | IMFplugin | .img | * |
51 | Custom | .img | * |
60 | SWF | .swf | * |
61 | AI | .ai | * |
62 | SVG | .svg | * |
63 | SWFT | .swft | * |
window;
columnLayout;
button;
showWindow;
window;
columnLayout;
checkBox -label "チェック 1";
checkBox -label "チェック 2";
checkBox -label "チェック 3";
showWindow;
window;
paneLayout;
channelBox;
showWindow;
window;
paneLayout;
cmdScrollFieldExecuter;
showWindow;
window;
paneLayout;
cmdScrollFieldReporter;
showWindow;
string $pname = `createNode polySplitRing`;
window;
columnLayout;
gradientControl -h 90 -at ($pname + ".profileCurve");
showWindow;
optionVar -stringValueAppend "myCurveOptionVar" "0,1,2";
optionVar -stringValueAppend "myCurveOptionVar" "1,0,2";
window;
columnLayout;
string $gname = `gradientControlNoAttr`;
gradientControlNoAttr -e -optionVar "myCurveOptionVar" $gname;
showWindow;
window;
columnLayout -adj true;
text -label "help line";
helpLine;
showWindow;
global proc myHudButton()
{
print("pressed\n");
}
hudButton -section 6 -block 5 -visible 1 -label "HudButton"
-buttonWidth 80 -buttonShape "roundRectangle"
-releaseCommand "myHudButton()";
global proc myHudSliderProc()
{
float $val = `hudSlider -q -v myHudSlider`;
print $val;
}
hudSlider -section 2 -block 5 -visible 1 -label "myHudSlider:" -value 0
-type "int" -minValue -10 -maxValue 10
-labelWidth 80 -valueWidth 50
-sliderLength 100 -sliderIncrement 1
-pressCommand "myHudSlider()"
-dragCommand "myHudSlider()"
-releaseCommand "myHudSlider()"
myHudSliderProc;
global proc myHudSliderButtonProc()
{
float $val = `hudSliderButton -q -v myHudSliderButton`;
print $val;
}
hudSliderButton -section 5 -block 5 -visible 1
-sliderLabel "Slider:" -value 0 -type "int" -minValue -10 -maxValue 10
-sliderLabelWidth 50 -valueWidth 50 -sliderLength 100 -sliderIncrement 1
-buttonLabel "Button" -buttonWidth 60 -buttonShape "rectangle"
-buttonReleaseCommand "myHudSliderButtonProc()"
myHudSliderButton;
window;
columnLayout -adj true;
iconTextButton -style "iconOnly" -image1 "sphere.xpm" -label "球体";
iconTextButton -style "iconAndTextHorizontal" -image1 "cone.xpm" -label "コーン";
iconTextButton -style "iconAndTextVertical" -image1 "cube.xpm" -label "立方体";
showWindow;
window;
columnLayout -adj true;
iconTextCheckBox -style "iconOnly" -image1 "sphere.xpm" -label "球体";
iconTextCheckBox -style "iconAndTextHorizontal" -image1 "cone.xpm" -label "コーン";
iconTextCheckBox -style "iconAndTextVertical" -image1 "cube.xpm" -label "立方体";
showWindow;
window;
columnLayout -adj true;
iconTextRadioCollection sampleIconTextRadioCollection;
iconTextRadioButton -st "iconOnly" -i1 "sphere.xpm" -l "球体" -select;
iconTextRadioButton -st "iconAndTextHorizontal" -i1 "cone.xpm" -l "コーン";
iconTextRadioButton -st "iconAndTextVertical" -i1 "cube.xpm" -l "立方体";
showWindow;
window;
paneLayout;
image -image "c:/tmp/test.bmp";
showWindow;
window;
columnLayout;
layerButton -label "defaultLayer" -color 1.0 0.0 0.0 -select true;
layerButton -label "nextLayer" -color 0.0 1.0 0.0;
showWindow;
window;
columnLayout -adj true;
text -label "message line";
messageLine;
showWindow;
window;
columnLayout -adj true;
nodeIconButton -style "iconOnly" -command "torus" -image1 "torus.xpm";
nodeIconButton -style "iconAndTextHorizontal" -command "directionalLight" -image1 "directionallight.xpm" -label "ディレクショナルライト";
showWindow;
window;
columnLayout;
picture -image "c:/tmp/test.xpm";
showWindow;
window;
columnLayout;
radioCollection;
radioButton -label "ボタン 1" -select;
radioButton -label "ボタン 2";
radioButton -label "ボタン 3";
showWindow;
window;
columnLayout;
radioButtonGrp -numberOfRadioButtons 3
-label "位置" -select 1 -labelArray3 "X" "Y" "Z";
showWindow;
string $ramp = `createNode ramp`;
window;
columnLayout;
rampColorPort -node $ramp;
showWindow;
window;
paneLayout;
rangeControl -minRange 0 -maxRange 60 myRangeSlider;
showWindow;
window;
paneLayout;
scriptTable -rows 4 -columns 2 -label 1 "Column 1" -label 2 "Column 2";
showWindow;
window;
columnLayout -adj true;
text -label "-style default";
separator;
text -label "-style none";
separator -style "none";
text -label "-style single";
separator -style "single";
text -label "-style double";
separator -height 10 -style "double";
text -label "-style singleDash";
separator -height 10 -style "singleDash";
text -label "-style doubleDash";
separator -height 40 -style "doubleDash";
text -label "-style in";
separator -height 40 -style "in";
text -label "-style out";
separator -height 40 -style "out";
showWindow;
window;
columnLayout;
shelfLayout;
shelfButton -annotation "球体" -image1 "sphere.xpm" -command "sphere";
shelfButton -annotation "コーン" -image1 "cone.xpm" -command "cone";
showWindow;
window;
paneLayout;
switchTable;
showWindow;
window;
columnLayout;
symbolButton -image "sphere.xpm";
symbolButton -image "cube.xpm";
showWindow;
window;
columnLayout;
symbolCheckBox -image "sphere.xpm";
symbolCheckBox -image "cube.xpm";
showWindow;
window;
columnLayout;
string $shname = `shadingNode -asShader lambert`;
swatchDisplayPort -wh 64 64 -sn $shname;
attrColorSliderGrp -at ($shname + ".color");
showWindow ;
window;
columnLayout;
text -label "テキスト 1";
text -label "テキスト 2";
showWindow;
window;
paneLayout;
textScrollList -allowMultiSelection true
-append "テスト 1"
-append "テスト 2"
-append "テスト 3"
-append "テスト 4"
-append "テスト 5"
-append "テスト 6"
-selectItem "test2"
-showIndexedItem 4;
showWindow;
window;
columnLayout;
timePort;
showWindow;
window;
columnLayout;
toolCollection;
toolButton
-tool selectSuperContext
-toolImage1 selectSuperContext "aselect.xpm";
toolButton
-tool moveSuperContext
-toolImage1 moveSuperContext "move_M.xpm";
toolButton
-tool scaleSuperContext
-toolImage1 scaleSuperContext "scale_M.xpm";
showWindow;
string $name[] = `sphere`;
window;
columnLayout;
attrFieldSliderGrp -label "移動X" -min -10.0 -max 10.0 -at ($name[0] + ".tx");
showWindow;
string $sname = `shadingNode -asShader phong`;
window;
columnLayout;
attrColorSliderGrp -at ($sname + ".color");
showWindow;
string $name[] = `sphere`;
window;
columnLayout;
attrFieldGrp -label "移動 XYZ" -min -10.0 -max 10.0 -at ($name[0] + ".t");
showWindow;
string $sname = `shadingNode -asShader blinn`;
window;
columnLayout;
attrNavigationControlGrp -label "バンプマッピング" -at ($sname + ".normalCamera");
showWindow;
window;
columnLayout;
colorSliderGrp -label "色" -rgb 1 0 0;
showWindow;
window;
columnLayout;
colorIndexSliderGrp -label "インデックス カラー" -min 1 -max 31 -value 1;
showWindow;
window;
columnLayout;
colorSliderButtonGrp
-label "ラベル"
-buttonLabel "ボタン"
-buttonCommand "球体"
-rgb 1 0 0
-symbolButtonDisplay true
-columnWidth 5 25
-image "navButtonUnconnected.xpm";
showWindow;
window;
columnLayout -adj true;
floatSlider;
showWindow;
string $name[] = `sphere`;
scale 2.0 3.0 1.0;
window;
columnLayout;
floatField -value 2.0 myFloatField1;
floatSlider2 myFloatSlider2;
floatField -value 3.0 myFloatField2;
floatSlider2 -e -positionControl1 myFloatField1 -positionControl2 myFloatField2
-polarity 1 -max 5
-value1 2.0 -value2 3.0
-changeCommand1 ("setAttr " + $name[0] + ".sx")
-changeCommand2 ("setAttr " + $name[0] + ".sy") myFloatSlider2;
showWindow;
window;
columnLayout;
floatSliderButtonGrp -label "ラベル" -field true
-buttonLabel "ボタン" -symbolButtonDisplay true
-columnWidth 5 40 -image "sphere.xpm";
showWindow;
window;
columnLayout -adj true;
floatSliderGrp -field true -min 0.0 -max 10.0 -value 2.0;
showWindow;
window;
columnLayout -adj true;
floatScrollBar;
showWindow;
window;
columnLayout -adj true;
intSlider;
showWindow;
window;
columnLayout -adj true;
intSliderGrp -field true -min 0 -max 10 -value 2;
showWindow;
window;
columnLayout -adj true;
intScrollBar;
showWindow;
window;
columnLayout -adj true;
floatField;
showWindow;
window;
columnLayout;
floatFieldGrp -numberOfFields 3
-label "Value" -extraLabel "mm"
-value1 0.3 -value2 0.5 -value3 0.1;
showWindow;
window;
columnLayout -adj true;
intField;
showWindow;
window;
columnLayout;
intFieldGrp -numberOfFields 3
-label "Value" -extraLabel "mm"
-value1 3 -value2 2 -value3 1;
showWindow;
window;
columnLayout -adj true;
string $sname[] = `sphere`;
nameField -object $sname[0];
showWindow;
window;
paneLayout;
scrollField -text "scrollField";
showWindow;
window;
paneLayout;
shellField;
showWindow;
window;
columnLayout -adj true;
textField;
showWindow;
window;
columnLayout;
textFieldButtonGrp -label "ラベル" -text "textFieldButtonGrp" -buttonLabel "ボタン";
showWindow;
window -menuBar true -width 150;
menu -label "Menu" -tearOff true;
menuItem -label "menu1";
menuItem -label "menu2";
menuItem -label "menu3";
menuItem -divider true;
menuItem -label "menu4";
menu -label "Help" -helpMenu true;
menuItem -label "help";
columnLayout;
button;
showWindow;
window;
columnLayout;
optionMenu -label "Menu";
menuItem -label "test1";
menuItem -label "test2";
menuItem -label "test3";
showWindow;
window;
columnLayout;
button;
popupMenu;
menuItem -label "test1";
menuItem -label "test2";
menuItem -label "test3";
showWindow;
window;
columnLayout;
button;
button;
button;
showWindow;
window;
string $form = `formLayout -numberOfDivisions 100`;
string $b1 = `button -label "ボタン 1"`;
string $b2 = `button -label "ボタン 2"`;
string $b3 = `button -label "ボタン 3"`;
string $b4 = `button -label "ボタン 4"`;
formLayout -edit
-attachForm $b1 "top" 5
-attachForm $b1 "left" 5
-attachControl $b1 "bottom" 15 $b2
-attachPosition $b1 "right" 0 55
-attachNone $b2 "top"
-attachForm $b2 "left" 10
-attachForm $b2 "bottom" 10
-attachForm $b2 "right" 10
-attachForm $b3 "top" 5
-attachPosition $b3 "left" 0 70
-attachControl $b3 "bottom" 25 $b4
-attachForm $b3 "right" 5
-attachNone $b4 "top"
-attachPosition $b4 "left" 0 60
-attachControl $b4 "bottom" 35 $b2
-attachForm $b4 "right" 5
$form;
showWindow;
window;
columnLayout -adjustableColumn true;
frameLayout -label "フレーム 1" -labelAlign "top" -borderStyle "in";
columnLayout;
button;
button;
setParent ..;
setParent ..;
frameLayout -label "フレーム 2" -labelAlign "center" -borderStyle "out";
columnLayout;
button;
button;
setParent ..;
setParent ..;
frameLayout -label "フレーム 3" -labelAlign "center" -borderStyle "etchedIn";
columnLayout;
button;
button;
setParent ..;
setParent ..;
frameLayout -label "フレーム 4" -labelAlign "bottom" -borderStyle "etchedOut";
columnLayout;
button;
button;
setParent ..;
setParent ..;
showWindow;
window;
gridLayout -numberOfColumns 3 -cellWidthHeight 50 30;
button;
button;
button;
button;
button;
showWindow;
window;
columnLayout -adjustableColumn true;
menuBarLayout;
menu -label "File";
menuItem -label "New";
menuItem -label "Open";
menuItem -label "Close";
menu -label "Help" -helpMenu true;
menuItem -label "About...";
setParent ..;
button;
button;
showWindow;
window;
paneLayout -configuration "quad";
button;
columnLayout;
button;
button;
setParent ..;
rowLayout -numberOfColumns 2 -columnWidth2 55 50;
button;
button;
setParent ..;
text -label "paneLayout";
showWindow;
window;
rowColumnLayout -numberOfRows 3
-rowHeight 1 30
-rowHeight 2 50;
button;
button;
button;
button;
button;
button;
button;
showWindow;
window;
rowLayout -numberOfColumns 3 -columnWidth3 65 55 60;
button;
button;
button;
showWindow;
window;
scrollLayout -horizontalScrollBarThickness 16 -verticalScrollBarThickness 16;
columnLayout;
int $i;
for($i = 0; $i < 10; $i++)
{
text -label ("ラベル " + $i);
}
showWindow;
window;
shelfLayout;
iconTextButton -style "iconOnly" -image1 "sphere.xpm";
iconTextButton -style "iconOnly" -image1 "cone.xpm";
iconTextButton -style "iconOnly" -image1 "cube.xpm";
setParent ..;
showWindow;
window;
shelfTabLayout -image "smallTrash.xpm" -imageVisible true;
shelfLayout Shelf1;
setParent ..;
shelfLayout Shelf2;
setParent ..;
showWindow;
window;
string $tabs = `tabLayout`;
string $col1 = `columnLayout`;
button;
setParent ..;
string $col2 = `columnLayout`;
button;
button;
setParent ..;
tabLayout -edit -tabLabel $col1 "タブ 1" -tabLabel $col2 "タブ 2" $tabs;
showWindow;
コントロール、レイアウト、メニューなどで、 マウス中ボタンを押してドラッグ&ドロップを行うときに実行されるプロシージャです。
(使用例)
以下の MEL スクリプトを実行するとした図のようなウインドウが表示されます。
Drag ボタンの上でマウス中ボタンを押して、
Drop ボタンの上にドラッグ&ドロップすると、
dragCallback と dropCallback の引数を スクリプト エディタ に表示します。
global proc string [] dragTest(string $dragControl, int $x, int $y, int $mods) { string $msgs[]; print ("drag dragControl" + $dragControl + "\n"); print ("drag x " + $x + "\n"); print ("drag y " + $y + "\n"); print ("drag mods " + $mods + "\n"); $msgs[0] = "dragtest"; return $msgs; } global proc dropTest(string $dragControl, string $dropControl, string $msgs[], int $x, int $y, int $type) { string $s; print ("drop drapControl " + $dragControl + "\n"); print ("drop dropControl " + $dropControl + "\n"); for($s in $msgs) { print ("drop msgs " + $s + "\n"); } print ("drop x " + $x + "\n"); print ("drop y " + $y + "\n"); print ("drop type " + $type + "\n"); } window -title "Drag and Drop"; columnLayout; button -label "Drag" -h 50 -w 100 -dragCallback "dragTest"; button -label "Drop" -h 50 -w 100 -dropCallback "dropTest"; showWindow;
window;
paneLayout;
animCurveEditor;
showWindow;
window;
paneLayout;
dynRelEditor;
showWindow;
window;
paneLayout;
dynRelEdPanel;
showWindow;
window;
paneLayout;
hardwareRenderPanel;
showWindow;
window;
paneLayout;
hyperPanel;
showWindow;
window;
paneLayout;
lightListEditor;
showWindow;
window;
paneLayout;
lightListPanel;
showWindow;
window;
paneLayout;
modelEditor;
showWindow;
window;
paneLayout;
modelPanel;
showWindow;
string $sname[] = `sphere`;
window;
paneLayout;
nodeOutliner -showInputs true -a $sname[0];
showWindow;
window;
paneLayout;
outlinerPanel;
showWindow;
sphere;
window;
paneLayout;
spreadSheetEditor -mainListConnection `selectionConnection -activeList`;
showWindow;
window;
paneLayout;
blendShapeEditor;
showWindow;
window;
paneLayout;
blendShapePanel;
showWindow;
window;
frameLayout -label "scriptEditor" scriptEditorFrameLayout;
scriptedPanel -e -p scriptEditorFrameLayout scriptEditorPanel1;
showWindow;
global proc int importMayaBinary( string $filename, string $fileType )
{
print ($filename+"\n");
print ($fileType+"\n");
return 1;
}
fileBrowserDialog -m 0 -fc "importMayaBinary" -ft "mayaBinary" -an "MayaBinary";
global proc progressBar1()
{
int $percent = 0;
progressWindow -title "Waiting 10 seconds"
-progress $percent
-status "Sleeping: 0%"
-isInterruptable true;
for(;;)
{
if(`progressWindow -q -isCancelled`)
break;
if(`progressWindow -q -progress` >= 100)
break;
$percent += 10;
progressWindow -e -progress $percent
-status ("Doing : "+$percent+"%");
pause -seconds 1;
}
progressWindow -endProgress;
}
global proc checkboxPrompt()
{
string $form = `setParent -q`;
formLayout -e -width 300 $form;
string $t = `text -l "以下のいずれかのボタンを押してください"`;
string $b1 = `button -l "Abort" -c "layoutDialog -dismiss \"作成\""`;
string $b2 = `button -l "Skip" -c "layoutDialog -dismiss \"適用\""`;
string $b3 = `button -l "Continue" -c "layoutDialog -dismiss \"中止\""`;
string $cb1 = `checkBox -label "操作を覚えておく"`;
int $spacer = 5;
int $top = 5;
int $edge = 5;
formLayout -edit
-attachForm $t "top" $top
-attachForm $t "left" $edge
-attachNone $t "bottom"
-attachForm $t "right" $edge
-attachControl $b1 "top" $spacer $t
-attachForm $b1 "left" $edge
-attachNone $b1 "bottom"
-attachPosition $b1 "right" $spacer 33
-attachControl $b2 "top" $spacer $t
-attachPosition $b2 "left" $spacer 33
-attachNone $b2 "bottom"
-attachPosition $b2 "right" $spacer 66
-attachControl $b3 "top" $spacer $t
-attachPosition $b3 "left" $spacer 66
-attachNone $b3 "bottom"
-attachForm $b3 "right" $edge
-attachControl $cb1 "top" $spacer $b1
-attachForm $cb1 "left" $edge
-attachForm $cb1 "bottom" $spacer
-attachNone $cb1 "right"
$form;
}
layoutDialog -ui "checkboxPrompt";