SyntaxHighlighter

2014年7月11日金曜日

メモ_maya(チャネル ボックスカラー)

ほかページからの転記

チャネル ボックス(Channel Box) カラー

ロックされている
グレー
キー設定不可
ライト グレー
ミュートされている
茶色
ブレンドされている
緑色
キー設定されている
明るいオレンジ色
エクスプレッション
紫色
コンストレイントされている
青色
接続済み
黄色


========================================================
Mel覚え書き
========================================================

--------------------------------------------------------
■for分テンプレート
--------------------------------------------------------
string $sentaku[] = ` ls -sl -tr ` ;
int $kazu = ` size ( $sentaku ) ` ;
int $x ;

for ( $x = 0 ; $x < $kazu ; $x++ )
{
string $locName = $sentaku[$x];
spaceLocator -n $locName;
}//for

--------------------------------------------------------
■指定した文字を含むオブジェクトをリスト
--------------------------------------------------------
ls "locator?"; 
ls "locator?""locator?2";//複数の文字列を指定する版 

↑結構簡単だった、、、。
「ls」コマンド後、「" "」で囲って文字列を指定するだけ。フラグもいらない。

--------------------------------------------------------
■文字列を置き換え(又は削除)
--------------------------------------------------------
string substituteAllString(string $text, string $searchStr, string $replaceStr)

$replaceStrを空の"" にすると削除と同じになる。

例:
string $text = "one + two + three + four";
string $result1 = substituteAllString($text, "+", "plus");
print $result1;

--------------------------------------------------------
■シーンのファイル名を調べる
--------------------------------------------------------
file -q -shortName -sceneName;

--------------------------------------------------------
■-typeフラグで使えるタイプを調べるコマンド
--------------------------------------------------------
ls -showType

--------------------------------------------------------
■アニメーションカーブを指定フレーム分ズラす
--------------------------------------------------------
string $animCurve[] = `ls -type animCurveTL -type animCurveTU -type animCurveTA -type animCurveTT`;
keyframe -edit -r -timeChange ( この括弧内にズラしたいフレーム数を記述してください ) $animCurve;

--------------------------------------------------------
■トランスフォームノードをリストUP
--------------------------------------------------------
ls -sl -typ transform;

--------------------------------------------------------
■ウィンドウ表示位置などをコントロールする
--------------------------------------------------------
windowPref -enableAll false;//多分、ウィンドウ作成時に強制されるデフォルト設定的なものを切ってる...。

//このコマンドで挟むようにウィンドウを作成する。

windowPref -enableAll true;//↑で切った設定をONに戻す



「-enableAll」フラグが何をしてるかは不明、、、。
(多分、ウィンドウ作成時に強制されるデフォルト設定的なものを切ってるんだと思う。)
「-w」や「-h」などのコマンドも機能するようになります。

--------------------------------------------------------
■ウィンドウにコメントなどのテキストを表示
--------------------------------------------------------
string $winName = "test";

windowPref -enableAll false;

if((`window -ex $winName`) == true)
deleteUI $winName;

window -w 360 -title $winName $winName;

scrollLayout;

text -al left//「left」、「right」、「center」の引数を指定する。

//-------------------------
"■テストコメント\n\
  test\n\
  test";
//-------------------------

showWindow;

windowPref -enableAll true;


--------------------------------------------------------
■可視性ONのパネルを検索→最後のパネルネームを取得
--------------------------------------------------------
string $panel[] = `getPanel -visiblePanels`;
int $kazu = `size($panel)`;
print $panel[($kazu - 1)];

※作成したモデルパネルの設定変更する際にパネルネームを取得して使用


--------------------------------------------------------
■論理演算子
--------------------------------------------------------
=====================================================
&& ~かつ・・・
|| ~または・・・("||"半角でshift+\で書ける。)
! ~じゃない
=====================================================

もし $num が0より大きくてかつ5以下であるなら…
という場合は

if(0 < $num && $num <= 5)

