mirror of
https://github.com/jorgevasquezp/AE_Scripts.git
synced 2026-08-16 15:31:06 +00:00
Updated repository with latest 'live' tools.
This commit is contained in:
@@ -30,13 +30,13 @@
|
|||||||
myButtonGroup.alignChildren = "center";
|
myButtonGroup.alignChildren = "center";
|
||||||
|
|
||||||
win.button1.onClick = function(){
|
win.button1.onClick = function(){
|
||||||
button1Click();
|
win.button1Click();
|
||||||
}
|
}
|
||||||
win.button2.onClick = function(){
|
win.button2.onClick = function(){
|
||||||
button2Click();
|
win.button2Click();
|
||||||
}
|
}
|
||||||
win.button3.onClick = function(){
|
win.button3.onClick = function(){
|
||||||
button3Click();
|
win.button3Click();
|
||||||
}
|
}
|
||||||
|
|
||||||
win.layout.layout(true);
|
win.layout.layout(true);
|
||||||
@@ -57,14 +57,14 @@
|
|||||||
/* General functions */
|
/* General functions */
|
||||||
|
|
||||||
/* Project Specific functions */
|
/* Project Specific functions */
|
||||||
function button1Click(){
|
w.button1Click = function(){
|
||||||
alert("Button 1 was clicked");
|
alert( w.button1.text + "was clicked"); //reference panel stuff
|
||||||
}
|
}
|
||||||
function button2Click(){
|
w.button2Click =function(){
|
||||||
alert("Button 2 was clicked");
|
alert( w.button2.text + "was clicked");
|
||||||
}
|
}
|
||||||
function button3Click(){
|
w.button3Click = function(){
|
||||||
alert("Button 3 was clicked");
|
alert( w.button3.text + "was clicked");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,116 @@
|
|||||||
#include "y.jsx";
|
#include "y.jsx";
|
||||||
my_comps = getSelectedProjectItems();
|
|
||||||
var my_comp = getSelectedProjectItems()[0];
|
|
||||||
|
|
||||||
// new_size = [ 240,320 ];
|
function compareComps( compA, compB, precision ){
|
||||||
//new_size = [ 4096, 2048 ];
|
// 0 = basic , 1 = advanced , 2 = certain
|
||||||
|
var result = false;
|
||||||
|
if ( precision == 0){
|
||||||
|
propList = ["name","width","height","frameDuration","numLayers"];
|
||||||
|
alert(propList);
|
||||||
|
}
|
||||||
|
for ( property in compA ){
|
||||||
|
|
||||||
|
for ( var i = 0 ; i < propList.length ; i++ ){
|
||||||
|
if ( property == propList[i] ){
|
||||||
|
//alert( property + String(compA[property]) + "/" + String(compB[property]) + " : " + ( compA[property] == compB[property]) );
|
||||||
|
if ( compA[property] == compB[property] ){
|
||||||
|
result = true;
|
||||||
|
}else{
|
||||||
|
result = false;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
function isSourceOneOfThese( layer , sourcesArray){
|
||||||
|
for ( var p = 0 ; p < sourcesArray.length ; p++ ){
|
||||||
|
if ( layer.source == sourcesArray[p] ){
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
function consolidateSelectedComps(){
|
||||||
|
app.beginUndoGroup("Consolidate Selected Comps");
|
||||||
|
//DANGER Comps might not be the same, they only have to be NAMED the same.
|
||||||
|
var allCompItems = getAllProjectComps();
|
||||||
|
var myItems = getSelectedProjectComps();
|
||||||
|
// var allMyItems = []+myItems;
|
||||||
|
var newSource = myItems.pop();
|
||||||
|
|
||||||
|
for ( var i = 0 ; i < allCompItems.length ; i ++){
|
||||||
|
var curComp = allCompItems[i];
|
||||||
|
for ( var l = 1 ; l <= curComp.layers.length ; l ++){
|
||||||
|
|
||||||
|
var curLayer = curComp.layers[l];
|
||||||
|
//alert(newSource);
|
||||||
|
//alert(myItems);
|
||||||
|
|
||||||
|
if ( isSourceOneOfThese( curLayer , myItems )){
|
||||||
|
if( curLayer.source != newSource ){
|
||||||
|
curLayer.replaceSource(newSource,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ( var i = 0 ; i < myItems.length ; i ++){
|
||||||
|
var myItem = myItems[i];
|
||||||
|
myItem.remove();
|
||||||
|
}
|
||||||
|
app.endUndoGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
// var myItems = getSelectedProjectComps();
|
||||||
|
// var myLayer = app.project.activeItem.selectedLayers[0]
|
||||||
|
// alert(isSourceOneOfThese(myLayer, myItems))
|
||||||
|
//alert(compareComps( myItems[0], myItems[1], 0));
|
||||||
|
|
||||||
|
consolidateSelectedComps();
|
||||||
|
|
||||||
|
// a = app.project.items[1];
|
||||||
|
// b = app.project.items[2];
|
||||||
|
// // alert(a.frameDuration)
|
||||||
|
// // alert(b)
|
||||||
|
// var same = compareComps( a, b, 0 );
|
||||||
|
// alert(same);
|
||||||
|
|
||||||
|
// for ( property in a ){
|
||||||
|
// alert( property );
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
//my_comps = getSelectedProjectItems();
|
||||||
|
//var myLayers = app.project.activeItem.selectedLayers;
|
||||||
|
//var my_comp = getSelectedProjectItems()[0];
|
||||||
|
|
||||||
|
//zeroOutLayer(myLayers[0]);
|
||||||
|
|
||||||
|
//app.project.save();
|
||||||
|
//alert();
|
||||||
|
|
||||||
|
//resizeCompsCanvasCentered( [ 1080, 1080 ] , true ); //1x1
|
||||||
|
//resizeCompsCanvasCentered( [ 1080, 1350 ] , true ); //4x5
|
||||||
|
//resizeCompsCanvasCentered( [ 1080, 1920 ] , true );
|
||||||
|
|
||||||
|
//a="WTC2_1x1_TUNG_GLD_ROTO_Ghostface_02tl_03jvFIN"
|
||||||
|
//alert( insertAt( a, "TXT", -12 ));
|
||||||
|
|
||||||
|
//insertAtSelectedItemsNames( "TXT", -12 ); // insert "TXT" into the 12th position from the end of all selected Items' names.
|
||||||
|
//insertAtSelectedItemsNames( "ROTO", -12 );
|
||||||
|
//insertAtSelectedItemsNames( "TXTLS", -12 );
|
||||||
|
|
||||||
//setFPS( my_comp, 24 );
|
//setFPS( my_comp, 24 );
|
||||||
|
//setCompsFPS( 12 );
|
||||||
|
|
||||||
for ( var i = 0 ; i < my_comps.length ; i++ ){
|
//new_size = [ 4096, 2048 ];
|
||||||
var my_comp = my_comps[i];
|
|
||||||
setFPS( my_comp, 24 );
|
|
||||||
}
|
|
||||||
|
|
||||||
//selectLayersByParented( false );
|
//selectLayersByParented( false );
|
||||||
|
|
||||||
//resizeCompCanvasCentered( my_comp, new_size, true )
|
//resizeCompCanvasCentered( my_comp, new_size, true )
|
||||||
//alert(system.callSystem("whoami"))
|
|
||||||
|
//alert(system.callSystem("whoami"))
|
||||||
|
|
||||||
|
//app.project.save()
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
#include "y_JSExtensions.jsx";
|
||||||
|
function sortNumber(a,b){
|
||||||
|
return a - b;
|
||||||
|
}
|
||||||
|
function pad(n,i){ //pad n with ceroes up to i places.
|
||||||
|
if (String(n).length>=i){
|
||||||
|
return String(n)
|
||||||
|
}else{
|
||||||
|
dif = i- (String(n)).length;
|
||||||
|
padding = "";
|
||||||
|
for (p=0;p<dif;p++){
|
||||||
|
padding = padding+"0"
|
||||||
|
}
|
||||||
|
return padding+String(n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function yUniStr(str){
|
||||||
|
if (app.project.activeItem != null) {
|
||||||
|
myLayers = app.project.activeItem.layers;
|
||||||
|
//myLayerNames = [];
|
||||||
|
nameMatches = [];
|
||||||
|
for (i=1;i<=myLayers.length;i++){
|
||||||
|
if(getBaseName(myLayers[i].name) == getBaseName(str)){
|
||||||
|
nameMatches.push(getN(myLayers[i].name))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
newN = getFirstGap(nameMatches);
|
||||||
|
if(nameMatches.length == 0 | (newN==0)){
|
||||||
|
return str
|
||||||
|
}else{
|
||||||
|
return str+' '+newN
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
alert('E01 : No Comp is ACTIVE')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function getN(str){
|
||||||
|
lastChunk = str.substr(str.lastIndexOf(' '),str.length);
|
||||||
|
if(lastChunk == parseInt(lastChunk)){
|
||||||
|
return parseInt(lastChunk);
|
||||||
|
}else{
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function getBaseName(str){
|
||||||
|
lastChunk = str.substr(str.lastIndexOf(' '),str.length);
|
||||||
|
if(lastChunk == parseInt(lastChunk)){
|
||||||
|
return str.substr(0,str.lastIndexOf(' '));
|
||||||
|
}else{
|
||||||
|
return str;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function getFirstGap(array){
|
||||||
|
length = array.length
|
||||||
|
array.sort(function sortNumber(a,b){return a-b})
|
||||||
|
max = array[array.length-1]
|
||||||
|
for (n=0;n<=max;n++){
|
||||||
|
entry = array.getOne(n);
|
||||||
|
if (entry == -1){
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return max+1
|
||||||
|
return array[0];
|
||||||
|
}
|
||||||
|
function yReplace(inputSTR,replaceSTR,replacementSTR){
|
||||||
|
tmpArray = inputSTR.split(replaceSTR);
|
||||||
|
tmpSTR = '';
|
||||||
|
for(i=0;i<tmpArray.length;i++){
|
||||||
|
tmpSTR = tmpSTR+tmpArray[i]
|
||||||
|
if(i<tmpArray.length-1){
|
||||||
|
tmpSTR = tmpSTR+replacementSTR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tmpSTR;
|
||||||
|
}
|
||||||
|
function genStamp(args){
|
||||||
|
d = new Date();
|
||||||
|
//alert(d.getMonth());
|
||||||
|
y = String(d.getFullYear()).substring(2,4);
|
||||||
|
m = pad(d.getMonth()+1,2);
|
||||||
|
d = pad(d.getUTCDate(),2);
|
||||||
|
str = String(m)+String(d)+String(y);
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
function mergeMultiLine(_str){
|
||||||
|
var re = new RegExp('[\n\r]');
|
||||||
|
_lines = _str.split(re);
|
||||||
|
newStr = '';
|
||||||
|
|
||||||
|
if(_lines.length>1){
|
||||||
|
for(L=0;L<_lines.length;L++){
|
||||||
|
alert(_lines[L]);
|
||||||
|
if(L==_lines.length-1||_lines[L]==''){
|
||||||
|
dash = '';
|
||||||
|
}else{
|
||||||
|
dash = '.';
|
||||||
|
}
|
||||||
|
if(_lines[L]!=''){
|
||||||
|
newStr = newStr+_lines[L]+dash;
|
||||||
|
}else{
|
||||||
|
newStr = newStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
newStr = _str;
|
||||||
|
}
|
||||||
|
return newStr;
|
||||||
|
}
|
||||||
|
function yFactor(n,f){
|
||||||
|
if((typeof(n)=='number'&&typeof(f)=='number')&&(n>f)){
|
||||||
|
value = n - (n%f);
|
||||||
|
return(value);
|
||||||
|
}else{
|
||||||
|
alert('error');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,30 @@ function getSelectedProjectItems(){
|
|||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
function getSelectedProjectComps(){
|
||||||
|
var items = [];
|
||||||
|
var p = app.project;
|
||||||
|
for ( var i = 1 ; i <= p.numItems ; i ++ ){
|
||||||
|
var item = p.item(i);
|
||||||
|
if ( (item.selected) && (item.typeName == "Composition") ){
|
||||||
|
items.push(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAllProjectComps(){
|
||||||
|
var items = [];
|
||||||
|
var p = app.project;
|
||||||
|
for ( var i = 1 ; i <= p.numItems ; i ++ ){
|
||||||
|
var item = p.item(i);
|
||||||
|
if ( item.typeName == "Composition" ){
|
||||||
|
items.push(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
function selectLayersByParented( isParented ){
|
function selectLayersByParented( isParented ){
|
||||||
layersToSelect = getLayersByParented( isParented );
|
layersToSelect = getLayersByParented( isParented );
|
||||||
for ( var i = 0; i < layersToSelect.length; i ++ ){
|
for ( var i = 0; i < layersToSelect.length; i ++ ){
|
||||||
@@ -18,6 +42,10 @@ function selectLayersByParented( isParented ){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function getLayersByParented( isParented ){
|
function getLayersByParented( isParented ){
|
||||||
|
|
||||||
|
/* TODO
|
||||||
|
not use activeItem. but have the function take a comp as an argument, to avoid activItem becoming obsolete.
|
||||||
|
*/
|
||||||
var active_comp = app.project.activeItem;
|
var active_comp = app.project.activeItem;
|
||||||
var filtered_layers = [];
|
var filtered_layers = [];
|
||||||
|
|
||||||
@@ -52,7 +80,7 @@ function setDurationInFrames( myComp, newFrameDuration ){
|
|||||||
//myComp.
|
//myComp.
|
||||||
};
|
};
|
||||||
function resizeCompCanvasCentered( my_comp, new_size, keep_scaler ){
|
function resizeCompCanvasCentered( my_comp, new_size, keep_scaler ){
|
||||||
app.beginUndoGroup("Resize Comp Canvas Centered")
|
//app.beginUndoGroup("Resize Comp Canvas Centered")
|
||||||
var n = my_comp.layers.addNull();
|
var n = my_comp.layers.addNull();
|
||||||
|
|
||||||
//center null on actual comp size
|
//center null on actual comp size
|
||||||
@@ -79,5 +107,56 @@ function resizeCompCanvasCentered( my_comp, new_size, keep_scaler ){
|
|||||||
}else{
|
}else{
|
||||||
n.remove()
|
n.remove()
|
||||||
}
|
}
|
||||||
|
//app.endUndoGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
function resizeCompsCanvasCentered( new_size, keep_scaler ){
|
||||||
|
app.beginUndoGroup("Resize Comps' Canvas Centered")
|
||||||
|
var my_comps = getSelectedProjectItems();
|
||||||
|
for ( var i = 0 ; i < my_comps.length ; i ++ ){
|
||||||
|
var my_comp = my_comps[i];
|
||||||
|
//alert( my_comp.name )
|
||||||
|
resizeCompCanvasCentered( my_comp, new_size, true );
|
||||||
|
}
|
||||||
app.endUndoGroup();
|
app.endUndoGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCompsFPS( newFPS ){
|
||||||
|
app.beginUndoGroup("Change selected Comps' framerates");
|
||||||
|
var my_comps = getSelectedProjectItems();
|
||||||
|
for ( var i = 0 ; i < my_comps.length ; i++ ){
|
||||||
|
var my_comp = my_comps[i];
|
||||||
|
setFPS( my_comp, 8 );
|
||||||
|
}
|
||||||
|
app.endUndoGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
function zeroOutLayer( myLayer ){
|
||||||
|
myLayer.position.setValue([0,0]);
|
||||||
|
myLayer.rotation.setValue(0);
|
||||||
|
myLayer.anchorPoint.setValue([0,0]);
|
||||||
|
myLayer.scale.setValue([100,100]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function insertAt( text , insertText, pos ){
|
||||||
|
var myText = text;
|
||||||
|
var insertText = insertText;
|
||||||
|
var myPos = pos;
|
||||||
|
var newText;
|
||||||
|
if( myPos >= 0 ){
|
||||||
|
newText= myText.substr(0,myPos)+"_"+insertText+myText.substr(myPos);
|
||||||
|
}else{
|
||||||
|
newText= myText.substr(0,myText.length+myPos)+insertText+"_"+myText.substr(myText.length+myPos);
|
||||||
|
}
|
||||||
|
return newText
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Extra for renaming tool, insert stringA
|
||||||
|
into specified position of stringB.*/
|
||||||
|
function insertAtSelectedItemsNames( text, pos){
|
||||||
|
my_comps = getSelectedProjectItems();
|
||||||
|
for ( var i = 0; i < my_comps.length ; i ++ ){
|
||||||
|
var myComp = my_comps[i];
|
||||||
|
myComp.name = insertAt( myComp.name , text, pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
//Useful extensions to AFX Extendscript classes.
|
||||||
|
|
||||||
|
if (AVLayer.prototype. getPins==null) AVLayer.prototype. getPins=function(){ //Extends the AVLayer class with the getPinsfunctions which returns the Layer's property groups which are pins.
|
||||||
|
this.selectedPins = [];
|
||||||
|
for(prop=0;prop<this.selectedProperties.length;prop++){
|
||||||
|
p= this.selectedProperties[prop];
|
||||||
|
if(p.matchName=="ADBE FreePin3 PosPin Atom"){
|
||||||
|
this.selectedPins.push(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.selectedPins;
|
||||||
|
}
|
||||||
|
|
||||||
|
function yMkUnique(aString){
|
||||||
|
myLayers = app.project.activeItem.layers;
|
||||||
|
uniqueness = 1;
|
||||||
|
for(i=1;i<=myLayers.length;i++){
|
||||||
|
if(aString == myLayers[i].name){
|
||||||
|
uniqueness++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(aString+'_'+uniqueness);
|
||||||
|
}
|
||||||
|
s = 'asdas_1';
|
||||||
|
alert(s.length);
|
||||||
|
alert(yMkUnique('apple'))
|
||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
|
|||||||
|
//Useful extensions to the JavaScript class versions that come with the default ExtendScript version.
|
||||||
|
|
||||||
|
if (Array.prototype.getOne==null) Array.prototype.getOne=function(item){ //Extends the Array class with the getOne functions wich
|
||||||
|
var val = -1;
|
||||||
|
for(i=0;i<=this.length;i++){
|
||||||
|
if(this[i]==item){
|
||||||
|
var val = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user