Created
April 18, 2018 16:46
-
-
Save deathponta/7ec8399c971fc87b8bcc7d82b88bc048 to your computer and use it in GitHub Desktop.
選択したオブジェクトの中から、カレントフレームにキーが無いオブジェクトを選択除外する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
選択したオブジェクトの中から、カレントフレームにキーが無いオブジェクトを選択除外する | |
結果的に、カレントフレームにキーが有るオブジェクトだけが選択される | |
グラフエディタでキーフレームを選択している場合は、キーフレームが打たれているオブジェクトのみ選択される | |
■ 使い方 | |
キーフレームがあるフレームを、カレントフレームにして実行 | |
*/ | |
proc FromSelectKey( string $_selObj[] ){ | |
/*------------------------------ | |
グラフエディターでキーを選択している場合はそちらを優先してフィルタ | |
カレントフレームにあるキーは処理しない | |
------------------------------*/ | |
// 選択したオブジェクトを回し・・・ | |
for( $obj in $_selObj ){ | |
// グラフエディタ上でキーフレームが選択されていないオブジェクトは選択から除外 | |
float $keyFrame[] = `keyframe -q -sl $obj`; | |
if( size($keyFrame) == 0 ){ | |
select -d $obj; | |
$isKeyframeFilter = true; | |
continue; | |
} | |
} | |
} | |
proc FromCurrentFrame( string $_selObj[] ){ | |
/*------------------------------ | |
グラフエディタでキーを選択していない場合はカレントフレームのキーでフィルタ | |
------------------------------*/ | |
select -clear; | |
// 選択オブジェクトのキーフレームがカレントフレームに存在しない場合は、選択を解除 | |
$currentTime = `currentTime -q`; | |
for( $obj in $_selObj ){ | |
// キー設定可能なアトリビュート分処理 | |
for( $attr in `listAttr -k $obj` ){ | |
// キー設定可能だけど、キーが打たれていない場合はスルー | |
if( size(`keyframe -at $attr -q $obj`) == 0 )continue; | |
$frames = `keyframe -at $attr -q $obj`; | |
// アトリビュート内のキーの数分処理 | |
for( $frame in $frames ){ | |
// キーフレームが現在のフレームにあったら通る | |
if( $frame == $currentTime ){ | |
select -add $obj; | |
print ($obj + "." + $attr + " はカレントフレームにキーを持ちます\n"); | |
} | |
} | |
} | |
} | |
} | |
proc FilterSelectObj(){ | |
string $selObj[] = `ls -sl`; | |
if( size(`keyframe -q -sl`) == 0 ){ | |
FromCurrentFrame( $selObj ); | |
}else{ | |
FromSelectKey( $selObj ); | |
} | |
} | |
FilterSelectObj(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment