パーティクル Dynamics/Solvers__Create_Particle_Disk_Cache_.htmlこの後で、以下のコマンドを実行するとパーティクルのヘルプがブラウザで開かれます。
chdir "Z:/my\ Document/maya/projects/default/images"; // Windows の場合
for($i = 100; $i >= 1; $i--)
{
$old = "test.iff." + $i;
$new = "test.iff." + ($i + 30);
sysFile -rename $new $old;
}
if(! `pluginInfo -q -l "test.so"`)
loadPlugin "test.so";
string $s;
int $fpid = `fopen "Z:/mel/tmp.mel" "r"`;
for( $s = `fgetline $fpid`; size($s) > 0; $s = `fgetline $fpid`)
{
$s = `fgetline $fpid`;
print $s;
}
fclose $fpid;
int $fpid = `fopen "Z:/mel/tmp.mel" "w"`;
fwrite $fpid "sphere;\n";
fclose $fpid;
global proc string [] getFilenames()
{
string $files[];
int $pipe = popen("dir /b /w c:\\","r");
int $i = 0;
while(!feof($pipe))
{
$files[$i] = fgetline($pipe);
$i++;
}
pclose($pipe);
return $files;
}
{
string $fname[] = `file -q -list`;
string $dirname = `dirname $fname[0]`;
string $newfile = `basename $fname[0] ".mb"`;
$newfile = `basename $newfile ".ma"`;
$newfile = $dirname + "/" + $newfile + "_v5.ma";
system("sed '4,11s/6\\.0/5.0/' <" + $fname[0] + ">"+ $newfile);
}
元のシーンファイル名が scene1.mb だとすると、
scene1_v5.ma という 5.0 のシーンファイルが作られます。
{
string $sel[] = `ls -sl`;
string $sl[] = `listRelatives -c $sel[1]`;
parent -s -add $sl $sel[0];
delete $sel[1];
}
スクリプト実行前
(curve1, curve2 の順に選択)
{
string $lname[] = `spaceLocator -p 0 0 0`;
string $sname[] = `sphere`;
move 1 2 3;
string $sph[] = `listRelatives -s $sname[0]`;
$cpm = `createNode closestPointOnSurface`;
connectAttr ($sph[0] + ".ws") ($cpm + ".is");
connectAttr ($lname[0] + ".t") ($cpm + ".ip");
float $p[] = `getAttr ($cpm + ".p")`;
move $p[0] $p[1] $p[2] $lname[0];
}
closestPointOnSurface ノードは点に最も近い UV 座標も求めることができます。
(parametarU, parametarV アトリビュート)
global proc int newObjExists(string $name)
{
if(`objExists $name` || `objExists ("*:" + $name)`)
{
return 1;
}
return 0;
}
プロシージャ newObjExists の別バージョン。
global proc int newObjExists(string $name)
{
string $names[] = `ls -r true $name`;
if(size($names) > 0)
{
return 1;
}
return 0;
}
int $i;
string $s = "abcde";
string $ss[];
for($i = 0; $i < size($s); $i++)
{
$ss[$i] = substring($s, $i+1, $i+1);
}
$ss[0]に"a"、$ss[1]に"b"...が代入される。
string $err;
string $com = "sphere; scale 2 2 2;";
int $ret = catchQuiet($com);
if($ret == 1)
{
$err = getLastError();
}
else
{
eval $com;
}
MAYA_SCRIPT_PATH = /home/ad000000/mel
MAYA_SCRIPT_PATH = c:\ad000000\mel
string $myMelFile = `commandScrollFieldPromptForFile "スクリプトを開く" "/Users/who" 0 "mel"`;
eval("source \"" + $myMelFile + "\"");
global proc displayInPhotoshop() { string $name[] = `ls -sl -type "file"`; string $filename = `getAttr ($name[0] + ".fileTextureName")`; chdir "c:/Program files/Adobe/Adobe Photoshop CS2"; $filename = `substituteAllString $filename "/" "\\"`; system ("start Photoshop " + $filename); }substituteAllString コマンドは、 画像ファイルのパス中の / を \\ に書き換えています。
global proc displayInGimp() { string $name[] = `ls -sl -type "file"`; string $filename = `getAttr ($name[0] + ".fileTextureName")`; system ("gimp " + $filename + ">& /dev/null &"); }
string $name[];
string $path = "aaa|bbb|ccc";
tokenize($path, "|", $name);
int $size = size($name);
$size--;
// $name[$size] は "ccc"
{
float $p1[] = `xform -q -ws -t joint1`;
float $p2[] = `xform -q -ws -t joint2`;
string $dname = `distanceDimension -sp $p1[0] $p1[1] $p1[2] -ep $p2[0] $p2[0] $p2[0]`;
print `getAttr ($dname + ".dist")`;
}
global proc variableExist(string $n)
{
string $names[] = `env`;
int $mc = stringArrayCount($n, $names);
if($mc > 0)
{
print "exists\n";
}
else
{
print "not exists\n";
}
}
上のプロシージャを使用する場合は、
変数名に $ を付けて引数として与えます。
// トップセクション(トランスフォームノード)で選択されているアトリビュート channelBox -q -sma mainChannelBox; // Shapes のセクションで選択されているアトリビュート channelBox -q -ssa mainChannelBox; // Inputs のセクションで選択されているアトリビュート channelBox -q -sha mainChannelBox; // Outputs のセクションで選択されているアトリビュート channelBox -q -soa mainChannelBox;
selectKey -time ":";
float $allKeys[] = sort(`keyframe -q -sl`);
playbackOptions -min $allKeys[0] -max $allKeys[(size($allKeys) -1)];
{
string $names[] = `ls -tr`;
for($n in $names)
{
float $tx = `getAttr ($n + ".tx")`;
float $ty = `getAttr ($n + ".ty")`;
float $tz = `getAttr ($n + ".tz")`;
if($tx > 10)
{
print ("tx " + $n + " " + $tx + "\n");
}
if($ty > 10)
{
print ("ty " + $n + " " + $ty + "\n");
}
if($tz > 10)
{
print ("tz " + $n + " " + $tz + "\n");
}
}
}
{
string $dir = "/home/user/mel/"; // 画像の存在するフォルダ(ディレクトリ)
string $winName = `window`;
string $form = `formLayout`;
string $i1 = `iconTextButton -w 33 -h 33 -style "iconOnly" -image1 "sphere.xpm"`;
string $pic1 = `picture -image ($dir + "picButton1.xpm")`;
formLayout -edit
-attachForm $pic1 "top" 0
-attachForm $pic1 "left" 0
-attachNone $pic1 "bottom"
-attachNone $pic1 "right"
-attachForm $i1 "top" 50
-attachForm $i1 "left" 50
-attachNone $i1 "bottom"
-attachNone $i1 "right"
$form;
setParent ..;
showWindow;
}
global proc changeMinValue()
{
float $value = `floatField -q -value myMinField`;
floatField -e -min $value myInputField;
}
global proc changeMinValueByButton()
{
float $value = `floatField -q -value myInputField`;
floatField -e -v $value myMinField;
floatField -e -min $value myInputField;
}
window;
rowLayout -nc 3 -cw3 60 30 60;
floatField -cc "changeMinValue();" myMinField;
button -label " < " -c "changeMinValueByButton();";
floatField -min 0 myInputField;
showWindow;
スクリプトの実行結果
global proc optionMenuSample1(string $location)
{
int $num = `optionMenu -q -ni brushesOptionMenu`;
string $fname = `optionMenu -q -v foldersOptionMenu`;
string $names[] = `getFileList -fld ($location + $fname + "/") -fs "*.mel"`;
int $i = 0;
for($n in $names)
{
if($i < $num)
{
menuItem -e -label $n ("brushesMenuItem" + $i);
}
else
{
menuItem -p brushesOptionMenu -label $n ("brushesMenuItem" + $i);
}
$i++;
}
for(; $i < $num; $i++)
{
deleteUI ("brushesMenuItem" + $i);
}
}
{
window;
columnLayout;
string $location = `getenv "MAYA_LOCATION"`;
$location += "/brushes/";
optionMenu -label "Folders" -cc ("optionMenuSample1(\"" + $location + "\")") foldersOptionMenu;
string $names[] = `getFileList -fld $location -fs "*"`;
for($n in $names)
{
menuItem -label $n;
}
optionMenu -label "Brushes" brushesOptionMenu;
$names = `getFileList -fld ($location + $names[0] + "/") -fs "*.mel"`;
int $i = 0;
for($n in $names)
{
menuItem -label $n ("brushesMenuItem" + $i);
$i++;
}
showWindow;
}
{
int $i;
window;
columnLayout;
string $colorPalette = `palettePort
-dimensions 16 2
-width (16 * 20)
-height (2 * 20)
-transparent 0
-topDown true
-colorEditable false`;
for($i = 1; $i <= 31; $i++)
{
float $col[] = `colorIndex -query $i`;
palettePort -edit -rgbValue $i $col[0] $col[1] $col[2] $colorPalette;
}
showWindow;
}
global proc makeButton1(string $dragControl, string $dropControl, string $msgs[], int $x, int $y, int $type)
{
string $com = $msgs[0];
setParent dropLayout;
eval($com);
setParent ..;
}
global proc string[] dragButton1(string $dragControl, int $x, int $y, int $mods)
{
string $msgs[];
$msgs[0] = "button";
return $msgs;
}
window;
columnLayout -dpc "makeButton1" dropLayout;
setParent ..;
showWindow;
window;
columnLayout;
button -dgc "dragButton1";
setParent ..;
showWindow;
window myWindow;
columnLayout myLayout;
button myButton;
showWindow;
objectTypeUI myWindow;
// 結果: floatingWindow //
objectTypeUI myLayout;
// 結果: columnLayout //
objectTypeUI myButton;
// 結果: button //
window;
// 結果: window1 //
columnLayout;
// 結果: window1|columnLayout1 //
button;
// 結果: window1|columnLayout1|button1 //
showWindow;
layout -q -childArray window1|columnLayout1;
// 結果: button1 //
window;
// 結果: window1 //
columnLayout;
// 結果: window1|columnLayout2 //
showWindow;
layout -q -ex window1|columnLayout2;
// 結果: 1 //
deleteUI window1;
layout -q -ex window1|columnLayout2;
// 結果: 0 //
global proc float displayCurrentFrame()
{
float $frame;
$frame = `currentTime -q`;
return $frame;
}
headsUpDisplay -section 5
-block 1
-blockSize "medium"
-label "Frame"
-command "displayCurrentFrame()"
-event "timeChanged"
HUDDisplayCurrentFrame;
global proc float [] getSelectedPosition()
{
float $val[];
string $sp[] = `ls -sl`;
string $pos[] = `filterExpand -sm 31 $sp`;
int $i = 0;
for($p in $pos)
{
$pv = `pointPosition $p`;
$val[$i] = $pv[0];
$i++;
$val[$i] = $pv[1];
$i++;
$val[$i] = $pv[2];
$i++;
}
return $val;
}
プロシージャを実行すると、
X, Y, Z の座標値が選択された頂点の個数分返ってきます。
string $poly[] = `polySphere -sx 7 -sy 7 -r 3`;
string $ver[] = `polyListComponentConversion -toFace $poly[0]`;
string $verE[] = `filterExpand -selectionMask 34 $ver`;
for($obj in $verE)
{
string $pe[] = `polyExtrudeFacet $obj`;
string $ns[] = `polyInfo -fn $obj`;
string $vs[];
tokenizeList($ns[0], $vs);
float $vx = $vs[2];
float $vy = $vs[3];
float $vz = $vs[4];
move -r $vx $vy $vz $obj;
}
global proc find3Polygon1()
{
string $poly[] = `ls -sl`;
string $edge[] = `polyListComponentConversion -toFace $poly[0]`;
string $edges[] = `filterExpand -selectionMask 34 $edge[0]`;
for($obj in $edges)
{
string $list[];
string $num[] = `polyInfo -fe $obj`;
tokenizeList($num[0], $list);
if(size($list) == 5)
{
print ("find " + $obj + "\n");
}
}
}
4 角以上のポリゴンを見つけて、セレクトし、 SplitPolygonTool のモードに入るスクリプト。
global proc findNPolygon1()
{
string $poly[] = `ls -sl`;
select -cl;
string $edge[] = `polyListComponentConversion -toFace $poly[0]`;
string $edges[] = `filterExpand -selectionMask 34 $edge[0]`;
for($obj in $edges)
{
string $list[];
string $num[] = `polyInfo -fe $obj`;
tokenizeList($num[0], $list);
if(size($list) > 6)
{
select $obj;
fitPanel -selected;
SplitPolygonTool;
return;
}
}
}
global proc float [] getSelectedUVs()
{
float $uvs[];
string $sp[] = `ls -sl`;
string $ver[] = `polyListComponentConversion -toUV $sp[0]`;
string $pos[] = `filterExpand -sm 35 $ver`;
for($i = 0, $j = 0; $i < size($pos); $i++)
{
float $uv[];
$uv = (`polyEditUV -q $pos[$i]`);
$uvs[$j] = $uv[0];
$j++;
$uvs[$j] = $uv[1];
$j++;
}
return $uvs;
}
global proc string [] getFaceUVs1()
{
string $face[] = `ls -sl`;
string $uvc[] = `polyListComponentConversion -toUV $face[0]`;
string $map[] = `filterExpand -sm 35 $uvc`;
for($i = 0; $i < size($map); $i++)
{
$map[$i] = `substitute ".*\.map\\[" $map[$i] ""`;
$map[$i] = `substitute "]" $map[$i] ""`;
}
return $map;
}
global proc separatePolygon(string $pname)
{
polyChipOff -ch 1 -kft 0 -dup 0 ($pname + ".f[*]");
string $fs[] = `polySeparate -ch 1 $pname`;
string $gname[] = `gravity`;
for($f in $fs)
{
if(`nodeType $f` != "transform")
{
continue;
}
string $sf[] = `listRelatives -s $f`;
select $sf[0];
rigidBody -active;
}
connectDynamic -f $gname[0] $fs;
}
{
string $pname[] = `ls -sl`;
ctxCompletion;
int $size[] = `polyEvaluate -e $pname[0]`;
$size[0] -= 1;
select ($pname[0] + ".e[" + $size[0] + "]");
}
{
string $pname[] = `ls -sl`;
ctxCompletion;
string $psname[] = `listRelatives -s $pname[0]`;
string $polySplit[] = `listConnections ($psname[0] + ".inMesh")`;
float $ver[] = `getAttr ($polySplit[0] + ".v[*]")`;
int $size = `size $ver`;
$size = $size / 3 - 1;
int $msize[] = `polyEvaluate -uv $pname[0]`;
$msize[0] -= 1;
$size = $msize[0] - $size;
if($size >= 0)
untangleUV -pu true -r harmonic ($pname[0] + ".map[" + $size + ":" + $msize[0] + " ]");
setToolTo polySplitContext;
}
$winName = `window`;
string $form = `formLayout`;
$b1 = `button -label "button"`;
formLayout -edit
-attachForm $b1 "top" 0
-attachForm $b1 "bottom" 0
-attachOppositeForm $b1 "left" -100
-attachForm $b1 "right" 10
$form;
showWindow;
{
int $sections = 16;
int $spans = 8;
string $sphere[] = `sphere -s $sections -nsp $spans`;
$spans += 3;
int $num = $sections * $spans;
for($i = 0; $i < $num; $i++)
{
float $x = rand(-0.2, 0.2);
float $y = rand(-0.2, 0.2);
float $z = rand(-0.2, 0.2);
move -r $x $y $z ($sphere[0] + ".cv[" + $i + "]");
}
}
global proc lineCv(float $sx, float $ex)
{
string $points[] = `ls -sl -fl`;
if(size($points) < 2)
{
return;
}
float $inc = ($ex - $sx)/(size($points) - 1);
float $x = $sx;
for($p in $points)
{
move $x 0 0 $p;
$x += $inc;
}
}
(実行前)
global proc randomCv(float $sx, float $ex, float $sy, float $ey)
{
string $points[] = `ls -sl -fl`;
if(size($points) < 2)
{
return;
}
float $inc = ($ex - $sx)/(size($points) - 1);
float $x = $sx;
for($p in $points)
{
float $y = rand($sy, $ey);
move $x $y 0 $p;
$x += $inc;
}
}
(実行前)
{
int $num = 10;
float $rad = 2;
string $cname = `curve -d 3 -p 0 0 0 -p 0 5.0 0 -p 0 5.0 0 -p 0 10 0 -k 0 -k 0 -k 0 -k 1 -k 1 -k 1`;
rebuildCurve -s (4*$num) $cname;
string $tname[] = `nonLinear -type twist $cname`;
move $rad 0 0 $cname;
setAttr ($tname[0] + ".endAngle") (360*$num);
}
string $text[] = `textCurves -f "Times-Roman" -t "Abe"`;
string $pln[] = `planarSrf -polygon 1 $text[0]`;
string $tname[] = `listConnections -s false -d true $pln[1]`;
setAttr ($tname[0] + ".polygonCount") 10;
{
string $obj;
string $names[] = `ls -sl`;
for($obj in $names)
{
bevelPlus -normalsOutwards true -range false -polygon 0 -tolerance 0.01 -numberOfSides 4 -js true -width 0.5 -depth 0.5 -extrudeDepth 1.5 -capSides 4 -bevelInside 0 -outerStyle 0 -innerStyle 0 $obj;
}
}
(実行前)
{
int $i;
string $obj;
string $names[] = `ls -sl`;
for($i = 0; $i < size($names); $i += 2)
{
bevelPlus -normalsOutwards true -range false -polygon 0 -tolerance 0.01 -numberOfSides 4 -js true -width 0.5 -depth 0.5 -extrudeDepth 1.5 -capSides 4 -bevelInside 0 -outerStyle 0 -innerStyle 0 $names[$i] $names[$i+1] ;
}
}
(実行前)
string $sname1[] = `sphere`;
move 2 0 0;
string $sname2[] = `sphere`;
freeFormFillet -bias 0.0 -depth 0.5 ($sname1[0] + ".u[1.0]") ($sname2[0] + ".u[3.0]");
{
string $sname[] = `sphere`;
string $cname = `curve -d 3 -p -0 -0 0 -p 2 2 0 -p 4 6 0 -p 6 4 0 -k 0 -k 0 -k 0 -k 1 -k 1 -k 1`;
pathAnimation -c $cname -stu 1 -etu 100 $sname[0];
choice -at tx -at tz -t 1 -t 30 -t 60 $sname[0];
choice -at tx -at tz -t 31 $sname[0];
currentTime 31;
setKeyframe -at tx -at tz $sname[0];
move -r 3 0 5;
currentTime 59;
setKeyframe -at tx -at tz $sname[0];
}
以下のスクリプトでは、
NURBS の球体が 1 フレームから 30 フレームまではキーフレーム、
31 フレームから 60 フレームまでは pointConstraint によって コーン と同じ位置でアニメーションし、
61 フレームからは再びキーフレームによってアニメーションを行います。
{
string $cname[] = `cone`;
currentTime 1;
setKeyframe;
currentTime 100;
move 5 0 5;
setKeyframe;
string $sname[] = `sphere`;
currentTime 1;
setKeyframe;
currentTime 100;
move -5 0 5;
setKeyframe;
choice -at tx -at tz -t 1 -t 30 -t 60 $sname[0];
string $chname[] = `choice -at tx -at tz -t 31 $sname[0]`;
string $pname[] = `pointConstraint $cname[0] $sname[0]`;
select -r pairBlend1;
delete;
connectAttr ($pname[0] + ".ctx") $chname[0];
connectAttr ($pname[0] + ".ctz") $chname[1];
}
{
string $sname[] = `sphere`;
currentTime 1;
setKeyframe -at tx;
currentTime 30;
move 10 0 0;
setKeyframe -at tx;
string $rname = `rigidBody -passive $sname[0]`;
currentTime 1;
setRigidKeyframe(0);
currentTime 31;
setRigidKeyframe(1);
string $gname[] = `gravity`;
connectDynamic -fields $gname[0] $rname;
}
ここで、setRigidKeyframe
は Maya において元から使用できる MEL スクリプトで、
選択されているリジッドボディにキーフレームの設定します。
addAttr -ln driven1 -min 0.0 -max 1.0 joint1;
setAttr joint1.driven1 0.0;
setAttr joint1.tx 5.0;
setDrivenKeyframe -cd joint1.driven1 joint1.translateX;
setAttr joint1.driven1 1.0;
setAttr joint1.tx 10.0;
setDrivenKeyframe -cd joint1.driven1 joint1.translateX;
string $j1 = `joint -p 0 10 0`; string $j2 = `joint -p 0 5 0`; joint -e -zso -oj xyz -sao yup $j1; // X軸がジョイントの方向、Y軸が上方向 string $j3 = `joint -p 0 0 0`; joint -e -zso -oj xyz -sao yup $j2; rotate -r 0 10 0 $j2; joint -e -spa -ch $j2; // 優先角設定 setAttr ($j2 + ".ry") 0; string $ikh[] = `ikHandle -sol ikRPsolver $j1 $j3`; string $loc[] = `spaceLocator`; move 0 5 5; makeIdentity -apply true -t 1 -r 1 -s 1 -n 0; // トランスフォームのフリーズ poleVectorConstraint -weight 1 $loc[0] $ikh[0]; // コンストレイン→極ベクトル
joint -n joint1;
joint -p 5 0 0 -n joint2;
joint -p 10 0.5 0 -n joint3;
ikHandle;
cylinder -radius 1.0 -heightRatio 10.0 -sections 20 -spans 6 -n nurbsCylinder1;
move 4 0 0;
skinCluster -n skinCluster1 joint1 joint2 joint3 nurbsCylinder1;
このオブジェクト(nurbsCylinder1)から各 CV のウエイト値を求めるには
以下のコマンドを使用します。
select nurbsCylinder1.cv["*"]["*"];
for($n in `ls -sl -fl`)
{
string $joints[] = `skinPercent -q -t skinCluster1 $n`;
float $waits[] = `skinPercent -q -v skinCluster1 $n`;
print ($n + "\n");
print $joints;
print $waits;
}
string $myJointnames[];
string $myRebindObjname;
{
string $sname[] = `ls -sl`;
$myRebindObjname = $sname[0];
string $lname[] = `listConnections ($myRebindObjname + ".create")`;
$myJointnames = `skinPercent -q -t $lname[0] ($myRebindObjname + ".cv[*][*]")`;
if(! `exists exportSkinWeightMap`)
{
string $path = `getenv "MAYA_LOCATION"`;
eval("source " + $path + "/scripts/others/exportSkinMap.mel");
}
string $wspace = `workspace -q -rd`;
exportSkinWeightMap ($wspace + "/sourceimages/tmp") "map";
skinCluster -e -ub $sname[0];
}
{
skinCluster $myJointnames $myRebindObjname;
if(! `exists importSkinWeightMap`)
{
string $path = `getenv "MAYA_LOCATION"`;
eval("source " + $path + "/scripts/others/importSkinMap.mel");
}
select $myRebindObjname;
string $wspace = `workspace -q -rd`;
importSkinWeightMap ($wspace + "/sourceimages/tmp.weightMap") "map";
}
{
string $dir = `workspace -q -rd`;
playblast -format image -viewer 0 -percent 50 -f ($dir + "images/persp");
}
各フラグの意味は以下の通り。
{
$ct = `currentTime -q`;
if($ct >= 30)
{
nurbsCone1.tx = `getAttr -t ($ct - 30) nurbsSphere1.tx
`;
}
else
{
nurbsCone1.tx = `getAttr -t 1 nurbsSphere1.tx`;
}
}
if(particleShape1.particleId % 100 == 0)
{
vector $p = particleShape1.position;
sphere -p ($p.x) ($p.y) ($p.z);
}
global proc myEventProc(string $particleName, int $particleID, string $objectName)
{
if($objectName == "pPlaneShape2")
{
particle -e -attribute lifespanPP -id $particleID -floatValue 0.0 $particleName;
}
}
この例では、pPlaneShape2 に衝突したときにパーティクルが消滅します。
if(rigidBody1.contactCount > 0)
{
string $pp[] = `rigidBody -q -cp rigidBody1`;
string $pos[];
tokenize $pp[0] $pos;
particle -p $pos[0] $pos[1] $pos[2];
string $emi[] = `emitter`;
particle;
connectDynamic -em $emi[0];
}
ここには記述していなませんが、
エミッターから発生するパーティクルには適当にアトリビュートを設定してください。
global proc shapedParticle1()
{
string $selected[] = `ls -sl`;
select -clear;
string $ename[] = `emitter -rate 300`;
string $pname[] = `particle`;
connectDynamic -emitters $ename[0];
for($sl in $selected)
{
collision $sl $pname[0];
connectDynamic -collisions $sl $pname[0];
}
int $max = `playbackOptions -q -max`;
string $loop = `playbackOptions -q -loop`;
playbackOptions -max 120 -loop once;
currentTime -e `playbackOptions -q -min`;
play -wait -state on;
disconnectAttr time1.outTime ($pname[1] + ".currentTime");
disconnectAttr time1.outTime ($ename[0] + ".currentTime");
string $gname[] = `listConnections particleShape1.collisionGeometry[0]`;
disconnectAttr time1.outTime ($gname[0] + ".currentTime");
currentTime -e `playbackOptions -q -min`;
playbackOptions -max $max -loop $loop;
}
(その他の例)
{
string $names[] = `ls -sl -type "file"`;
if(`size($names)` > 0)
{
string $texname = `getAttr ($names[0] + ".fileTextureName")`;
PaintEffectsWindow;
dynPaintOpenFile $texname "image";
}
}
{
string $names[] = `ls -sl`;
for($i = 1; $i < size($names); $i++)
{
string $bn = $names[$i];
string $cs = `createNode scaleConstraint`;
connectAttr -f ($names[0] + ".scale") ($cs + ".target[0].targetScale");
connectAttr -f ($names[0] + ".parentMatrix[0]") ($cs + ".target[0].targetParentMatrix");
float $os = `getAttr ($names[0] + ".scaleX")`;
string $stroke[] = `listRelatives $bn`;
string $brush[] = `listConnections -t brush $stroke[0]`;
float $ts = `getAttr ($brush[0] + ".globalScale")`;
float $rate = $ts/$os;
setAttr ($cs + ".offsetX") $rate;
connectAttr -f ($cs + ".constraintScale.constraintScaleX") ($brush[0] + ".globalScale");
}
}
string $sname[] = `sphere`; string $shname = `shadingNode -asShader blinn`; string $sgname = `sets -renderable true -noSurfaceShader true -empty`; connectAttr -f ($shname + ".outColor") ($sgname + ".surfaceShader"); select -r $sname[0]; sets -e -forceElement $sgname;mentalrayのmia_materialをアサイン。
string $sname[] = `sphere`; string $shname = `shadingNode -asShader mia_material`; string $sgname = `sets -renderable true -noSurfaceShader true -empty`; connectAttr -f ($shname + ".diffuse") ($sgname + ".surfaceShader"); select -r $sname[0]; sets -e -forceElement $sgname;
string $shname = `shadingNode -asShader lambert`; string $tex = `shadingNode -asTexture checker`; string $ptex = `shadingNode -asUtility place2dTexture`; connectAttr ($ptex + ".outUV") ($tex + ".uv"); connectAttr ($ptex + ".outUvFilterSize") ($tex + ".uvFilterSize"); connectAttr -f ($tex + ".outColor") ($shname + ".color");
{ string $mname = "lambert1"; defaultNavigation -createNew -destination ($mname + ".color"); createRenderNode -allWithTexturesUp ("defaultNavigation -force true -connectToExisting -source %node -destination " + $mname + ".color") ""; defaultNavigation -defaultTraversal -destination ($mname + ".color"); window -e -vis true createRenderNodeWindow; }
{ string $texfiles[] = `ls -type file`; for($f in $texfiles) { AEfileTextureReloadCmd ($f + ".fileTextureName"); } }
{ string $texfiles[] = `ls -type file`; for($f in $texfiles) { AEpsdFileTextureReloadCmd ($f + ".fileTextureName"); } }
{ string $tex[] = `ls -sl`; string $con = `shadingNode -asUtility condition`; string $sam = `shadingNode -asUtility samplerInfo`; connectAttr -f ($tex[1] + ".outColor") ($con + ".colorIfTrue"); connectAttr -f ($tex[2] + ".outColor") ($con + ".colorIfFalse"); connectAttr -f ($sam + ".flippedNormal") ($con + ".firstTerm"); connectAttr -f ($con + ".outColor") ($tex[0] + ".color"); }
ファイル形式 | 番号 |
---|---|
GIF | 0 |
SI | 1 |
RLA | 2 |
Tiff | 3 |
Tiff16 | 4 |
SGI | 5 |
Alias | 6 |
IFF | 7 |
JPEG | 8 |
EPS | 9 |
IFF16 | 10 |
Cineon | 11 |
Quantel | 12 |
SGI16 | 13 |
TARGA | 19 |
BMP | 20 |
SGIMV | 21 |
QT | 22 |
AVI | 23 |
MACPAINT | 30 |
PHOTOSHOP | 31 |
PNG | 32 |
QUICKDRAW | 33 |
QTIMAGE | 34 |
DDS | 35 |
DDS | 36 |
IMFplugin | 50 |
Custom | 51 |
SWF | 60 |
AI | 61 |
SVG | 62 |
SWFT | 63 |
{
$panel = `getPanel -withFocus`;
if(`getPanel -typeOf $panel` == "modelPanel")
modelEditor -e -dl "none" $panel;
}
{
$panel = `getPanel -withFocus`;
if(`getPanel -typeOf $panel` == "modelPanel")
modelEditor -e -wos (!`modelEditor -q -wos $panel`) $panel;
}
{
$panel = `getPanel -withFocus`;
if(`getPanel -typeOf $panel` == "modelPanel")
modelEditor -e -xray (!`modelEditor -q -xray $panel`) $panel;
}
{
$panel = `getPanel -withFocus`;
if(`getPanel -typeOf $panel` == "modelPanel")
isolateSelect -state (!`isolateSelect -q -state $panel`) $panel;
}
string $mode = `optionMenu -q -v $gMenuModeButton`; if($mode == "ポリゴン") { print "メニューはポリゴン\n"; }
window;
paneLayout;
modelPanel;
showWindow;
if(`window -query -visible unifiedRenderGlobalsWindow`) window -e -vis 0 unifiedRenderGlobalsWindow;
if(isUIComponentVisible("Time Slider")) { print "タイムスライダ表示\n"; }
if(isUIComponentVisible("Range Slider")) { print "レンジスライダ表示\n"; }
{ string $currentShelf = `tabLayout -query -selectTab $gShelfTopLevel`; setParent $currentShelf; shelfButton -command "sphere" -sourceType "mel" -label "test" -annotation "sphere" -imageOverlayLabel "test" -image1 "c:/tmp/tmp1.bmp" -style `shelfLayout -query -style $currentShelf` -width `shelfLayout -query -cellWidth $currentShelf` -height `shelfLayout -query -cellHeight $currentShelf`; }
colorEditor;
float $col[] = `colorEditor -q -rgb`;
print ("red " + $col[0] + "\n");
print ("green " + $col[1] + "\n");
print ("blue " + $col[2] + "\n");
window;
columnLayout -adjustableColumn true;
button; // button1
columnLayout;
button; // button2
setParent ..;
showWindow;
{
string $window = `window`;
string $form = `formLayout`;
string $b1 = `button`;
string $b2 = `button`;
formLayout -edit
-attachNone $b1 "top"
-attachForm $b1 "left" 0
-attachForm $b1 "bottom" 0
-attachPosition $b1 "right" 0 50
-attachNone $b2 "top"
-attachPosition $b2 "left" 0 50
-attachForm $b2 "bottom" 0
-attachForm $b2 "right" 0
$form;
showWindow $window;
}
string $menu1 = "物体を1つ選択してください\n元の位置から5 5 5だけ移動します";
string $menu2 = "物体を2つ選択してください\n2つ目の物体を1つ目に移動します。";
global proc moveObj()
{
global string $bname, $bname2, $menu2;
string $name[] = `ls -sl`;
if(size($name) != 1)
{
return;
}
move -r 5 5 5;
button -e -en false -ann "" $bname;
button -e -en true -ann $menu2 $bname2;
}
global proc moveObj2()
{
global string $bname, $bname2, $menu1;
string $name[] = `ls -sl`;
if(size($name) != 2)
{
return;
}
float $pos[] = `xform -q -ws -t $name[0]`;
move $pos[0] $pos[1] $pos[2] $name[1];
button -e -en true -ann $menu1 $bname;
button -e -en false -ann "" $bname2;
}
window;
columnLayout -adjustableColumn true;
string $bname = `button -l "操作1" -ann $menu1 -c moveObj`;
string $bname2 = `button -l "操作2" -en false -c moveObj2`;
showWindow;
window;
columnLayout;
button -annotation "sample button";
showWindow;
if(`getAttr persp.orthographic`)
{
print "Orthographic\n";
}
else
{
print "Perspective\n";
}
scriptCtx -title "my scale tool" -totalSelectionSets 1
-finalCommandScript "select -r $Selection1; scale 2 2 2;" myScaleTool;
setToolTo myScaleTool;
string $mySelectedVertexNumber[];
global proc setSelectedVertexNumber()
{
string $addstr[];
global string $mySelectedVertexNumber[];
string $vers[] = `ls -sl -fl -type float3`;
int $i = 0;
int $j = 0;
for($item in $vers)
{
if(stringArrayContains($item, $mySelectedVertexNumber) == 0)
{
$addstr[$j] = $item;
$j++;
}
}
$mySelectedVertexNumber = stringArrayCatenate($mySelectedVertexNumber, $addstr);
}
int $myScriptJobNumber;
scriptCtx -title "merge Tool"
-totalSelectionSets 1
-setAutoComplete false
-setAutoToggleSelection true
-setSelectionCount 0
-vertex true
-expandSelectionList true
-toolCursorType "edit"
-toolStart "$myScriptJobNumber = `scriptJob -event SelectionChanged setSelectedVertexNumber`;"
-finalCommandScript "int $size = size($mySelectedVertexNumber);\
float $pos[] = `pointPosition $mySelectedVertexNumber[$size-1]`;\
polyMergeVertex -d 10.0 $Selection1;\
move $pos[0] $pos[1] $pos[2];\
scriptJob -kill $myScriptJobNumber;\
clear $mySelectedVertexNumber;"
myMergeVertexCtx;
setToolTo myMergeVertexCtx; によってコンテキストモードに入り、
ポリゴンの頂点を順番に選択して Enter キーを押すと、
最後に選択された頂点の位置にマージされます。