Skip to content

Instantly share code, notes, and snippets.

@deathponta
Created October 6, 2018 06:34
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/3cf53a85a9780174443762855fdfa244 to your computer and use it in GitHub Desktop.
Save deathponta/3cf53a85a9780174443762855fdfa244 to your computer and use it in GitHub Desktop.
再帰処理テンプレ
/*
再帰処理テンプレ
指定されたフォルダ以下のmltファイルをすべてリストします。
mlt 部分を、 ma , mb に書き換えることで通常のMayaでも利用可
*/
proc RecursiveProcess(){
string $window = "RecursiveProcess";
if( window( "-exists" , $window ) ){
deleteUI $window;
}
window( "-title" , $window , "-width" , 300 , "-toolbox" , true , $window );
columnLayout( "-columnAttach" , "both" , 5 , "-rowSpacing" , 10 , "-columnWidth" , 250 );
textField( "-tx" , "" , "tf_dirPath" );
button( "-l" , "上記フォルダ以下のmltファイルをリストアップ" , "-c" , "SearchDirFiles(textField( \"-q\" , \"-tx\" , \"tf_dirPath\" ) )" );
showWindow $window;
}
proc SearchDirFiles( string $_path ){
string $Dirpass = $_path ;
string $list[] = `getFileList -fld $Dirpass` ;
for( $s in $list ){
$fullPath = $_path+"/"+$s;
// ***.mlt ファイルが見つかった場合のみ処理を行うときはこの if 文内に処理を追記
if( gmatch( $s , "*.mlt") > 0 ){
print ( $fullPath+"\n");
/*
ここにファイルに対して行いたい処理を記述。
例えば、シーンを開いてシーン内にある特定のノードを削除したりとか。
*/
}
SearchDirFiles( $fullPath );
}
}
RecursiveProcess();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment