From 81ae9c5398d4e2e816fd3ce755465beda8535f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20V=C3=A1squez=20P=C3=A9rez?= Date: Thu, 13 Apr 2017 18:03:59 -0700 Subject: [PATCH] Fixed an error on a string declaration that broke the yToolMenu when addig said tool. --- ScriptUI Panels/yToolBox.jsx | 2 +- yScripts/RenderToProject.jsx | 224 ++++++++++++++++++++++++++- yScripts/y_CompHerder.jsx | 244 ++++++++++++++++++++++++++++- yScripts/y_CompRenamingTools.jsx | 115 ++++++++++++++ yScripts/y_GenericNewScript.jsx | 253 ++++++++++++++++++++++++++++++- yScripts/y_setStructure.jsx | 128 +++++++++++++++- 6 files changed, 961 insertions(+), 5 deletions(-) create mode 100644 yScripts/y_CompRenamingTools.jsx diff --git a/ScriptUI Panels/yToolBox.jsx b/ScriptUI Panels/yToolBox.jsx index c8f1715..a319973 100644 --- a/ScriptUI Panels/yToolBox.jsx +++ b/ScriptUI Panels/yToolBox.jsx @@ -84,7 +84,7 @@ YTB = //alert( aTool.info.name ); this.tools.push( aTool ); - + //alert( aTool.btnLauyout ); var btn = this.window.grp.main.add( aTool.btnLauyout ); btn.onClick = aTool.activate; diff --git a/yScripts/RenderToProject.jsx b/yScripts/RenderToProject.jsx index 10319fd..288434d 100644 --- a/yScripts/RenderToProject.jsx +++ b/yScripts/RenderToProject.jsx @@ -1 +1,223 @@ -#include "../yScripts/y_JSExtensions.jsx"; function RenderToProject() { this.info = { name : "RenderToProject", version : 0.1, stage : "development", description : "Set Renders to project appropriate folders according to the studio's folder structure.", url : "yorchnet.com" }; this.appearence = { buttonHeight : 30, buttonWidth : 126 }; this.resources = { icon : new File('yNet.png'), }; this.methods = { pad : function ( n , pad ) { zeros = ""; for ( i = 0 ; i < pad ; i ++ ) { zeros+="0"; } n = String(n); padded = zeros.substr( 0, pad - n.length ) + String(n) ; return padded }, getTodayTag : function(){ var today = new Date(); var month_component = pad(String(today.getMonth()+1),2); var date_component = pad(today.getDate(),2); var full_year_component = String(today.getFullYear()) var year_component = full_year_component.substr(full_year_component.length - 2,full_year_component.length ); var tag = month_component + date_component + year_component return tag; }, getOutputBasePath : function(){ var file = app.project.file; var file_path = String(app.project.file); var gfx_output_base = "05_Graphics_Output"; var endtag_output_extra = "02_EndTags"; var scene_output_extra = "01_GFX_Scenes"; var vfx_output_base = "03_Composite_Outputs"; var vfx_output_base; var gfx_string = "09_Graphics"; var vfx_string = "08_Composite"; var endtag_string = "EndTags"; var search_gfx = file_path.search(gfx_string); var search_vfx = file_path.search(vfx_string); var search_endtag = file_path.search(endtag_string); var base_path; if ( search_gfx != -1 ){ var base_path = file_path.substr(0,search_gfx+gfx_string.length)+"/"+gfx_output_base; if ( search_endtag != -1 ){ base_path += "/" + endtag_output_extra; } base_path += "/" + scene_output_extra + "/" + this.getTodayTag(); } if( search_vfx != -1 ){ var base_path = file_path.substr(0,search_vfx+vfx_string.length)+"/"+vfx_output_base + "/" + this.getTodayTag();; } return base_path; }, setRendersToProjectPath : function(){ var q = app.project.renderQueue; //check the render queue item is not already rendered. for ( var i = 1 ; i <= q.numItems ; i ++ ){ item = q.item(i); //3015 is QUEUED //3013 is NEEDS_OUTPUT if ( (item.status == 3015) || (item.status == 3013) ){ for ( var j = 1 ; j <= item.numOutputModules ; j ++ ){ o_module = item.outputModule(j); var old_name = item.comp.name.replace(".","_"); //alert(old_name); if ( o_module.file != null ){ var new_path = this.getOutputBasePath(); var new_folder = Folder( new_path ); if ( !new_folder.exists ){ new_folder.create(); } //alert(new_path + "/" + old_name) var new_file = new File( new_path + "/" + old_name ); o_module.file = new_file ; //alert ( new_path ); //o_module.file= new_file; } var p = String( o_module.file.path ).split("/"); p.splice(0,3); var s = ""; for ( var i = 0 ; i < p.length ; i ++ ){ s += "\n"+p[i]; } alert( "Rendering to :" + "\n" + s + "\n\n" + o_module.file.name ); } } } }, } this.init = function init() { this.btnLauyout = "button\ {\ preferredSize: ['" + this.appearence.buttonWidth + "','" + this.appearence.buttonHeight + "'],\ text:'" + this.info.name + "',\ helpTip:'" + this.info.description + "'\ }"; this. res = "window\ {\ type:'palette',\ text:'" + this.info.name + ' ' + this.info.ver + ' ' + this.info.stage + "',\ info: Group \ {\ alignment:['center','bottom'],\ icon: Image \ {\ icon:'" + this.resources.icon.path + '/' + this.resources.icon.name + "',\ preferredSize: [15, 18]\ },\ website: StaticText\ {\ text:'" + this.info.url + "',\ alignment:['fill','center']\ },\ }\ }"; } this.createUI = function createUI( ) { var myUI = this; var res = " window {\ text: 'RenderToProject',\ alignment: ['fill','fill'], \ alignChildren: ['center','top'], \ orientation: 'column', \ resizeable: 'true'\ }"; myUI.window = new Window( res ); myUI.window.layout.layout(true); myUI.window.show(); myUI.window.layout.onResizing = myUI.window.layout.onResize = function () { myUI.layout.resize();} //EVENT HANDLERS /* myUI.window.tabs.search_tab.doItBtn.onClick = function(){ var search_str = myUI.window.tabs.search_tab.searchGrp.searchString.text; var replace_str = myUI.window.tabs.search_tab.replaceGrp.replaceString.text; myUI.methods.replace( myUI.methods.getSelectedProjectItems() , search_str , replace_str ); }; myUI.window.tabs.suprefix.suprefixGrp.pre.prefixBtn.onClick = function(){ var pre = myUI.window.tabs.suprefix.suprefixGrp.su.prefixString.text; myUI.methods.prefix( myUI.methods.getSelectedProjectItems() , pre ); }; myUI.window.tabs.suprefix.suprefixGrp.su.sufixBtn.onClick = function(){ var su = myUI.window.tabs.suprefix.suprefixGrp.su.sufixString.text; myUI.methods.suffix( myUI.methods.getSelectedProjectItems() , su ); }; myUI.window.tabs.rename_tab.renameGrp.renameBtn.onClick = function(){ var new_name = myUI.window.tabs.rename_tab.renameGrp.renameString.text; myUI.methods.rename( myUI.methods.getSelectedProjectItems() , new_name ); }; */ //END EVENT HANDLERS return(this); } this.yMainFunction = function yMainFunction() { w = this.methods.setRendersToProjectPath(); } this.activate = function activate() { this.yTool.yMainFunction(); } this.init(); return this; } //CHECKS that the toolbox exists, and if it doesn´t it runs the script on its own. if (typeof(YTB)=='undefined') { rtp = new RenderToProject(); rtp.activate(); } else { YTB.addTool(new RenderToProject()); } \ No newline at end of file +#include "../yScripts/y_JSExtensions.jsx"; + +function RenderToProject() +{ + this.info = + { + name : "RenderToProject", + version : 0.1, + stage : "development", + description : "Set Renders to project appropriate folders according to the studio folder structure.", + url : "yorchnet.com" + }; + this.appearence = + { + buttonHeight : 30, + buttonWidth : 126 + }; + this.resources = + { + icon : new File('yNet.png'), + }; + this.methods = + { + pad : function ( n , pad ) { + zeros = ""; + for ( i = 0 ; i < pad ; i ++ ) + { + zeros+="0"; + } + n = String(n); + padded = zeros.substr( 0, pad - n.length ) + String(n) ; + return padded + }, + getTodayTag : function(){ + var today = new Date(); + var month_component = pad(String(today.getMonth()+1),2); + var date_component = pad(today.getDate(),2); + var full_year_component = String(today.getFullYear()) + var year_component = full_year_component.substr(full_year_component.length - 2,full_year_component.length ); + var tag = month_component + date_component + year_component + return tag; + }, + getOutputBasePath : function(){ + var file = app.project.file; + var file_path = String(app.project.file); + var gfx_output_base = "05_Graphics_Output"; + var endtag_output_extra = "02_EndTags"; + var scene_output_extra = "01_GFX_Scenes"; + var vfx_output_base = "03_Composite_Outputs"; + var vfx_output_base; + var gfx_string = "09_Graphics"; + var vfx_string = "08_Composite"; + var endtag_string = "EndTags"; + + var search_gfx = file_path.search(gfx_string); + var search_vfx = file_path.search(vfx_string); + var search_endtag = file_path.search(endtag_string); + var base_path; + + if ( search_gfx != -1 ){ + var base_path = file_path.substr(0,search_gfx+gfx_string.length)+"/"+gfx_output_base; + if ( search_endtag != -1 ){ + base_path += "/" + endtag_output_extra; + } + base_path += "/" + scene_output_extra + "/" + this.getTodayTag(); + } + + if( search_vfx != -1 ){ + var base_path = file_path.substr(0,search_vfx+vfx_string.length)+"/"+vfx_output_base + "/" + this.getTodayTag();; + } + + return base_path; + }, + setRendersToProjectPath : function(){ + var q = app.project.renderQueue; + //check the render queue item is not already rendered. + + for ( var i = 1 ; i <= q.numItems ; i ++ ){ + item = q.item(i); + //3015 is QUEUED + //3013 is NEEDS_OUTPUT + + if ( (item.status == 3015) || (item.status == 3013) ){ + for ( var j = 1 ; j <= item.numOutputModules ; j ++ ){ + o_module = item.outputModule(j); + var old_name = item.comp.name.replace(".","_"); + //alert(old_name); + if ( o_module.file != null ){ + + + var new_path = this.getOutputBasePath(); + var new_folder = Folder( new_path ); + if ( !new_folder.exists ){ + new_folder.create(); + } + //alert(new_path + "/" + old_name) + var new_file = new File( new_path + "/" + old_name ); + o_module.file = new_file ; + //alert ( new_path ); + //o_module.file= new_file; + + } + + var p = String( o_module.file.path ).split("/"); + + p.splice(0,3); + + var s = ""; + + for ( var i = 0 ; i < p.length ; i ++ ){ + s += "\n"+p[i]; + } + alert( "Rendering to :" + "\n" + s + "\n\n" + o_module.file.name ); + } + } + } + }, + } + + this.init = function init() + { + + this.btnLauyout = + "button\ + {\ + preferredSize: ['" + this.appearence.buttonWidth + "','" + this.appearence.buttonHeight + "'],\ + text:'" + this.info.name + "',\ + helpTip:'" + this.info.description + "'\ + }"; + + this. res = + "window\ + {\ + type:'palette',\ + text:'" + this.info.name + ' ' + this.info.ver + ' ' + this.info.stage + "',\ + info: Group \ + {\ + alignment:['center','bottom'],\ + icon: Image \ + {\ + icon:'" + this.resources.icon.path + '/' + this.resources.icon.name + "',\ + preferredSize: [15, 18]\ + },\ + website: StaticText\ + {\ + text:'" + this.info.url + "',\ + alignment:['fill','center']\ + },\ + }\ + }"; + } + this.createUI = function createUI( ) + { + var myUI = this; + var res = + " window {\ + text: 'RenderToProject',\ + alignment: ['fill','fill'], \ + alignChildren: ['center','top'], \ + orientation: 'column', \ + resizeable: 'true'\ + }"; + + myUI.window = new Window( res ); + myUI.window.layout.layout(true); + + myUI.window.show(); + + myUI.window.layout.onResizing = myUI.window.layout.onResize = function () { myUI.layout.resize();} + + //EVENT HANDLERS + + /* + myUI.window.tabs.search_tab.doItBtn.onClick = function(){ + var search_str = myUI.window.tabs.search_tab.searchGrp.searchString.text; + var replace_str = myUI.window.tabs.search_tab.replaceGrp.replaceString.text; + myUI.methods.replace( myUI.methods.getSelectedProjectItems() , search_str , replace_str ); + }; + + myUI.window.tabs.suprefix.suprefixGrp.pre.prefixBtn.onClick = function(){ + var pre = myUI.window.tabs.suprefix.suprefixGrp.su.prefixString.text; + myUI.methods.prefix( myUI.methods.getSelectedProjectItems() , pre ); + }; + + myUI.window.tabs.suprefix.suprefixGrp.su.sufixBtn.onClick = function(){ + var su = myUI.window.tabs.suprefix.suprefixGrp.su.sufixString.text; + myUI.methods.suffix( myUI.methods.getSelectedProjectItems() , su ); + }; + + myUI.window.tabs.rename_tab.renameGrp.renameBtn.onClick = function(){ + var new_name = myUI.window.tabs.rename_tab.renameGrp.renameString.text; + myUI.methods.rename( myUI.methods.getSelectedProjectItems() , new_name ); + }; + */ + + //END EVENT HANDLERS + + return(this); + } + + this.yMainFunction = function yMainFunction() + { + w = this.methods.setRendersToProjectPath(); + } + this.activate = function activate() + { + this.yTool.yMainFunction(); + } + + this.init(); + return this; +} + +//CHECKS that the toolbox exists, and if it doesn´t it runs the script on its own. +if (typeof(YTB)=='undefined') +{ + rtp = new RenderToProject(); + rtp.activate(); +} +else +{ + YTB.addTool(new RenderToProject()); +} diff --git a/yScripts/y_CompHerder.jsx b/yScripts/y_CompHerder.jsx index a3bb429..c8c1721 100644 --- a/yScripts/y_CompHerder.jsx +++ b/yScripts/y_CompHerder.jsx @@ -1 +1,243 @@ -#include "../yScripts/y_JSExtensions.jsx"; function CompHerder() { this.info = { name : "CompHerder", version : 0.1, stage : "development", description : "Tool to manage project items.", url : "yorchnet.com" }; this.appearence = { buttonHeight : 30, buttonWidth : 126 }; this.resources = { icon : new File('yNet.png'), }; this.methods = { pad : function ( n , pad ) { zeros = ""; for ( i = 0 ; i < pad ; i ++ ) { zeros+="0"; } n = String(n); padded = zeros.substr( 0, pad - n.length ) + String(n) ; return padded }, replace: function( items , string , newString ){ for ( i = 0 ; i < items.length ; i ++ ){ var item = items[i]; item.name = item.name.replace( string , newString ); } return true; }, getSelectedProjectItems: function (){ var items = []; var p = app.project; for ( var i = 1 ; i <= p.numItems ; i ++ ){ var item = p.item(i); if ( item.selected ){ items.push(item); } } //items = items.concat( app.project.activeItem.selectedItems ); return items; }, suffix: function ( items , suffix ){ for ( i = 0 ; i < items.length ; i ++ ){ var item = items[i]; if ( item.name.search( suffix ) != (item.name.length - suffix.length) ){ item.name+= "_"+suffix; } } return true; }, prefix : function( items , prefix ){ for ( i = 0 ; i < items.length ; i ++ ) { var item = items[i]; if ( item.name.search( prefix ) != 0 ){ item.name = prefix + "_" + item.name; } } return true; }, rename: function ( items , new_name ){ for ( i = 0 ; i < items.length ; i ++ ){ var item = items[i]; item.name = new_name + "_" + i; } } } this.init = function init() { this.btnLauyout = "button\ {\ preferredSize: ['" + this.appearence.buttonWidth + "','" + this.appearence.buttonHeight + "'],\ text:'" + this.info.name + "',\ helpTip:'" + this.info.description + "'\ }"; this. res = "window\ {\ type:'palette',\ text:'" + this.info.name + ' ' + this.info.ver + ' ' + this.info.stage + "',\ info: Group \ {\ alignment:['center','bottom'],\ icon: Image \ {\ icon:'" + this.resources.icon.path + '/' + this.resources.icon.name + "',\ preferredSize: [15, 18]\ },\ website: StaticText\ {\ text:'" + this.info.url + "',\ alignment:['fill','center']\ },\ }\ }"; } this.createUI = function createUI( ) { var myUI = this; var res = "window { \ text: 'CompHerder',\ alignment: ['fill','fill'], \ alignChildren: ['center','top'], \ orientation: 'column', \ resizeable: 'true',\ tabs: Panel {\ type: 'tabbedpanel',\ alignment: ['fill','fill'], \ alignChildren: ['center','top'], \ search_tab: Panel {\ type: 'tab',\ text: 'Search & Replace',\ orientation: 'column', \ alignChildren: ['center','top'], \ searchGrp: Group {\ alignment: ['fill','fill'], \ alignChildren: ['center','top'], \ orientation: 'column', \ searchString: EditText {text:'SEARCH FOR TEXT',alignment: ['fill','center']}, \ },\ replaceGrp: Group {\ alignment: ['fill','fill'], \ alignChildren: ['center','center'], \ orientation: 'column', \ replaceString: EditText {text:'REPLACE WITH TEXT',alignment: ['fill','center']}, \ }\ doItBtn: Button {text: 'Replace in selected Comps', alignment: ['center','center']} , \ }\ suprefix: Panel {\ type: 'tab',\ text: 'Suffix / Prefix',\ orientation: 'column', \ suprefixGrp: Group {\ alignment: ['fill','fill'], \ alignChildren: ['left','center'], \ orientation: 'column', \ pre:Group {\ alignment: ['fill','fill'], \ alignChildren: ['left','center'], \ orientation: 'row', \ prefixString: EditText {text:'PREFIX',alignment: ['fill','center']}, \ prefixBtn: Button {text: 'Preffix'} , \ },\ su:Group{\ alignment: ['fill','fill'], \ alignChildren: ['left','center'], \ orientation: 'row', \ sufixString: EditText {text:'SUFIX',alignment: ['fill','center']}, \ sufixBtn: Button {text: 'Sufix'} , \ }\ },\ },\ rename_tab: Panel {\ type: 'tab',\ text: 'Rename',\ renameGrp: Group {\ alignment: ['fill','fill'], \ alignChildren: ['left','center'], \ orientation: 'row', \ renameString: EditText {text:'NEW NAME',alignment: ['fill','center']}, \ renameBtn: Button {text: 'Rename'} ,\ }\ }\ },\ }"; myUI.window = new Window( res ); myUI.window.layout.layout(true); myUI.window.show(); myUI.window.layout.onResizing = myUI.window.layout.onResize = function () { myUI.layout.resize();} //EVENT HANDLERS myUI.window.tabs.search_tab.doItBtn.onClick = function(){ var search_str = myUI.window.tabs.search_tab.searchGrp.searchString.text; var replace_str = myUI.window.tabs.search_tab.replaceGrp.replaceString.text; myUI.methods.replace( myUI.methods.getSelectedProjectItems() , search_str , replace_str ); }; myUI.window.tabs.suprefix.suprefixGrp.pre.prefixBtn.onClick = function(){ var pre = myUI.window.tabs.suprefix.suprefixGrp.su.prefixString.text; myUI.methods.prefix( myUI.methods.getSelectedProjectItems() , pre ); }; myUI.window.tabs.suprefix.suprefixGrp.su.sufixBtn.onClick = function(){ var su = myUI.window.tabs.suprefix.suprefixGrp.su.sufixString.text; myUI.methods.suffix( myUI.methods.getSelectedProjectItems() , su ); }; myUI.window.tabs.rename_tab.renameGrp.renameBtn.onClick = function(){ var new_name = myUI.window.tabs.rename_tab.renameGrp.renameString.text; myUI.methods.rename( myUI.methods.getSelectedProjectItems() , new_name ); }; return(this); } this.replaceInSelectedItems = function(){ var search_string = "GFX"; var replace_string = "VFX"; } this.yMainFunction = function yMainFunction() { w = this.createUI(); } this.activate = function activate() { this.yTool.yMainFunction(); } this.init(); return this; } //CHECKS that the toolbox exists, and if it doesn´t it runs the script on its own. if (typeof(YTB)=='undefined') { CompHerder = new CompHerder(); CompHerder.activate(); } else { YTB.addTool(new CompHerder()); } \ No newline at end of file +#include "../yScripts/y_JSExtensions.jsx"; + +function CompHerder() +{ + this.info = + { + name : "CompHerder", + version : 0.1, + stage : "development", + description : "Tool to manage project items.", + url : "yorchnet.com" + }; + this.appearence = + { + buttonHeight : 30, + buttonWidth : 126 + }; + this.resources = + { + icon : new File('yNet.png'), + }; + this.methods = + { + pad : function ( n , pad ) { + zeros = ""; + for ( i = 0 ; i < pad ; i ++ ) + { + zeros+="0"; + } + n = String(n); + padded = zeros.substr( 0, pad - n.length ) + String(n) ; + return padded + }, + replace: function( items , string , newString ){ + for ( i = 0 ; i < items.length ; i ++ ){ + var item = items[i]; + item.name = item.name.replace( string , newString ); + } + return true; + }, + getSelectedProjectItems: function (){ + var items = []; + var p = app.project; + for ( var i = 1 ; i <= p.numItems ; i ++ ){ + var item = p.item(i); + if ( item.selected ){ + items.push(item); + } + } + //items = items.concat( app.project.activeItem.selectedItems ); + return items; + }, + suffix: function ( items , suffix ){ + for ( i = 0 ; i < items.length ; i ++ ){ + var item = items[i]; + if ( item.name.search( suffix ) != (item.name.length - suffix.length) ){ + item.name+= "_"+suffix; + } + + } + return true; + }, + prefix : function( items , prefix ){ + for ( i = 0 ; i < items.length ; i ++ ) + { + var item = items[i]; + if ( item.name.search( prefix ) != 0 ){ + item.name = prefix + "_" + item.name; + } + } + return true; + }, + rename: function ( items , new_name ){ + for ( i = 0 ; i < items.length ; i ++ ){ + var item = items[i]; + item.name = new_name + "_" + i; + } + + } + + } + this.init = function init() + { + + this.btnLauyout = + "button\ + {\ + preferredSize: ['" + this.appearence.buttonWidth + "','" + this.appearence.buttonHeight + "'],\ + text:'" + this.info.name + "',\ + helpTip:'" + this.info.description + "'\ + }"; + + this. res = + "window\ + {\ + type:'palette',\ + text:'" + this.info.name + ' ' + this.info.ver + ' ' + this.info.stage + "',\ + info: Group \ + {\ + alignment:['center','bottom'],\ + icon: Image \ + {\ + icon:'" + this.resources.icon.path + '/' + this.resources.icon.name + "',\ + preferredSize: [15, 18]\ + },\ + website: StaticText\ + {\ + text:'" + this.info.url + "',\ + alignment:['fill','center']\ + },\ + }\ + }"; + } + this.createUI = function createUI( ) + { + var myUI = this; + var res = + "window { \ + text: 'CompHerder',\ + alignment: ['fill','fill'], \ + alignChildren: ['center','top'], \ + orientation: 'column', \ + resizeable: 'true',\ + tabs: Panel {\ + type: 'tabbedpanel',\ + alignment: ['fill','fill'], \ + alignChildren: ['center','top'], \ + search_tab: Panel {\ + type: 'tab',\ + text: 'Search & Replace',\ + orientation: 'column', \ + alignChildren: ['center','top'], \ + searchGrp: Group {\ + alignment: ['fill','fill'], \ + alignChildren: ['center','top'], \ + orientation: 'column', \ + searchString: EditText {text:'SEARCH FOR TEXT',alignment: ['fill','center']}, \ + },\ + replaceGrp: Group {\ + alignment: ['fill','fill'], \ + alignChildren: ['center','center'], \ + orientation: 'column', \ + replaceString: EditText {text:'REPLACE WITH TEXT',alignment: ['fill','center']}, \ + }\ + doItBtn: Button {text: 'Replace in selected Comps', alignment: ['center','center']} , \ + }\ + suprefix: Panel {\ + type: 'tab',\ + text: 'Suffix / Prefix',\ + orientation: 'column', \ + suprefixGrp: Group {\ + alignment: ['fill','fill'], \ + alignChildren: ['left','center'], \ + orientation: 'column', \ + pre:Group {\ + alignment: ['fill','fill'], \ + alignChildren: ['left','center'], \ + orientation: 'row', \ + prefixString: EditText {text:'PREFIX',alignment: ['fill','center']}, \ + prefixBtn: Button {text: 'Preffix'} , \ + },\ + su:Group{\ + alignment: ['fill','fill'], \ + alignChildren: ['left','center'], \ + orientation: 'row', \ + sufixString: EditText {text:'SUFIX',alignment: ['fill','center']}, \ + sufixBtn: Button {text: 'Sufix'} , \ + }\ + },\ + },\ + rename_tab: Panel {\ + type: 'tab',\ + text: 'Rename',\ + renameGrp: Group {\ + alignment: ['fill','fill'], \ + alignChildren: ['left','center'], \ + orientation: 'row', \ + renameString: EditText {text:'NEW NAME',alignment: ['fill','center']}, \ + renameBtn: Button {text: 'Rename'} ,\ + }\ + }\ + },\ + }"; + + myUI.window = new Window( res ); + myUI.window.layout.layout(true); + + myUI.window.show(); + + myUI.window.layout.onResizing = myUI.window.layout.onResize = function () { myUI.layout.resize();} + + //EVENT HANDLERS + myUI.window.tabs.search_tab.doItBtn.onClick = function(){ + var search_str = myUI.window.tabs.search_tab.searchGrp.searchString.text; + var replace_str = myUI.window.tabs.search_tab.replaceGrp.replaceString.text; + myUI.methods.replace( myUI.methods.getSelectedProjectItems() , search_str , replace_str ); + }; + + myUI.window.tabs.suprefix.suprefixGrp.pre.prefixBtn.onClick = function(){ + var pre = myUI.window.tabs.suprefix.suprefixGrp.su.prefixString.text; + myUI.methods.prefix( myUI.methods.getSelectedProjectItems() , pre ); + }; + + myUI.window.tabs.suprefix.suprefixGrp.su.sufixBtn.onClick = function(){ + var su = myUI.window.tabs.suprefix.suprefixGrp.su.sufixString.text; + myUI.methods.suffix( myUI.methods.getSelectedProjectItems() , su ); + }; + + myUI.window.tabs.rename_tab.renameGrp.renameBtn.onClick = function(){ + var new_name = myUI.window.tabs.rename_tab.renameGrp.renameString.text; + myUI.methods.rename( myUI.methods.getSelectedProjectItems() , new_name ); + }; + + return(this); + } + this.replaceInSelectedItems = function(){ + var search_string = "GFX"; + var replace_string = "VFX"; + } + + this.yMainFunction = function yMainFunction() + { + w = this.createUI(); + } + this.activate = function activate() + { + this.yTool.yMainFunction(); + } + + this.init(); + return this; +} + +//CHECKS that the toolbox exists, and if it doesn´t it runs the script on its own. +if (typeof(YTB)=='undefined') +{ + CompHerder = new CompHerder(); + CompHerder.activate(); +} +else +{ + YTB.addTool(new CompHerder()); +} diff --git a/yScripts/y_CompRenamingTools.jsx b/yScripts/y_CompRenamingTools.jsx new file mode 100644 index 0000000..2bcee9b --- /dev/null +++ b/yScripts/y_CompRenamingTools.jsx @@ -0,0 +1,115 @@ +#include "../yScripts/y_JSExtensions.jsx"; + +function CompHerder() +{ + this.info = + { + name : "CompHerder", + version : 0.1, + stage : "development", + description : "Generic script to use as a base for new tools.", + url : "yorchnet.com" + }; + this.appearence = + { + buttonHeight : 30, + buttonWidth : 126 + }; + this.resources = + { + icon : new File('yNet.png'), + }; + this.init = function init() + { + + this.btnLauyout = + "button\ + {\ + preferredSize: ['" + this.appearence.buttonWidth + "','" + this.appearence.buttonHeight + "'],\ + text:'" + this.info.name + "',\ + helpTip:'" + this.info.description + "'\ + }"; + + this. res = + "window\ + {\ + type:'palette',\ + text:'" + this.info.name + ' ' + this.info.ver + ' ' + this.info.stage + "',\ + info: Group \ + {\ + alignment:['center','bottom'],\ + icon: Image \ + {\ + icon:'" + this.resources.icon.path + '/' + this.resources.icon.name + "',\ + preferredSize: [15, 18]\ + },\ + website: StaticText\ + {\ + text:'" + this.info.url + "',\ + alignment:['fill','center']\ + },\ + }\ + }"; + } + this.createUI = function createUI() + { + var res = + "window { \ + text: 'CompHerder',\ + alignment: ['fill','fill'], \ + alignChildren: ['left','top'], \ + orientation: 'column', \ + resizeable: 'true',\ + tabs: Panel {\ + type: 'tabbedpanel',\ + alignment: ['fill','fill'], \ + alignChildren: ['left','top'], \ + orientation: 'column', \ + tab1: Panel {\ + type: 'tab',\ + text: 'search & replace'\ + },\ + tab2: Panel {\ + type: 'tab',\ + text: 'suffix/prefix'\ + },\ + tab3: Panel {\ + type: 'tab',\ + text: 'rename'\ + }\ + }\ + }"; + + this.window = new Window( res ); + this.window.layout.layout(true); + /* + this.window.resize(); + this.window.center(); + */ + this.window.show(); + + this.window.layout.onResizing = this.window.layout.onResize = function () {this.layout.resize();} + } + this.yMainFunction = function yMainFunction() + { + this.createUI(); + } + this.activate = function activate() + { + this.yTool.yMainFunction(); + } + + this.init(); + return this; +} + +//CHECKS that the toolbox exists, and if it doesn´t it runs the script on its own. +if (typeof(YTB)=='undefined') +{ + CompHerder = new CompHerder(); + CompHerder.activate(); +} +else +{ + YTB.addTool(new CompHerder()); +} diff --git a/yScripts/y_GenericNewScript.jsx b/yScripts/y_GenericNewScript.jsx index c9be872..e2bb5cb 100755 --- a/yScripts/y_GenericNewScript.jsx +++ b/yScripts/y_GenericNewScript.jsx @@ -1 +1,252 @@ -#include "../yScripts/y_JSExtensions.jsx"; function GenericTool() { this.info = { name : "GenericTool", version : 0.1, stage : "development", description : "Generic script to use as a base for new tools.", url : "yorchnet.com" }; this.appearence = { buttonHeight : 30, buttonWidth : 126 }; this.resources = { icon : new File('yNet.png'), }; this.methods = { pad : function ( n , pad ) { zeros = ""; for ( i = 0 ; i < pad ; i ++ ) { zeros+="0"; } n = String(n); padded = zeros.substr( 0, pad - n.length ) + String(n) ; return padded }, replace: function( items , string , newString ){ for ( i = 0 ; i < items.length ; i ++ ){ var item = items[i]; item.name = item.name.replace( string , newString ); } return true; }, getSelectedProjectItems: function (){ var items = []; var p = app.project; for ( var i = 1 ; i <= p.numItems ; i ++ ){ var item = p.item(i); if ( item.selected ){ items.push(item); } } //items = items.concat( app.project.activeItem.selectedItems ); return items; }, suffix: function ( items , suffix ){ for ( i = 0 ; i < items.length ; i ++ ){ var item = items[i]; if ( item.name.search( suffix ) != (item.name.length - suffix.length) ){ item.name+= "_"+suffix; } } return true; }, prefix : function( items , prefix ){ for ( i = 0 ; i < items.length ; i ++ ) { var item = items[i]; if ( item.name.search( prefix ) != 0 ){ item.name = prefix + "_" + item.name; } } return true; }, rename: function ( items , new_name ){ for ( i = 0 ; i < items.length ; i ++ ){ var item = items[i]; item.name = new_name + "_" + i; } } } this.init = function init() { this.btnLauyout = "button\ {\ preferredSize: ['" + this.appearence.buttonWidth + "','" + this.appearence.buttonHeight + "'],\ text:'" + this.info.name + "',\ helpTip:'" + this.info.description + "'\ }"; this. res = "window\ {\ type:'palette',\ text:'" + this.info.name + ' ' + this.info.ver + ' ' + this.info.stage + "',\ info: Group \ {\ alignment:['center','bottom'],\ icon: Image \ {\ icon:'" + this.resources.icon.path + '/' + this.resources.icon.name + "',\ preferredSize: [15, 18]\ },\ website: StaticText\ {\ text:'" + this.info.url + "',\ alignment:['fill','center']\ },\ }\ }"; } this.createUI = function createUI( ) { var myUI = this; var res = " window {\ text: 'GenericTool',\ alignment: ['fill','fill'], \ alignChildren: ['center','top'], \ orientation: 'column', \ resizeable: 'true'\ }" var res = "window { \ text: 'GenericTool',\ alignment: ['fill','fill'], \ alignChildren: ['center','top'], \ orientation: 'column', \ resizeable: 'true',\ tabs: Panel {\ type: 'tabbedpanel',\ alignment: ['fill','fill'], \ alignChildren: ['center','top'], \ search_tab: Panel {\ type: 'tab',\ text: 'Search & Replace',\ orientation: 'column', \ alignChildren: ['center','top'], \ searchGrp: Group {\ alignment: ['fill','fill'], \ alignChildren: ['center','top'], \ orientation: 'column', \ searchString: EditText {text:'SEARCH FOR TEXT',alignment: ['fill','center']}, \ },\ replaceGrp: Group {\ alignment: ['fill','fill'], \ alignChildren: ['center','center'], \ orientation: 'column', \ replaceString: EditText {text:'REPLACE WITH TEXT',alignment: ['fill','center']}, \ }\ doItBtn: Button {text: 'Replace in selected Comps', alignment: ['center','center']} , \ }\ suprefix: Panel {\ type: 'tab',\ text: 'Suffix / Prefix',\ orientation: 'column', \ suprefixGrp: Group {\ alignment: ['fill','fill'], \ alignChildren: ['left','center'], \ orientation: 'column', \ pre:Group {\ alignment: ['fill','fill'], \ alignChildren: ['left','center'], \ orientation: 'row', \ prefixString: EditText {text:'PREFIX',alignment: ['fill','center']}, \ prefixBtn: Button {text: 'Preffix'} , \ },\ su:Group{\ alignment: ['fill','fill'], \ alignChildren: ['left','center'], \ orientation: 'row', \ sufixString: EditText {text:'SUFIX',alignment: ['fill','center']}, \ sufixBtn: Button {text: 'Sufix'} , \ }\ },\ },\ rename_tab: Panel {\ type: 'tab',\ text: 'Rename',\ renameGrp: Group {\ alignment: ['fill','fill'], \ alignChildren: ['left','center'], \ orientation: 'row', \ renameString: EditText {text:'NEW NAME',alignment: ['fill','center']}, \ renameBtn: Button {text: 'Rename'} ,\ }\ }\ },\ }"; myUI.window = new Window( res ); myUI.window.layout.layout(true); myUI.window.show(); myUI.window.layout.onResizing = myUI.window.layout.onResize = function () { myUI.layout.resize();} //EVENT HANDLERS /* myUI.window.tabs.search_tab.doItBtn.onClick = function(){ var search_str = myUI.window.tabs.search_tab.searchGrp.searchString.text; var replace_str = myUI.window.tabs.search_tab.replaceGrp.replaceString.text; myUI.methods.replace( myUI.methods.getSelectedProjectItems() , search_str , replace_str ); }; myUI.window.tabs.suprefix.suprefixGrp.pre.prefixBtn.onClick = function(){ var pre = myUI.window.tabs.suprefix.suprefixGrp.su.prefixString.text; myUI.methods.prefix( myUI.methods.getSelectedProjectItems() , pre ); }; myUI.window.tabs.suprefix.suprefixGrp.su.sufixBtn.onClick = function(){ var su = myUI.window.tabs.suprefix.suprefixGrp.su.sufixString.text; myUI.methods.suffix( myUI.methods.getSelectedProjectItems() , su ); }; myUI.window.tabs.rename_tab.renameGrp.renameBtn.onClick = function(){ var new_name = myUI.window.tabs.rename_tab.renameGrp.renameString.text; myUI.methods.rename( myUI.methods.getSelectedProjectItems() , new_name ); }; */ //END EVENT HANDLERS return(this); } this.yMainFunction = function yMainFunction() { w = this.createUI(); } this.activate = function activate() { this.yTool.yMainFunction(); } this.init(); return this; } //CHECKS that the toolbox exists, and if it doesn´t it runs the script on its own. if (typeof(YTB)=='undefined') { gt = new GenericTool(); gt.activate(); } else { YTB.addTool(new GenericTool()); } \ No newline at end of file +#include "../yScripts/y_JSExtensions.jsx"; + +function GenericTool() +{ + this.info = + { + name : "GenericTool", + version : 0.1, + stage : "development", + description : "Generic script to use as a base for new tools.", + url : "yorchnet.com" + }; + this.appearence = + { + buttonHeight : 30, + buttonWidth : 126 + }; + this.resources = + { + icon : new File('yNet.png'), + }; + this.methods = + { + pad : function ( n , pad ) { + zeros = ""; + for ( i = 0 ; i < pad ; i ++ ) + { + zeros+="0"; + } + n = String(n); + padded = zeros.substr( 0, pad - n.length ) + String(n) ; + return padded + }, + replace: function( items , string , newString ){ + for ( i = 0 ; i < items.length ; i ++ ){ + var item = items[i]; + item.name = item.name.replace( string , newString ); + } + return true; + }, + getSelectedProjectItems: function (){ + var items = []; + var p = app.project; + for ( var i = 1 ; i <= p.numItems ; i ++ ){ + var item = p.item(i); + if ( item.selected ){ + items.push(item); + } + } + //items = items.concat( app.project.activeItem.selectedItems ); + return items; + }, + suffix: function ( items , suffix ){ + for ( i = 0 ; i < items.length ; i ++ ){ + var item = items[i]; + if ( item.name.search( suffix ) != (item.name.length - suffix.length) ){ + item.name+= "_"+suffix; + } + + } + return true; + }, + prefix : function( items , prefix ){ + for ( i = 0 ; i < items.length ; i ++ ) + { + var item = items[i]; + if ( item.name.search( prefix ) != 0 ){ + item.name = prefix + "_" + item.name; + } + } + return true; + }, + rename: function ( items , new_name ){ + for ( i = 0 ; i < items.length ; i ++ ){ + var item = items[i]; + item.name = new_name + "_" + i; + } + + } + + } + this.init = function init() + { + + this.btnLauyout = + "button\ + {\ + preferredSize: ['" + this.appearence.buttonWidth + "','" + this.appearence.buttonHeight + "'],\ + text:'" + this.info.name + "',\ + helpTip:'" + this.info.description + "'\ + }"; + + this. res = + "window\ + {\ + type:'palette',\ + text:'" + this.info.name + ' ' + this.info.ver + ' ' + this.info.stage + "',\ + info: Group \ + {\ + alignment:['center','bottom'],\ + icon: Image \ + {\ + icon:'" + this.resources.icon.path + '/' + this.resources.icon.name + "',\ + preferredSize: [15, 18]\ + },\ + website: StaticText\ + {\ + text:'" + this.info.url + "',\ + alignment:['fill','center']\ + },\ + }\ + }"; + } + this.createUI = function createUI( ) + { + var myUI = this; + var res = + " window {\ + text: 'GenericTool',\ + alignment: ['fill','fill'], \ + alignChildren: ['center','top'], \ + orientation: 'column', \ + resizeable: 'true'\ + }" + var res = + "window { \ + text: 'GenericTool',\ + alignment: ['fill','fill'], \ + alignChildren: ['center','top'], \ + orientation: 'column', \ + resizeable: 'true',\ + tabs: Panel {\ + type: 'tabbedpanel',\ + alignment: ['fill','fill'], \ + alignChildren: ['center','top'], \ + search_tab: Panel {\ + type: 'tab',\ + text: 'Search & Replace',\ + orientation: 'column', \ + alignChildren: ['center','top'], \ + searchGrp: Group {\ + alignment: ['fill','fill'], \ + alignChildren: ['center','top'], \ + orientation: 'column', \ + searchString: EditText {text:'SEARCH FOR TEXT',alignment: ['fill','center']}, \ + },\ + replaceGrp: Group {\ + alignment: ['fill','fill'], \ + alignChildren: ['center','center'], \ + orientation: 'column', \ + replaceString: EditText {text:'REPLACE WITH TEXT',alignment: ['fill','center']}, \ + }\ + doItBtn: Button {text: 'Replace in selected Comps', alignment: ['center','center']} , \ + }\ + suprefix: Panel {\ + type: 'tab',\ + text: 'Suffix / Prefix',\ + orientation: 'column', \ + suprefixGrp: Group {\ + alignment: ['fill','fill'], \ + alignChildren: ['left','center'], \ + orientation: 'column', \ + pre:Group {\ + alignment: ['fill','fill'], \ + alignChildren: ['left','center'], \ + orientation: 'row', \ + prefixString: EditText {text:'PREFIX',alignment: ['fill','center']}, \ + prefixBtn: Button {text: 'Preffix'} , \ + },\ + su:Group{\ + alignment: ['fill','fill'], \ + alignChildren: ['left','center'], \ + orientation: 'row', \ + sufixString: EditText {text:'SUFIX',alignment: ['fill','center']}, \ + sufixBtn: Button {text: 'Sufix'} , \ + }\ + },\ + },\ + rename_tab: Panel {\ + type: 'tab',\ + text: 'Rename',\ + renameGrp: Group {\ + alignment: ['fill','fill'], \ + alignChildren: ['left','center'], \ + orientation: 'row', \ + renameString: EditText {text:'NEW NAME',alignment: ['fill','center']}, \ + renameBtn: Button {text: 'Rename'} ,\ + }\ + }\ + },\ + }"; + + myUI.window = new Window( res ); + myUI.window.layout.layout(true); + + myUI.window.show(); + + myUI.window.layout.onResizing = myUI.window.layout.onResize = function () { myUI.layout.resize();} + + //EVENT HANDLERS + + /* + myUI.window.tabs.search_tab.doItBtn.onClick = function(){ + var search_str = myUI.window.tabs.search_tab.searchGrp.searchString.text; + var replace_str = myUI.window.tabs.search_tab.replaceGrp.replaceString.text; + myUI.methods.replace( myUI.methods.getSelectedProjectItems() , search_str , replace_str ); + }; + + myUI.window.tabs.suprefix.suprefixGrp.pre.prefixBtn.onClick = function(){ + var pre = myUI.window.tabs.suprefix.suprefixGrp.su.prefixString.text; + myUI.methods.prefix( myUI.methods.getSelectedProjectItems() , pre ); + }; + + myUI.window.tabs.suprefix.suprefixGrp.su.sufixBtn.onClick = function(){ + var su = myUI.window.tabs.suprefix.suprefixGrp.su.sufixString.text; + myUI.methods.suffix( myUI.methods.getSelectedProjectItems() , su ); + }; + + myUI.window.tabs.rename_tab.renameGrp.renameBtn.onClick = function(){ + var new_name = myUI.window.tabs.rename_tab.renameGrp.renameString.text; + myUI.methods.rename( myUI.methods.getSelectedProjectItems() , new_name ); + }; + */ + + //END EVENT HANDLERS + + return(this); + } + + this.yMainFunction = function yMainFunction() + { + w = this.createUI(); + } + this.activate = function activate() + { + this.yTool.yMainFunction(); + } + + this.init(); + return this; +} + +//CHECKS that the toolbox exists, and if it doesn´t it runs the script on its own. +if (typeof(YTB)=='undefined') +{ + gt = new GenericTool(); + gt.activate(); +} +else +{ + YTB.addTool(new GenericTool()); +} diff --git a/yScripts/y_setStructure.jsx b/yScripts/y_setStructure.jsx index b0526d3..e014282 100755 --- a/yScripts/y_setStructure.jsx +++ b/yScripts/y_setStructure.jsx @@ -1 +1,127 @@ -#include "../yScripts/y_JSExtensions.jsx"; function YSetProjectTool() { this.info = { name : "YSetStructure", version : 0.11, stage : "alpha", description : "Set the Folder Structure for a new Project", url : "yorchnet.com" }; this.appearence = { buttonHeight : 30, buttonWidth : 126 }; this.resources = { icon : new File('yNet.png'), }; this.init = function init() { //alert("my name is:" + this.info.name); this.btnLauyout = "button\ {\ preferredSize: ['" + this.appearence.buttonWidth + "','" + this.appearence.buttonHeight + "'],\ text:'" + this.info.name + "',\ helpTip:'" + this.info.description + "'\ }"; this. res = "window\ {\ type:'palette',\ text:'" + this.info.name + ' ' + this.info.ver + ' ' + this.info.stage + "',\ info: Group \ {\ alignment:['center','bottom'],\ icon: Image \ {\ icon:'" + this.resources.icon.path + '/' + this.resources.icon.name + "',\ preferredSize: [15, 18]\ },\ website: StaticText\ {\ text:'" + this.info.url + "',\ alignment:['fill','center']\ },\ }\ }"; } this.createUI = function createUI() { this.window = new Window ( this.res ); this.window.show() ; } this.ySetProject = function ySetProject() { //alert("is this working"); app.beginUndoGroup('ySetProject'); var preStruct = ["01 MAIN","02 PComp","03 Source Layers" ,"04 Movies","05 Other Projects","06 Audio" , "07 Reference"]; var newStruct = []; var projectItems = []; for(i=1;i<=app.project.items.length;i++) { if(app.project.items[i].parentFolder.name=='Root') { projectItems.push(app.project.items[i].name); } } //to start a new organized project since the beginning if (projectItems.length == 0) { newStruct = preStruct; } else { for(a=0;a