Skip to content

Instantly share code, notes, and snippets.

@deathponta
Last active June 18, 2018 10:56
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/8d4a6111c57c284fdb02026227be9dd2 to your computer and use it in GitHub Desktop.
Save deathponta/8d4a6111c57c284fdb02026227be9dd2 to your computer and use it in GitHub Desktop.
選択したキーの内、変化の無いキーだけを選択維持する
/*
選択したキーの内、変化の無いキーだけを選択維持する
シーン内のアニメーションカーブを全選択
select `ls -typ animCurve`;
size `ls -sl`;
*/
proc SelectStaticKey_Exec(){
// 選択したキーフレームのアニメーションカーブ名まずは配列で取得
string $animCrvNames[] = `keyframe -q -name`;
int $deleteAnimCrvCount = `size($animCrvNames)`;
for( $animCrvName in $animCrvNames ){
// カーブ内のすべてのキーフレームの値を配列で取得し・・・
float $keys[] = `keyframe -q -valueChange $animCrvName`;
// 比較して、値に変化があるアニメーションカーブを選択解除
// キーが1つしか無いものも変化の無いキーと言えますね
for( $key in $keys ){
if( $keys[0] != $key){
selectKey -rm $animCrvName;
$deleteAnimCrvCount--;
break;
}
}
}
print ($deleteAnimCrvCount + " / " + `size($animCrvNames)` + " 個の AnimCurve は値に変化がありません");
}
proc SelectStaticKey(){
string $window = "SelectStaticKey";
if(`window -exists $window`) deleteUI $window;
window -title $window -width 300 -toolbox true $window;
columnLayout -columnAttach "both" 5 -rowSpacing 10 -columnWidth 250;
frameLayout -label "使い方" -cl true -cll true -bgc 0 0 0;
text -l "グラフエディタで多くのキーを選択して実行。";
text -l "キーの値の変化がないカーブだけが選択される。";
text -l "これは、不要なキーを削減するのに役立つ。";
setParent ..;
//floatSliderGrp -l "しきい値" -field true -adj 1 -min 0 -max 0.1 -precision 3 -value 0.01 "ReductKeySample";
button -l "Select ( ^ _ ^ )" -command "SelectStaticKey_Exec" -ann "選択したキーの内、変化の無いキーだけを選択維持する";
showWindow $window;
}
SelectStaticKey();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment