Skip to content

Instantly share code, notes, and snippets.

@deathponta
Last active August 22, 2018 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deathponta/c46f7d871bf87ad602e45ff0e2797a93 to your computer and use it in GitHub Desktop.
Save deathponta/c46f7d871bf87ad602e45ff0e2797a93 to your computer and use it in GitHub Desktop.
シーン内のアニメーションしているコントローラーなどをすべて選択します。
/*
シーン内のアニメーションしているコントローラーなどをすべて選択します。
*/
// グローバル変数
string $animatedTransforms[];
proc SelectAnimatedTransformNode(){
string $window = "SelectAnimatedTransformNode";
if(`window -exists $window`){deleteUI $window;}
window -t $window -w 300 -tb true $window;
columnLayout -columnAttach "both" 5 -rowSpacing 10 -columnWidth 250;
button -l "選択 & リスト" -c "SATN_Exec()" -ann "キー設定されているトランスフォームノードをリスト&選択";
rowLayout -nc 3 -adj 2;
text -l "絞り込み";
textField -textChangedCommand "SATN_Search()" -ann "半角小文字のみ対応" "tf_searchBox";
checkBox -l "含まない" -changeCommand "SATN_Search()" -ann "絞り込みワードが含まれているノードを除外します。" "cb_reverse";
setParent ..;
textScrollList -nr 8 -ams true -sc "SATN_SelNodeFromList()" "tsl_animTrans";
showWindow $window;
}
// リスト内の項目を選択した時に、同名オブジェクトを選択する。(複数選択対応)
proc SATN_SelNodeFromList(){
string $transforms[] = `textScrollList -q -si "tsl_animTrans"`;
select $transforms;
}
// 絞り込みボックスに入力した文字列を含むノードのみをリストに反映する
proc SATN_Search(){
global string $animatedTransforms[];
int $isReverse = `checkBox -q -v "cb_reverse"`; // 1 == 文字列を含まないようにする
string $tempTransList[];
string $serachString = `textField -q -text "tf_searchBox"`;
// 【リセット】入力がない時は、表示をリセット
if( $serachString == "" ){
textScrollList -e -ra "tsl_animTrans";
for( $animatedTrans in $animatedTransforms ){
textScrollList -e -a $animatedTrans "tsl_animTrans";
}
return;
}
// 【比較】検索処理
for( $animatedTrans in $animatedTransforms ){
// 小文字へ変換して、文字列がマッチしたばあいは変数に格納
string $lowerStr = `tolower $animatedTrans`;
string $matchStr = `match $serachString $lowerStr`;
// マッチ文字列に一致した項目をストック。
if ( $isReverse == 0 ){
if( size( $matchStr ) > 0){
string $tempArray[] = {$animatedTrans};
appendStringArray( $tempTransList , $tempArray , 1 );
}
}
// マッチ文字列が存在しないものをストック。
else{
if( size( $matchStr ) == 0){
string $tempArray[] = {$animatedTrans};
appendStringArray( $tempTransList , $tempArray , 1 );
}
}
}
// 絞り込んだリストに更新
textScrollList -e -ra "tsl_animTrans";
for( $animatedTrans in $tempTransList ){
textScrollList -e -a $animatedTrans "tsl_animTrans";
}
}
proc SATN_Exec(){
global string $animatedTransforms[];
select -cl;
string $transforms[] = `ls -type transform`;
// リストを一旦クリア
textScrollList -e -ra "tsl_animTrans";
// すべてのトランスフォームから・・
for( $trans in $transforms ){
// 接続されているカーブをリストアップ
$animCrvs = `findKeyframe -c $trans`;
// ドリブンキーの場合はリストに登録しない
int $isDrivenKey = 0;
for( $animCrv in $animCrvs ){
string $type = `nodeType $animCrv`;
$isDrivenKey_temp = `gmatch $type "animCurveU?"`;
if( $isDrivenKey_temp == 1 ){
$isDrivenKey = $isDrivenKey_temp;
continue;
}
}
if( $isDrivenKey == 1 )continue;
// 1つでもアニメーションカーブがあればそのオブジェクトを選択
if( size($animCrvs) > 0 ){
select -add $trans;
// リストに追加
textScrollList -e -a $trans "tsl_animTrans";
}
}
// グローバル変数にアニメーとしているノードを格納
$animatedTransforms = `textScrollList -q -ai "tsl_animTrans"`;
// 絞り込みを実行
SATN_Search();
print ( "キー設定されているオブジェクト : " + size( `ls -sl` ) );
}
SelectAnimatedTransformNode();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment