SyntaxHighlighter

2016年9月15日木曜日

setProjectRootSettings

import nuke,nukescripts

def setProjectRootSettings():
    #
    setProjectFps = nuke.root()['fps'].setValue(30)
    #
    def largeFormat():
        sn = nuke.selectedNode()
        if sn.Class() != 'Read':
            print('#[WARNING]: リードノードが選択されてません')
            normalFormat()
        else:
            targetSizeFormat        = nuke.selectedNode().knob("format").value()
            sizeFormatWidth         = targetSizeFormat.width()
            sizeFormatHeight        = targetSizeFormat.height()
            sizeFormatPixelAspect   = targetSizeFormat.pixelAspect()
            hogehogeLarge               = str(sizeFormatWidth) + " " + str(sizeFormatHeight) + " " + str(sizeFormatPixelAspect) + " " + "hogehoge(large)"
            nuke.addFormat( hogehogeLarge )
            nuke.root()['format'].setValue("hogehoge(large)")
            setProjectFps

    def normalFormat():
        hogehogeNormalSize = '2520 1418 hogehoge(normal)'
        nuke.addFormat( hogehogeNormalSize )
        nuke.root()['format'].setValue("hogehoge(normal)")
        setProjectFps

    nodeSelected = nuke.nodesSelected()
    #print nodeSelected
    if nodeSelected == False:
        normalFormat()
    else:
        largeFormat()

setProjectRootSettings()

2015年12月29日火曜日

openDirectory


var currentDate         = dateAcquisition()[0] +"_"+ dateAcquisition()[1] +"_"+ dateAcquisition()[2] ;
var currentTime         = dateAcquisition()[3] +"_"+ dateAcquisition()[4];
//カレントのAepファイルのパス "-project project_path"
var aepProjectFileAbsolutePath  = app.project.file.absoluteURI;
//カレントのAepファイルのバージョン
var aepFileVersion              = fileNameVersionExtension(aepProjectFileAbsolutePath)[4];
//年月日取得
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 ];
}
//ファイル名と拡張子とバージョン取得
function fileNameVersionExtension(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];
  //ファイルネーム要素
  var fileNameElement       = fileName.split("_");
  var fileVersionAryLength  = fileNameElement.length -1;
  var fileVersion           = fileNameElement[fileVersionAryLength];
  return [fileFullName , fileName , fileExtension , fileNameElement , fileVersion ];
}

function openDirectory() {
  var aepPathObj            = new Folder(app.project.file.path);

  var imagesDir             = app.project.file.path +"/"+ "images";
  var imagesDirObj          = new Folder( imagesDir );
  var outputDir             = app.project.file.path +"/"+ "images" +"/"+ aepFileVersion;
  var outputDirObj          = new Folder( outputDir );

  var userTempDirObj        = new Folder ( Folder.temp) ;
  var aerenderDir           = (userTempDirObj.toString() + "/afterEffect/aerender/");
  var aerenderDirObj        = new Folder( aerenderDir );
  var aeBatDir              = (userTempDirObj.toString() + "/afterEffect/aerender/batch/");
  var aeBatchDirObj         = new Folder( aeBatDir );
  var aeTodayBatchDirObj    = new Folder( aeBatDir + currentDate );
  var aepDir                = (userTempDirObj.toString() + "/afterEffect/aerender/project/");
  var aepDirObj             = new Folder( aepDir );
  var aepTodayDirObj        = new Folder( aepDir + currentDate );
  return [ aepPathObj , imagesDirObj , outputDirObj , userTempDirObj , aerenderDirObj , aeBatchDirObj , aeTodayBatchDirObj , aepDirObj , aepTodayDirObj];
}

function openAepCopyDir() {
  if (openDirectory()[8].exists == true) {
    openDirectory()[8].execute();
  }else {
    if (openDirectory()[7].exists == true) {
      openDirectory()[7].execute();
    }else {
      if (openDirectory()[4].exists == true) {
        openDirectory()[4].execute();
      }else {
        if (openDirectory()[3].exists == true) {
          openDirectory()[3].execute();
        }else {
          alert("ないっす!!!((((;゚Д゚))))ガクガクブルブル");
        }
      }
    }
  }
}

function openAepBatDir() {
  if (openDirectory()[6].exists == true) {
    openDirectory()[6].execute();
  }else {
    if (openDirectory()[5].exists == true) {
      openDirectory()[5].execute();
    }else {
      if (openDirectory()[4].exists == true) {
        openDirectory()[4].execute();
      }else {
        if (openDirectory()[3].exists == true) {
          openDirectory()[3].execute();
        }else {
          alert("ないっす!!!((((;゚Д゚))))ガクガクブルブル");
        }
      }
    }
  }
}

function openImagesDir() {
  if (openDirectory()[2].exists == true) {
    openDirectory()[2].execute();
  }else {
    if (openDirectory()[1].exists == true) {
      openDirectory()[1].execute();
    }else {
      if (openDirectory()[0].exists == true) {
        openDirectory()[0].execute();
      }else {
        alert("ないっす!!!((((;゚Д゚))))ガクガクブルブル");
      }
    }
  }
}

function openAepDir() {
  if (openDirectory()[0].exists == true) {
    openDirectory()[0].execute();
  }else {
    alert("ないっす!!!((((;゚Д゚))))ガクガクブルブル");
  }
}

function inputPromptOpenDirectory() {
  var selectChoice = prompt("0-2を入力してください\n"+
                    "0:カレントAEPファイルのフォルダを開く\n"+
                    "1:カレントイメージフォルダを開く\n"+
                    "2:バッチファイルフォルダを開く"
                    ,"0"
                    ,"OpenDirectory");
  if (selectChoice != null) {
    if (selectChoice == 0) {
      openAepDir();
    }else if (selectChoice == 1) {
      openImagesDir();
    }else if (selectChoice == 2) {
      openAepBatDir();
    }else if (selectChoice == 3) {
      openAepCopyDir();
    }else {
      alert("むりっす:-p");
    }
  }else {
    alert("キャンセルされました");
  }
}
inputPromptOpenDirectory()

2015年12月27日日曜日

setRenderOutput

レンダーキューでアクティブなキューの設定をする(ディレクトリも作成)

//年月日取得
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 ];
}
//ファイル名と拡張子とバージョン取得
function fileNameVersionExtension(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];
  //ファイルネーム要素
  var fileNameElement       = fileName.split("_");
  var fileVersionAryLength  = fileNameElement.length -1;
  var fileVersion           = fileNameElement[fileVersionAryLength];
  return [fileFullName , fileName , fileExtension , fileNameElement , fileVersion ];
}
//コマンドラインオプション
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 compostionLayerName(i){
  var compositonName      = commandLineOption(i)[0];
  var compNameElement     = compositonName.split("_");
  var compNameAryLength   = compNameElement.length -1;
  var compLayerName       = compNameElement[compNameAryLength];
  return [ compLayerName ];
}
//
function makeOutputDir(i){
  var compLayerName = compostionLayerName(i)[0];
  var folder        = app.project.file.path +"/"+ "images" +"/"+ aepFileVersion  +"/"+ compLayerName;
  folderObj = new Folder(folder);
  folderObj.create();
  return [ folder ];
}
//
function setRenderOutput(i,selectChoice){
  //パディング指定部分の文字列
  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");
  var curRnedSet                  = app.project.renderQueue.item(i).outputModule(1);
  var renderAbsolutePath          = app.project.renderQueue.item(i).outputModule(1).file.absoluteURI;
  var fileNeme                    = fileNameVersionExtension(renderAbsolutePath);
  var renderOutputFolder          = makeOutputDir(i)[0];
  if (selectChoice == 0) {
    if ((frameCountPadding.test(fileNeme[0]) == 1)&&(sequenceImageFile.test(fileNeme[0]) == 1)) {
      curRnedSet.file = new File(renderOutputFolder +"/"+  fileNameSetImage );
    }
    else if ((frameCountPadding.test(fileNeme[0]) == 0)&&(sequenceImageFile.test(fileNeme[0]) == 1)) {
      curRnedSet.file = new File(renderOutputFolder +"/"+  fileNameSetImage );
    }
    else if (movieSoundFile.test(fileNeme[0]) == 1) {
      curRnedSet.file = new File(renderOutputFolder +"/"+  fileNameSetMovieSound );
    }
    //
  }else if (selectChoice == 1) {
    curRnedSet.applyTemplate(outputModuleProject);
    curRnedSet.file = new File(renderOutputFolder +"/"+  fileNameSetImage );
    //
  }else if (selectChoice == 2) {
    if ((frameCountPadding.test(fileNeme[0]) == 1)&&(sequenceImageFile.test(fileNeme[0]) == 1)) {
      curRnedSet.applyTemplate(outputModuleImage);
      curRnedSet.file = new File(renderOutputFolder +"/"+  fileNameSetImage );
    }
    else if ((frameCountPadding.test(fileNeme[0]) == 0)&&(sequenceImageFile.test(fileNeme[0]) == 1)) {
      curRnedSet.applyTemplate(outputModuleImage);
      curRnedSet.file = new File(renderOutputFolder +"/"+  fileNameSetImage );
    }
    else if (movieSoundFile.test(fileNeme[0]) == 1) {
      curRnedSet.applyTemplate(outputModuleMovieSound);
      curRnedSet.file = new File(renderOutputFolder +"/"+  fileNameSetMovieSound );
    }
  }else {
  }
}
//
function inputPromptSetRenderOutput(){
  var selectChoice = prompt("0-2を入力してください\n"+
                    "0:出力モジュールは変更せず出力先を設定\n"+
                    "1:出力モジュールを一括設定して出力先を設定!\n"+
                    "2:出力モジュールを設定して出力先を設定(ファイル判別)"
                    ,"0"
                    ,"setRenderPath");
  if (selectChoice != null){
    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                    = fileNameVersionExtension(renderAbsolutePath);
        if (renderQueActiveCompostion == 1) {
          makeOutputDir(i);
          setRenderOutput(i,selectChoice);
        }
        else if(renderQueActiveCompostion == 0) {
          //alert("レンダーキューにアクティブなアイテムがねーっす:-q")
        }
    }
    if (selectChoice <= 2) {
      alert("設定しました");
    }else {
      alert("むりっす:-p");
    }
  }else {
    alert("キャンセルされました")
  }
}

//日時
var currentDate                 = dateAcquisition()[0] +"_"+ dateAcquisition()[1] +"_"+ dateAcquisition()[2] ;
//時刻
var currentTime                 = dateAcquisition()[3] +"_"+ dateAcquisition()[4];
//カレントのAepファイルのパス "-project project_path"
var aepProjectFileAbsolutePath  = app.project.file.absoluteURI;
//カレントのAepファイルの名前
var afterEffectsFileNeme        = fileNameVersionExtension(aepProjectFileAbsolutePath);
//レンダーキューのアイテム数
var renderQueNumberItem         = app.project.renderQueue.numItems;
//カレントのAepファイルのバージョン
var aepFileVersion              = fileNameVersionExtension(aepProjectFileAbsolutePath)[4];
//出力モジュール
var outputModuleImage           = "TIFF シーケンス (アルファ付き)"   //"Photoshop"
var outputModuleMovieSound      = "ロスレス圧縮(アルファ付き)"     //"H.264"
var outputModuleProject         = "Photoshop"                    //"TIFF シーケンス (アルファ付き)"
//ファイル名
var fileNameSetImage            = "[compName]_" + aepFileVersion + "_[####].[fileExtension]";
var fileNameSetMovieSound       = "[compName]_" + aepFileVersion + ".[fileExtension]";
inputPromptSetRenderOutput();

2015年12月24日木曜日

aerenderDiv

//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();

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' )

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日月曜日

メモ_nuke

忘れないように...(^^;

上流のノード取得
for n in node.dependencies()

下流のノード取得
for n in node.dependent()