//aerender スキップフレーム版
var currentDate = dateAcquisition()[0] +"_"+ dateAcquisition()[1] +"_"+ dateAcquisition()[2] ;
var currentTime = dateAcquisition()[3] +"_"+ dateAcquisition()[4];
var randnum = Math.floor( Math.random() * 100000 );
var userTempDir = new Folder (Folder.temp);
//カレントのAepファイルのパス "-project project_path"
var aepProjectFileAbsolutePath = app.project.file.absoluteURI;
//カレントのAepファイルの名前
var afterEffectsFileNeme = fileNameExtension(aepProjectFileAbsolutePath);
//カレントaerenderのファイルのパス
var aeRenderAbsolutePath = '"C:\\Program Files\\Adobe\\Adobe After Effects '+ applicationVersion() +'\\Support Files\\aerender.exe"';
//レンダーキューのアイテム数
var renderQueNumberItem = app.project.renderQueue.numItems
//メモリの使用量とキャッシュの使用量 "-mem_usage image_cache_percent max_mem_percent"
//年月日取得
function dateAcquisition(){
//今日の日時示
var now = new Date();
var year = now.getYear(); // 年
var month = now.getMonth() + 1; // 月
var day = now.getDate(); // 日
var hour = now.getHours(); // 時
var min = now.getMinutes(); // 分
var sec = now.getSeconds(); // 秒
if(year < 2000) { year += 1900; }
// 数値が1桁の場合、頭に0を付けて2桁で表示する指定
if(month < 10) { month = "0" + month; }
if(day < 10) { day = "0" + day; }
if(hour < 10) { hour = "0" + hour; }
if(min < 10) { min = "0" + min; }
if(sec < 10) { sec = "0" + sec; }
return [ year , month , day , hour , min , sec ];
}
//afterEffectsの確認
function applicationVersion(){
var applicationBuildNumber = app.buildName;
var applicationVersion = applicationBuildNumber.substring(0,4);
if (applicationVersion == 10.0) {
var applicationVersionCharacter = "CS5";
return applicationVersionCharacter;
}else if (applicationVersion == 10.5){
var applicationVersionCharacter = "CS5.5";
return applicationVersionCharacter;
}else if ((applicationVersion == 11.0)||(applicationVersion == 11.1)){
var applicationVersionCharacter = "CS6";
return applicationVersionCharacter;
}else if ((applicationVersion == 13.0)||(applicationVersion == 13.1)){
var applicationVersionCharacter = "CC 2014";
return applicationVersionCharacter;
}else{
return "バージョンを確認してください";
}
}
//ファイル名と拡張子取得
function fileNameExtension(AbsolutePath){
//拡張子込ファイル名
var filePathAry = AbsolutePath.split("/");
var filePathAryLength = filePathAry.length -1;
var fileFullName = filePathAry[filePathAryLength];
//ファイル名とファイルタイプ(拡張子)
var fileNameAry = fileFullName.split(".");
var fileNameAryLength = fileNameAry.length -1;
var fileName = fileNameAry[0];
var fileExtension = fileNameAry[fileNameAryLength];
return [fileFullName , fileName , fileExtension];
}
//プロジェクトファイルをtempへコピー
function copyAepFileToTemp(copySourceAep,copyDestinationDir){
var currentAepFile = new File( copySourceAep );
var copyAepFile = new File( afterEffectsProjDir + currentDate +"/"+ afterEffectsFileNeme[0] );
currentAepFile.copy(copyAepFile);
}
//ログファイル書き出し先 "-log logfile_path"
function createPathAepLogDir(){
var afterEffectsLogDir = (userTempDir.toString() + "/afterEffect/aerender/log/" + currentDate);
var createAfterEffectsLogDir = new Folder( afterEffectsLogDir ).create();
return [ createAfterEffectsLogDir , afterEffectsLogDir ];
}
//プロジェクトファイルコピー先
function createPathAepProjDir(){
var afterEffectsProjDir = (userTempDir.toString() + "/afterEffect/aerender/project/");
var createAfterEffectsAepDir = new Folder( afterEffectsProjDir + currentDate ).create();
return [ createAfterEffectsAepDir , afterEffectsProjDir ];
}
//バッチファイル書き出し先
function createPathAepBatDir(){
var afterEffectsBatDir = (userTempDir.toString() + "/afterEffect/aerender/batch/");
var createAfterEffectsBatDir = new Folder( afterEffectsBatDir + currentDate ).create();
return [ createAfterEffectsBatDir , afterEffectsBatDir ];
}
//バッチファイル作成
function createPathBatchFile(afterEffectsBatDir){
var afterEffectsBatFileName = ("aerender" +"_" + afterEffectsFileNeme[1] +"_" + currentTime +"_"+ randnum + ".bat");
var afterEffectsBatFilePath = afterEffectsBatDir + currentDate +"/"+ afterEffectsBatFileName;
var afterEffectsBatFile = new File( afterEffectsBatFilePath );
return [ afterEffectsBatFile , afterEffectsBatFilePath , afterEffectsBatFileName ];
}
//バッチファイルにコマンド追記
function addCommandToBatchFile(afterEffectsBatFile){
var batFile = new File(afterEffectsBatFile);
var aepFileName = fileNameExtension(aepProjectFileAbsolutePath)[0];
batFile.open("w");
batFile.writeln("@echo off");
batFile.writeln("title" +" "+ aepFileName +" "+ applicationVersion() +" "+ "batch start at"+" "+ "%time%");
for ( i = 0; i < batCommandLineAry.length; i++){
batFile.writeln(batCommandLineAry[i]) + "\n";
}
batFile.close();
}
//コマンドラインオプション
function commandLineOption(i){
//コンポジション名 "-comp comp_name"
var compositonName = app.project.renderQueue.item(i).comp.name;
//コンポジションのフレームレート
var compositonFrameRate = app.project.renderQueue.item(i).comp.frameRate;
//コンポジションのデュレーション
var compositonDuration = app.project.renderQueue.item(i).comp.duration * compositonFrameRate;
//コンポジションのスタートフレーム "-s start_frame"
var compostionStartTime = app.project.renderQueue.item(i).comp.displayStartTime * compositonFrameRate;
//コンポジションのエンドフレーム "-e end_frame"
var compostionEndTime = (compostionStartTime + compositonDuration) - 1;
//ワークエリアのスタートフレーム "-s start_frame"
var compostionWorkAreaStart = app.project.renderQueue.item(i).comp.workAreaStart * compositonFrameRate;
//ワークエリアのデュレーション
var compositonWorkAreaDuration = app.project.renderQueue.item(i).comp.workAreaDuration * compositonFrameRate;
//コンポジションのエンドフレーム "-e end_frame"
var compostionWorkAreaEndTime = (compostionWorkAreaStart + compositonWorkAreaDuration) - 1;
//レンダリング出力先 "-output output_path"
var renderPath = app.project.renderQueue.item(i).outputModule(1).file;
//レンダリング出力先その2 ※Absoluteをつけないと配列にならない
var renderAbsolutePath = app.project.renderQueue.item(i).outputModule(1).file.absoluteURI;
return [ compositonName , compostionStartTime , compostionEndTime , compostionWorkAreaStart , compostionWorkAreaEndTime , renderAbsolutePath ]
}
//分割しない場合のコマンドライン
function indivisibleFileComandLine(i){
var comp = commandLineOption(i)[0];
var indivisibleFile = "start /wait"
+" "+ '"' + comp +" "+ applicationVersion() +" "+ "rendering start at"+" "+ "%time%"+'"'
+" "+ aeRenderAbsolutePath
+" "+ "-project" + " " + aepProjectFileAbsolutePath
+" "+ "-rqindex" + " " + i
+" "+ "-sound ON"
+" "+ "-continueOnMissingFootage";
batCommandLineAry.push(indivisibleFile);
}
//分割する場合のコマンドライン
function divideFileComandLine(i){
var comp = commandLineOption(i)[0];
var divideNum = numDiv
for (k = 1 ; k <= divideNum ; k++){
if (k < divideNum) {
var indivisibleFile = "start"
+" "+ '"' + comp +" "+ applicationVersion() +" "+ "rendering start at"+" "+ "%time%"+'"'
+" "+ aeRenderAbsolutePath
+" "+ "-project" + " " + aepProjectFileAbsolutePath
+" "+ "-rqindex" + " " + i
+" "+ "-RStemplate" + " " + "マルチマシン設定"
+" "+ "-continueOnMissingFootage";
batCommandLineAry.push(indivisibleFile);
}else if (k == divideNum) {
var indivisibleFile = "start /wait"
+" "+ '"' + comp +" "+ applicationVersion() +" "+ "rendering start at"+" "+ "%time%"+'"'
+" "+ aeRenderAbsolutePath
+" "+ "-project" + " " + aepProjectFileAbsolutePath
+" "+ "-rqindex" + " " + i
+" "+ "-RStemplate" + " " + "マルチマシン設定"
+" "+ "-sound ON"
+" "+ "-continueOnMissingFootage";
batCommandLineAry.push(indivisibleFile);
}else {
batCommandLineAry.push(":-q")
}
}
}
//レンダーキューのアクティブキュー情報取得バッチファイルへ書き出し
function renderQueueToBatchFile(){
//パディング指定部分の文字列
var frameCountPadding = new RegExp("%5B#{1,7}%5D","i");
//ムービもしくはサウンドファイルの拡張子の文字列
var movieSoundFile = new RegExp("(aif|avi|f4v|flv|mp4|m4v|mp3|mpg|mxf|mov|wav)$","i");
//イメージファイルの拡張子文字列
var sequenceImageFile = new RegExp("dpx|cin|iff|jpg|exr|png|psd|hdr|sgi|tif|tga","i");
for (i = 1 ; i <= renderQueNumberItem ; i++){
var renderQueActiveCompostion = app.project.renderQueue.item(i).render;
var renderAbsolutePath = app.project.renderQueue.item(i).outputModule(1).file.absoluteURI;
var fileNeme = fileNameExtension(renderAbsolutePath);
if (renderQueActiveCompostion == 1) {
//alert (fileNeme[0] + "を" +"レンダーするっす:-p");
if ((frameCountPadding.test(fileNeme[0]) == 1)&&(sequenceImageFile.test(fileNeme[0]) == 1)) {
if (numDiv == 0){
//alert("レンダリングしないっす:-q");
}else if (numDiv == 1) {
//alert("レンダリングするっす:-q");
indivisibleFileComandLine(i);
}else if (numDiv >= 2 && numDiv <= 12) {
//alert("レンダリングするっす:-q");
divideFileComandLine(i);
}
}
else if ((frameCountPadding.test(fileNeme[0]) == 0)&&(sequenceImageFile.test(fileNeme[0]) == 1)) {
indivisibleFileComandLine(i);
}
else if (movieSoundFile.test(fileNeme[0]) == 1) {
indivisibleFileComandLine(i);
}
}
else if(renderQueActiveCompostion == 0) {
//alert ("レンダーキューにアクティブなアイテムがねーっす:-q")
}
}
}
//入力ダイアログ
function inputPrompt(){
var text = prompt("並列でレンダリングする数を入力してください \n 2-8 をお勧めします","4");
if (text != null){
//alert("並列数は"+text+"です")
}else {
alert("キャンセルされました")
}
return [ text ];
}
//レンダリング条件分岐
function renderingBranch(){
if (numDiv == 0){
alert("レンダリングしないっす:-q");
}else if (numDiv == 1) {
renderQueueToBatchFile();
createBatchFile;
addCommandToBatchFile(afterEffectsBatFile);
alert("並列レンダリングしないっす:-q");
}else if (numDiv >= 2 && numDiv <= 8) {
renderQueueToBatchFile();
createBatchFile;
addCommandToBatchFile(afterEffectsBatFile);
alert("並列レンダリングするっす:-D");
}else if (numDiv >= 9 && numDiv <= 12) {
renderQueueToBatchFile();
createBatchFile;
addCommandToBatchFile(afterEffectsBatFile);
alert("お勧めしないぴょん:-p");
}else if (numDiv >= 13) {
alert("むりっす(;´・ω・)");
}
}
//メイン
var numDiv = inputPrompt()[0];
var batCommandLineAry = new Array();
var afterEffectsBatFile = createPathBatchFile(createPathAepBatDir()[1])[1];
var batFile = new File(afterEffectsBatFile);
var createBatchFile = createPathBatchFile(createPathAepBatDir()[1]);
renderingBranch();
batFile.execute();
SyntaxHighlighter
2015年12月24日木曜日
2015年10月2日金曜日
nuke_memo
root関係めも
nuke.root()['format'].setValue("HD")
nuke.root()['format'].setValue( "square_2K" )
scriptFormats = nuke.formats()
for f in scriptFormats:
print f.name()
print f.width()
print f.height()
print f.pixelAspect()
print 10*'-'
nuke.root()['format'].value().name() # renvoi le nom du format
nuke.root()['format'].value().setName("nomDuFormat")
print nuke.root()['format'].value().width()
print nuke.root()['format'].value().height()
print nuke.root()['format'].value().pixelAspect()
print nuke.root()['format'].value().name()
square2k = '2048 2048 square 2k'
nuke.addFormat( square2k )
nuke.root()['format'].setValue(nuke.addFormat("1024 960 1"))
quare2k = '2048 2048 square 2k'
nuke.addFormat( square2k )
nuke.root()[‘format’].setValue( ‘square 2k’ )
# DEFINE BASE AND PROXY FORMATS
square2k = '2048 2048 square 2k'
square1k = '1024 1024 square 1k'
# ADD FORMATS TO SESSION
for f in ( square2k, square1k ):
nuke.addFormat( f )
# SET THE ROOT TO USE BOTH BASE AND PROXY FORMATS
root = nuke.root()
root['format'].setValue( 'square 2k' )
root['proxy_type'].setValue( 'format' )
root['proxy_format'].setValue( 'square 1k' )
nuke.root()['format'].setValue("HD")
nuke.root()['format'].setValue( "square_2K" )
scriptFormats = nuke.formats()
for f in scriptFormats:
print f.name()
print f.width()
print f.height()
print f.pixelAspect()
print 10*'-'
nuke.root()['format'].value().name() # renvoi le nom du format
nuke.root()['format'].value().setName("nomDuFormat")
print nuke.root()['format'].value().width()
print nuke.root()['format'].value().height()
print nuke.root()['format'].value().pixelAspect()
print nuke.root()['format'].value().name()
square2k = '2048 2048 square 2k'
nuke.addFormat( square2k )
nuke.root()['format'].setValue(nuke.addFormat("1024 960 1"))
quare2k = '2048 2048 square 2k'
nuke.addFormat( square2k )
nuke.root()[‘format’].setValue( ‘square 2k’ )
# DEFINE BASE AND PROXY FORMATS
square2k = '2048 2048 square 2k'
square1k = '1024 1024 square 1k'
# ADD FORMATS TO SESSION
for f in ( square2k, square1k ):
nuke.addFormat( f )
# SET THE ROOT TO USE BOTH BASE AND PROXY FORMATS
root = nuke.root()
root['format'].setValue( 'square 2k' )
root['proxy_type'].setValue( 'format' )
root['proxy_format'].setValue( 'square 1k' )
2015年10月1日木曜日
選んだオブジェクトにロケータをペアレントコンストレイントしてベイク
選んだオブジェクトにロケータをペアレントコンストレイントしてベイク
proc BakeLocator(){
string $Selobjs[] =`ls -sl -tr`;
int $Selsum = `size( $Selobjs )`;
//print $Selsum;
string $addStr = "_nukeLightLoc";
string $tagStr = "hoge";
string $repStr = "hogehoge";
string $conStr = "_parentConstraint1";
//print ($addStr + "," + $tagStr + "," + $repStr + "," + $conStr);
int $x;
for($x = 0; $x < $Selsum; $x++ ){
CreateLocator;
string $LocSelA[] = `ls -sl`;
select $Selobjs[$x];
string $RnmLoc = (substituteAllString($Selobjs[$x], $tagStr , $repStr )) + $addStr ;
string $rnmObj = `rename $LocSelA[0] $RnmLoc`;
select -r $Selobjs[$x] $rnmObj;
//ペアレントコンストレイントコマンド
doCreateParentConstraintArgList 1 { "0","0","0","0","0","0","0","1","","1" };
parentConstraint -weight 1;
print($rnmObj + $conStr);
}
select -r ("*" + $addStr);
string $SelLocs[] =`ls -sl -tr`;
int $SelLocSum = `size( $SelLocs )`;
string $sFrame =`playbackOptions -query -minTime`;
string $eFrame =`playbackOptions -query -maxTime`;
string $bRange = ($sFrame + ":" + $eFrame);
//print $bRange;
bakeSimulation -t $bRange -at "tx" -at "ty" -at "tz" -at "rx" -at "ry" -at "rz";
select -r ("*" + $addStr + $conStr);
delete;
}
BakeLocator();
2015年7月13日月曜日
2015年7月2日木曜日
カレントディレクトリ等をExplorerで開くmel
カレントディレクトリ等を開くmel
数字でオープン先を選ぶ
global proc sDirOpen()
{
//-----------------------------------------------------------------------------------------------------
string $fPath = `file -q -sceneName`;
string $fName = `file -q -shortName -sceneName`;
string $sPath = substituteAllString($fPath, $fName , "");
string $iPath = substituteAllString($sPath, "scenes/" , "images/");
string $itPath = substituteAllString($sPath, "scenes/" , "images/tmp/");
//-----------------------------------------------------------------------------------------------------
string $text;
string $result = `promptDialog
-title "sDirOpen"
-message "input Number:"
-text "0"
-button "OK" -button "Cancel"
-defaultButton "OK" -cancelButton "Cancel"
-dismissString "Cancel"`;
if ($result == "OK")
{
$text = `promptDialog -query -text`;
if($text == 0)
{
print ($sPath + "\n");
string $sOsPath = substituteAllString($sPath, "/", "\\");
print ($sOsPath+ "\n");
system ("explorer.exe "+ $sOsPath);
}
else if($text == 1)
{
print ($iPath + "\n");
string $iOsPath = substituteAllString($iPath, "/", "\\");
system ("explorer.exe "+ $iOsPath);
}
else if($text == 2)
{
string $itOsPath = substituteAllString($itPath, "/", "\\");
system ("explorer.exe "+$itOsPath);
}
else
{
string $window = `window -title "alart"
-iconName "Short Name"
-widthHeight 64 24`;
columnLayout -adjustableColumn true;
button -label "ねーっす :-P" -command ("deleteUI -window " + $window);
setParent ..;
showWindow $window;
//print "ねーっす";
}
}
}
sDirOpen()
数字でオープン先を選ぶ
global proc sDirOpen()
{
//-----------------------------------------------------------------------------------------------------
string $fPath = `file -q -sceneName`;
string $fName = `file -q -shortName -sceneName`;
string $sPath = substituteAllString($fPath, $fName , "");
string $iPath = substituteAllString($sPath, "scenes/" , "images/");
string $itPath = substituteAllString($sPath, "scenes/" , "images/tmp/");
//-----------------------------------------------------------------------------------------------------
string $text;
string $result = `promptDialog
-title "sDirOpen"
-message "input Number:"
-text "0"
-button "OK" -button "Cancel"
-defaultButton "OK" -cancelButton "Cancel"
-dismissString "Cancel"`;
if ($result == "OK")
{
$text = `promptDialog -query -text`;
if($text == 0)
{
print ($sPath + "\n");
string $sOsPath = substituteAllString($sPath, "/", "\\");
print ($sOsPath+ "\n");
system ("explorer.exe "+ $sOsPath);
}
else if($text == 1)
{
print ($iPath + "\n");
string $iOsPath = substituteAllString($iPath, "/", "\\");
system ("explorer.exe "+ $iOsPath);
}
else if($text == 2)
{
string $itOsPath = substituteAllString($itPath, "/", "\\");
system ("explorer.exe "+$itOsPath);
}
else
{
string $window = `window -title "alart"
-iconName "Short Name"
-widthHeight 64 24`;
columnLayout -adjustableColumn true;
button -label "ねーっす :-P" -command ("deleteUI -window " + $window);
setParent ..;
showWindow $window;
//print "ねーっす";
}
}
}
sDirOpen()
2015年4月1日水曜日
カレントディレクトリをExplorerで開く
別アプリで書かれていたものを丸パクリしたもの
import nuke
import os.path
import sys
def openCurrent():
path = nuke.root().name()
if path == 'Root':
print('#[WARNING]: No scene is opened.')
return
nkp = '\\'.join(path.split('/')[:-1])
if os.path.isdir(nkp):
os.popen('explorer "%s"' % nkp)
print('>> Open: %s' % nkp)
else:
print('#[WARANING]: Directory not found: %s' % nkp)
openCurrent()
<pre class="brush: python;">
// ココにソースを記述
</pre>
import nuke
import os.path
import sys
def openCurrent():
path = nuke.root().name()
if path == 'Root':
print('#[WARNING]: No scene is opened.')
return
nkp = '\\'.join(path.split('/')[:-1])
if os.path.isdir(nkp):
os.popen('explorer "%s"' % nkp)
print('>> Open: %s' % nkp)
else:
print('#[WARANING]: Directory not found: %s' % nkp)
openCurrent()
<pre class="brush: python;">
// ココにソースを記述
</pre>
2015年3月11日水曜日
nukeでコマ落とし
コマ落としとバレ消しの注意書き
import nuke
readNodes = nuke.allNodes("Read")
for node in nuke.allNodes():
node["selected"].setValue(0)
#print node
for read in readNodes:
read["selected"].setValue(1)
first = read["first"].getValue()
last = read["last"].getValue()
timeWarp = nuke.createNode("TimeWarp")
timeWarp["lookup"].setAnimated(0)
timeWarp["lookup"].animations()[0].setKey(first, first)
timeWarp["lookup"].animations()[0].setKey(last, last)
if first%2 == 0:
timeWarp["lookup"].setExpression('(int(curve/2))*2')
else:
timeWarp["lookup"].setExpression('((int((curve+1)/2))*2)-1')
NoteOfCaution = nuke.nuke.createNode("Text2")
NoteOfCaution["message"].setValue('バレ消しの必要はありません')
NoteOfCaution["font"].setValue("Adobe Gothic Std", "B")
NoteOfCaution["font_size"].setValue(72)
if first%2 == 0:
NoteOfCaution["opacity"].setExpression('(frame%2)')
else:
NoteOfCaution["opacity"].setExpression('((frame+1)%2)')
read["selected"].setValue(0)
timeWarp["selected"].setValue(0)
NoteOfCaution["selected"].setValue(0)
import nuke
readNodes = nuke.allNodes("Read")
for node in nuke.allNodes():
node["selected"].setValue(0)
#print node
for read in readNodes:
read["selected"].setValue(1)
first = read["first"].getValue()
last = read["last"].getValue()
timeWarp = nuke.createNode("TimeWarp")
timeWarp["lookup"].setAnimated(0)
timeWarp["lookup"].animations()[0].setKey(first, first)
timeWarp["lookup"].animations()[0].setKey(last, last)
if first%2 == 0:
timeWarp["lookup"].setExpression('(int(curve/2))*2')
else:
timeWarp["lookup"].setExpression('((int((curve+1)/2))*2)-1')
NoteOfCaution = nuke.nuke.createNode("Text2")
NoteOfCaution["message"].setValue('バレ消しの必要はありません')
NoteOfCaution["font"].setValue("Adobe Gothic Std", "B")
NoteOfCaution["font_size"].setValue(72)
if first%2 == 0:
NoteOfCaution["opacity"].setExpression('(frame%2)')
else:
NoteOfCaution["opacity"].setExpression('((frame+1)%2)')
read["selected"].setValue(0)
timeWarp["selected"].setValue(0)
NoteOfCaution["selected"].setValue(0)
登録:
投稿 (Atom)