もし $num が0以下かまたは5より大きいなら
という場合は

if($num <= 0 || 5 < $num)

この様に書きます。

また、『~じゃなければ』という否定には、『!』記号を使います。

例えば、
if(!($num < 5))

この様に書くと、「もし$numが5より小さくなければ」という意味になります。



--------------------------------------------

int:整数型(整数のみ代入可能)
float:浮動小数点型(小数も代入可能)
string:文字列型(文字列を代入可能)

vector:ベクトルデータ型(3つの浮動小数点の組み合わせ)
配列型:同じ型の要素のリスト
matrix:行列型(2次元の表)

【↓例↓】
int $a = 10; 
float $b = 1.234; 
vector $v = <<1.2, 3.4, 6.5>>; 
※個々の値を参照するには、$v.x、$v.y、$v.zと記述する。
float $ar[] = {1.2, 3.4, 4.5}; // 浮動小数点の配列
matrix $mtx[3][2]; // 3*2の浮動小数点の表

■代入演算子

$x++ // $x = $x + 1と同じ意味。
$x-- // $x = $x - 1
$x += 5 // $x = $x + 5 
$x -= 3 // $x = $x - 3

■比較演算子

a == b // aはbと等しい
a != b // aはbと等しくない
a < b // aはb未満
a >= b // aはb以上である
a <= b // aはb以下である

■論理演算子

|| // or 
&& // and 
! // not 

--------------------------------------------




--------------------------------------------------------
■ウィンドウ作成
--------------------------------------------------------

{
/* 
「-exists」フラグは:指定した名前のウィンドウが存在するかどうかによってtrueまたはfalseを返します。
「if」コマンドでは( )の中の結果がTrueであればそれに続くコマンドを実行する。
*/

string $window = `window -title test aaa`;

if(`window -exists aaa`)
deleteUI aaa;

formLayout ;

button -label"ボタンの名前" ;

//window -title test aaa;
showWindow $window ;

}


string $kaz = 123 ;

if(`window -exists aaa`)
deleteUI aaa;

string $windowA = `window -title test aaa`;

//formLayout ;
columnLayout;
button -label "ボタン1" -command "print $kaz";

showWindow $windowA ;


window -title "レイアウト1";
columnLayout;
button -label "A";
rowLayout -numberOfColumns 2 -columnWidth2 20 20;
button -label "B";
button -label "C";
setParent ..;

/*
-numberOfColumn 2
横に何個の部品を並べるかを指定します。

-columnWidth2 20 20
各部品を並べる間隔の指定です。(2 個の場合) 
この場合、B・C ボタンがそれぞれ 20 ピクセル幅の範囲にレイアウトされます。 
3 個の部品を並べる場合には代わりに -columnWidth3 を使用します。

setParent ..;
rowLayout の有効範囲の終りです。 
これ以後は columnLayout が有効になるので、これ以降は部品が縦に並びます。
*/

button -label "D";
rowLayout -numberOfColumns 3 -columnWidth3 20 20 20;
button -label "E";
button -label "F";
button -label "G";
setParent ..;
showWindow;





//ボタンの間隔のパラメーター
int $cWibth = 20;

if(`window -ex XXX`)
deleteUI XXX;

string $winX = `window -title "kmoriyama" XXX`;
columnLayout;
button -label "A";

rowLayout -numberOfColumns 2 -columnWidth2 $cWibth $cWibth;
button -label "B";
button -label "C";
setParent ..;

rowLayout -numberOfColumns 3 -columnWidth3 $cWibth $cWibth $cWibth;
button -label "D";
button -label "E";
button -label "F";
setParent ..;

rowLayout -numberOfColumns 4 -columnWidth4 $cWibth $cWibth $cWibth $cWibth;
button -label "G";
button -label "H";
button -label "I" -w 20;
button -label "J";
setParent ..;

showWindow $winX;

========================================
アニムレイヤーを作成して、特定のリグを適用する
========================================

string $anmName = "Pose";

string $setRo = $anmName + ".rotationAccumulationMode" ;
string $setSc = $anmName + ".scaleAccumulationMode" ;

animLayer $anmName;

setAttr $setRo 0;
setAttr $setSc 1;

select -cl ;
select -r Rigroot Righara Rigkoshi Rigmune Rigkubi Rigatama Rigashi_RVec Rigashi_LVec Rigtekubi_LVec Rigtekubi_RVec Rigashi_RAll Rigashi_RReverse Rigtsumasaki_RReverse Rigtsumasaki_RDummy Rigashi_LAll Rigashi_LReverse Rigtsumasaki_LReverse Rigtsumasaki_LDummy ;

animLayer -e -addSelectedObjects -excludeScale -excludeDynamic -excludeBoolean -excludeEnum $anmName;

========================================
チャンネルボックスの余計なチャンネルの非表示
========================================
setAttr ノード名.ini 0;//これで非表示
setAttr ノード名.ini 2;//これで初期化。1ではないようです。

========================================
アニムカーブを検索してフレーム移動
========================================
int $StarFrame = `getAttr PRM.StartFrame`;
int $EndFrame = `getAttr PRM.EndFrame`;
int $LoopStart = `getAttr PRM.LoopStart`;
int $LoopEnd = `getAttr PRM.LoopEnd`;

string $animCurve[] = `ls -type animCurveTL -type animCurveTU -type animCurveTA -type animCurveTT`;
keyframe -edit -r -timeChange (-$LoopEnd) $animCurve;

playbackOptions -ast $StarFrame -aet ($EndFrame - $LoopEnd) -min $StarFrame -max ($EndFrame - $LoopEnd)

========================================
textフィールドウィンドウ
========================================
window;
columnLayout -adj true;
textField;
textFieldButtonGrp -label "ラベル" -text "textFieldButtonGrp" -buttonLabel "ボタン";
showWindow;


rowLayout -numberOfColumns 2;
button -label "<-StartOrEnd->" -w 102 -command "command7" ;

text -label "テストメッセージ";
separator -height 1 -style "double";
text -label "テストメッセージ";

========================================
選択したキーのアトリビュートネームをメモ帳に書き出す
========================================

//BlShapeのkeyを全て選択してく実行してください。
{
string $attName[] = `keyframe -q -name`;
$size = size($attName);

for($i=0; $i<$size; $i++){
string $FilePath = "C:/Users/k_moriyama.MEDIAV/Desktop/ぶれんどたーげっとリスト.txt"; //書き込み用テキストの場所指定
string $blnamea[] = `ls -typ blendShape`;
string $blnamea2 = $blnamea[0] + "_";
string $output = substituteAllString($attName[$i], $blnamea2 , "");
system("echo " + $output + ">> " + $FilePath);
}
print ("total = " + $size );
}

========================================
改行
========================================

string\n;// "\n"で改行

string $aaa = $attName[$i] + "\n";




例:

//BlShapeのkeyを全て選択してく実行してください。
{
string $attName[] = `keyframe -q -name`;
$size = size($attName);

for($i=0; $i<$size; $i++){
string $aaa = $attName[$i] + "\n";//MAYA上では"\"はスラッシュを逆のヤツになる。
print $aaa;
}
print ("total = " + $size );
}


========================================
.txtに書き込むmelSample
========================================

if(`window -q -exists TsTimeWindow`) deleteUI TsTimeWindow;

window TsTimeWindow;
columnLayout;
textFieldButtonGrp -bc "TsTimeCmd" -bl "OK" TsTimeTFG; //文末の"TsTimeTFG"はこのボタンの名称と思われ!

showWindow TsTimeWindow;

global proc TsTimeCmd(){
string $FilePath = "C:/Users/k_moriyama.MEDIAV/Desktop/test1.txt"; //書き込み用テキストの場所指定
string $time = `about -ct`; //多分、現在の時刻を取得して、変数に格納してる。
string $output = `textFieldButtonGrp -q -tx TsTimeTFG`; //"TsTimeTFG"という名前のフィールドの内容を"-q"を使って問い、取得してる。

system("echo " + $time + " " + $output + ">> " + $FilePath);
//deleteUI TsTimeWindow;
}

========================================
ボタン付ウィンドウテンプレ
========================================

//ウィンドウ、ボタン生成--------------------------------------------

string $windowName = "buttonWin" ; //ウィンドウ名はこの変数で指定してください。
string $windowTitle = "適当" ; //ウィンドウに表示するタイトルはこの変数で指定してください。


if(`window -exists $windowName`)
deleteUI $windowName;

window -w 100 -h 30 -title $windowTitle $windowName;
columnLayout;
button -label "ボタン1" -w 206 -command "command1";

rowLayout -numberOfColumns 4 ;
button -label "ボタン2" -w 50 -command "command2";
button -label "ボタン3" -w 50 -command "command3";
button -label "ボタン4" -w 50 -command "command4";
button -label "ボタン5" -w 50 -command "command5";


setParent ..;
rowLayout -numberOfColumns 2;

// button -label "ボタン6" -w 102 -command "timRangeCTRL" ;
button -label "ボタン7" -w 102 -command "select PRM" ;
button -label "ボタン8" -w 102 -command "command6" ;

setParent ..;

rowLayout -numberOfColumns 2;
button -label "ボタン9" -w 206 -command "command7" ;

setParent ..;


showWindow $windowName ;


//ボタンのコマンド生成--------------------------------------------

proc command1() //ボタン1
{
playblast -format avi -filename "C:/Users/k_moriyama.MEDIAV/Desktop/test1" -offScreen
-forceOverwrite -sequenceTime 0 -clearCache 1 -viewer 1 -showOrnaments 0 -fp 0 -percent 100 -compression "none" -quality 100 -widthHeight 1280 720;

}

proc command2() //ボタン2
{
print "コマンドを記述してください";
}

========================================
選択したオブジェクトのビジビリティをoff
========================================

string $sentaku[] = ` ls -sl -tr ` ;
int $kazu = ` size ( $sentaku ) ` ;
int $x ;

for ( $x = 0 ; $x < $kazu ; $x++ )
{
string $listShp[] = `listRelatives -s`;
string $visib = $listShp[$x] + ".visibility";
int $joutai = `getAttr $visib`;

if( $joutai == 1 )
{
setAttr $visib 0;
}
else
{
setAttr $visib 1;
}//elseのブロックエンド
}//forのブロックエンド

========================================
エクスプレッションMemo
========================================

================================================================================
■「基本的な記述の仕方」のメモ
================================================================================
joint1.translateZ = joint2.translateZ * 0.3;//ジョイント1(tz)にジョイント2の"tz*0.3"の値を代入

================================================================================
■指定フレーム数、遅れて追従するエクスプレッション
================================================================================
{
$ct = `currentTime -q`; //現在のフレーム位置
int $tm = 15; //遅れるフレーム数

if($ct >= $tm)
{
pSphere1.translateX = `getAttr -t ($ct - $tm) pCube1.tx`;
}
else
{
pSphere1.translateX = `getAttr -t 1 pCube1.tx`;
}
}



========================================
シェイプノードをペアレント
========================================
parent -shape -r;

※"シェイプノード"→"ペアレント先のトランスフォームノード"を選択して実行しないとエラーになる。


========================================
シェイプノード名取得
========================================
listRelatives -s;//選択されたオブジェクトのShapeノード名を取得する





========================================
選択されたオブジェクトのキーフレームの範囲とレンジの範囲を合わせる
========================================
selectKey -time ":";
float $allKeys[] = sort(`keyframe -q -sl`);
playbackOptions -min $allKeys[0] -max $allKeys[(size($allKeys) -1)];





========================================
シーン全体のアニメーションのキーを一括でオフセットする
========================================

global proc offsetAllAnimation(int $offsetVal)
{
string $animCurve[] = `ls -type animCurveTL -type animCurveTU -type animCurveTA -type animCurveTT`;
keyframe -edit -r -timeChange $offsetVal $animCurve;
}

animCurveの種類は、 input がTimeなら animCurveT(L U A T)
DrivenKeyのように  inputがDouble(数値)なら animCurveU(L U A T)
それぞれ、
L distance
A angle
T time
U double
の意味。
OffsetするのはDrivenKey以外のTimeと接続しているものなので animCurveT系のノードをリストし、
keyframe に -r(相対移動)のフラグを付ける。


========================================
文字列の置き換えコマンド
========================================
substituteっていうコマンドは

substitute A B C;

でBの文字列の中にあるAという文字列をCで置き換えるというコマンドです。

A:"B"内をこの文字列で検索する
B:置き換え対象の文字列
C:この文字列に置き換える



========================================
ボタンのサイズをウィンドウにあわせる
========================================
例: rowLayout -numberOfColumns 4 -adjustableColumn 1;//横にボタンを並べるレイアウト

レイアウトに「-adjustableColumn 1」フラグをつける。0で多分off。


========================================
実行するたびにon/offを切り替える書き方
========================================
setAttr time1.enableTimewarp (!`getAttr time1.enableTimewarp`);

・多分()内で、取得した数値を[!]コマンド?で反転することでon⇔off切り替えを実現している。
・一行で済むから美しい!


========================================
チェックボックスの状態を取得
========================================
string $checkBox1 = `checkBox -label "スケールX"`;//チェックボックスは変数に格納する
if(`checkBox -q -value $checkBox1`)//チェックボックスの状態[-value]を[-q]で取得してonならif実行
{
print "チェックボックスのチェックがonなら実行"
}


========================================
アトリビュートがノード上に存在を確認(attributeExistsコマンド)
========================================
基本: attributeExists("attributeName","nodeName")

例: if (attributeExists("visibility","mySphere")) {
setAttr mySphere.visibility on;
}

・指定のノードに指定したアトリビュートが存在するかを確認できます。


========================================
サイズ、位置などを復元しない
========================================
windowPref -remove $WindowName このコマンドを実行することで復元をやめさせることができる。
「showWindow」の前に実行させる。

windowPref -enableAll false ┬このコマンドでウィンドウ生成コマンドを挟む
windowPref -enableAll true ┘


========================================
ファイルに書き出す
========================================

$exampleFileName = "C:/Users/k_moriyama.MEDIAV/Desktop/test1.txt";//ファイルパスを変数に格納
$fileId=`fopen $exampleFileName "w"`;//ファイル識別子を変数に格納

/*
■識別子の種類↓
"w" 書き込み用のファイルを開く(ファイルの以前の内容を破棄する)
"a" 書き込み用にアペンドする(ファイルの最後にアペンドする)
"r" 読み取り用に開く
*/

fprint $fileId "書き込みたい文字列(変数指定可)";
fclose $fileId;//終了する


2014年7月1日火曜日

メモ_nuke

選択したノードの後に指定のノードを作って値も入れる

sn = nuke.selectedNodes()
for i in sn:

nuke.nodes.Colorspace(channels = 'all',colorspace_in = 3 ).setInput(0, i)

print nuke.selectedNode()
スクリプトで指定する項目の文字列が表示される

sn = nuke.selectedNodes()
for i in sn:

i.knob('frame_rate').setValue(30)


sn = nuke.selectedNodes()
for i in sn:
    i.knob('width').setValue(2560)

    i.knob('height').setValue(720)

sn = nuke.selectedNodes()
for i in sn:

nuke.nodes.Premult().setInput(0,i)

snSR = nuke.allNodes('ScanlineRender')
for i in snSR:

    i['samples'].setValue(6)


for a in nuke.allNodes():
    if a.Class()=='Constant':
        a['format'].setValue('2080x1520')
最後の行コロンを付けない...