Skip to content

Commit 00d99e1

Browse files
author
Nik Ska
committed
mass update
1 parent 0727a8d commit 00d99e1

7 files changed

+193
-13
lines changed

batchChangeTiming.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
//Script used for batch change timing of selected compositions//or actve comp with all layers//It basically adjusts outPoints of all layers and precomps//0.1 - initial release//0.2 - code cleanup, true recursive function//0.3 - minor update//0.31 - fixed improper behavior with shorter than comp layers//0.4 - now you can increase (+) or decrease (-) comp duration//CC-BY, Nik Ska, 2013var chTiming = this;chTiming.version = 0.4;chTiming.scriptTitle = "Batch Timing Changer";chTiming.run = function(){ this.buildGUI(this);}chTiming.buildGUI = function(thisObj){ thisObj.w = (thisObj instanceof Panel) ? thisObj : new Window("palette", thisObj.scriptTitle, undefined, {resizeable:true}); thisObj.w.alignChildren = ['left', 'top'] var g = thisObj.w.add("group{orientation:'row', alignChildren: ['left', 'top']}"); var timeText = g.add("editText", undefined, "0"); timeText.size = [50, 25]; var modeselect = g.add("dropdownlist", undefined, ["s", "fr"]); modeselect.selection = 0; modeselect.size = [42, 25]; thisObj.newTime = 0; thisObj.sign = 0; timeText.update = function(){ if(this.text[0]=="-"){ thisObj.sign = -1; } else if(this.text[0]=='+'){ thisObj.sign = 1; } else thisObj.sign = 0; thisObj.newTime = Number(this.text.substr(Math.abs(thisObj.sign),this.text.length)); } timeText.onEnterKey = function(){ timeText.update(); thisObj.changeTiming(thisObj, thisObj.newTime, thisObj.sign, modeselect.selection.index); } if (thisObj.w instanceof Window){ thisObj.w.center(); thisObj.w.show(); } else thisObj.w.layout.layout(true);}chTiming.changeTiming = function(thisObj, _time, sign, _sel){ //_time is a new time for a comp //sign is a sign for additional time. -1 for decrease, 0 for change, 1 for increase //_sel is selection type, 0 for frames, 1 for seconds function loopthrough(compToChange, _newDuration){ //first - loop through compositions for(var i = 0; i<compToChange.length; i++){ //now loop through comp's layers for(var k = 1; k<=compToChange[i].layers.length; k++){ var layerToChange = compToChange[i].layers[k]; if(_newDuration>layerToChange.inPoint && layerToChange.outPoint>=compToChange[i].duration){ layerToChange.outPoint = _newDuration; if(layerToChange.source instanceof CompItem){ //if the layer we stumble upon is a comp - go deeper loopthrough([layerToChange.source], _newDuration-layerToChange.inPoint); layerToChange.outPoint = _newDuration; } } } compToChange[i].duration = _newDuration; } } var selComps = app.project.selection; var activeComp = app.project.activeItem; if(activeComp && activeComp instanceof CompItem){ //if we are in a comp var comps = [app.project.activeItem]; } else if(selComps.length>0){ var comps = selComps; } if(_sel == 1) _time*=selComps[0].frameDuration //frames if(sign){ //if there is some time involved if(activeComp.duration+_time*thisObj.sign <= 0){ alert("Composition can't be shorter than 0") } else{ _time = activeComp.duration+_time*thisObj.sign; } } app.beginUndoGroup("Change timing"); loopthrough(comps, _time); app.endUndoGroup();}chTiming.run()
1+
//Script used for batch change timing of selected compositions//or actve comp with all layers//It basically adjusts outPoints of all layers and precomps//0.1 - initial release//0.2 - code cleanup, true recursive function//0.3 - minor update//0.31 - fixed improper behavior with shorter than comp layers//0.4 - now you can increase (+) or decrease (-) comp duration//CC-BY-SA, Nik Ska, 2013-2014//http://aescripts.com/authors/m-p/nik-ska/var chTiming = this;chTiming.version = 0.4;chTiming.scriptTitle = "Batch Timing Changer";chTiming.run = function(){ this.buildGUI(this);}chTiming.buildGUI = function(thisObj){ thisObj.w = (thisObj instanceof Panel) ? thisObj : new Window("palette", thisObj.scriptTitle, undefined, {resizeable:true}); thisObj.w.alignChildren = ['left', 'top'] var g = thisObj.w.add("group{orientation:'row', alignChildren: ['left', 'top']}"); var timeText = g.add("editText", undefined, "0"); timeText.size = [80, 25]; var modeselect = g.add("dropdownlist", undefined, ["s", "fr"]); modeselect.selection = 0; modeselect.size = [42, 25]; var recursiveMode = thisObj.w.add("checkbox", undefined, "Recursive"); recursiveMode.value = true; thisObj.newTime = 0; thisObj.sign = 0; timeText.update = function(){ if(this.text[0]=="-"){ thisObj.sign = -1; } else if(this.text[0]=='+'){ thisObj.sign = 1; } else thisObj.sign = 0; thisObj.newTime = Number(this.text.substr(Math.abs(thisObj.sign),this.text.length)); } timeText.onChanging = function(){ preFilter = /[+-]?([0-9\:]*)/; //this one does not allow to input anything but numbers and some symbols; this.text = this.text.match(preFilter)[0]; /* if(modeselect.selection.index == 0){ var newtxt = this.text.replace(/\:/g, ''); this.text = newtxt.replace(/(\d)(?=(\d\d)+$)/g, '$1:'); //separate with : // str.replace(/(?=(\d\d)+($))/g, '$1:'); } */ } timeText.onEnterKey = function(){ timeText.update(); thisObj.changeTiming(thisObj, thisObj.newTime, thisObj.sign, modeselect.selection.index, recursiveMode.value); } if (thisObj.w instanceof Window){ thisObj.w.center(); thisObj.w.show(); } else thisObj.w.layout.layout(true);}chTiming.changeTiming = function(thisObj, _time, sign, _sel, recursive){ //_time is a new time for a comp //sign is a sign for additional time. -1 for decrease, 0 for change, 1 for increase //_sel is selection type, 0 for frames, 1 for seconds function loopthrough(compToChange, _newDuration){ //first - loop through compositions for(var i = 0; i<compToChange.length; i++){ //now loop through comp's layers for(var k = 1; k<=compToChange[i].layers.length; k++){ var layerToChange = compToChange[i].layers[k]; if(_newDuration>layerToChange.inPoint && layerToChange.outPoint>=compToChange[i].duration){ layerToChange.outPoint = _newDuration; if((layerToChange.source instanceof CompItem) && recursive){ //if the layer we stumble upon is a comp - go deeper loopthrough([layerToChange.source], _newDuration-layerToChange.inPoint); layerToChange.outPoint = _newDuration; } } } compToChange[i].duration = _newDuration; } } var selComps = app.project.selection; var activeComp = app.project.activeItem; if(activeComp && activeComp instanceof CompItem){ //if we are in a comp var comps = [app.project.activeItem]; } else if(selComps.length>0){ var comps = selComps; } if(_sel == 1) _time*=selComps[0].frameDuration //frames if(sign){ //if there is some time involved if(activeComp.duration+_time*thisObj.sign <= 0){ alert("Composition can't be shorter than 0") } else{ _time = activeComp.duration+_time*thisObj.sign; } } app.beginUndoGroup("Change timing"); loopthrough(comps, _time); app.endUndoGroup();}chTiming.run()

changeAllFonts.jsx

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
var changeAllFontsScript={
2+
fontName:"Kankin"
3+
};
4+
changeAllFontsScript.go = function(){
5+
6+
FolderItem.prototype.getSelected = function(allItems)//boolean
7+
{
8+
var arr=[];
9+
if (this.selected)
10+
allItems=true;
11+
for (var i=1;i<=this.numItems;i++)
12+
{
13+
var curItem=this.item(i);
14+
if (curItem instanceof FolderItem)
15+
{
16+
var inner=curItem.getSelected(allItems);
17+
arr=arr.concat(inner);
18+
}
19+
if ((allItems === true || curItem.selected) && curItem instanceof CompItem)
20+
{
21+
arr.push(curItem);
22+
}
23+
}
24+
return arr;
25+
}
26+
27+
Project.prototype.getSelectedItems = function()
28+
{
29+
return this.rootFolder.getSelected(false);
30+
}
31+
32+
TextLayer.prototype.changeFont=function(fontName)
33+
{
34+
var prop=this.property("Source Text");
35+
if (prop.numKeys>0)
36+
for (var i=1;i<=prop.numKeys;i++)
37+
{
38+
var curTime=prop.keyTime(i);
39+
var textDocument=prop.valueAtTime(curTime,false);
40+
textDocument.font=fontName;
41+
prop.setValueAtTime(curTime,textDocument)
42+
}
43+
else
44+
{
45+
var textDocument=prop.value;
46+
textDocument.font=fontName;
47+
prop.setValue(textDocument);
48+
}
49+
}
50+
51+
CompItem.prototype.changeFonts=function()
52+
{
53+
for (var i=1;i<=this.numLayers;i++)
54+
{
55+
var curLayer=this.layer(i);
56+
if (curLayer instanceof TextLayer)
57+
try
58+
{
59+
//alert("trying to change font of layer: "+curLayer.name);
60+
curLayer.changeFont(changeAllFontsScript.fontName);
61+
}
62+
catch(e)
63+
{
64+
return null;
65+
}
66+
}
67+
return 0;
68+
}
69+
70+
app.beginUndoGroup("Change All Fonts");
71+
72+
var selItems=app.project.getSelectedItems();
73+
//alert("number of selected comps:"+selItems.length);
74+
75+
for (var i=0;i<selItems.length;i++)
76+
{
77+
var func=selItems[i].changeFonts();//function returns null if caugth exeption
78+
if (func === null)
79+
{
80+
alert("Unknown font name");
81+
return 0;//end script
82+
}
83+
}
84+
85+
alert("Done!");
86+
app.endUndoGroup();
87+
88+
89+
}
90+
91+
changeAllFontsScript.go();

csvreader.jsx

+3-11
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
return null;
88
}
99

10-
function findLayerByName(_name, _comp){
11-
for(var l = 1; l <= _comp.layers.length; l++){
12-
if(_comp.layers[l].name == _name) return _comp.layers[l];
13-
}
14-
return null;
15-
}
16-
1710
function findEffectByName(_name, _layer){
1811
//looks for an effect with given name inside given layer
1912
var eff = _layer.property("ADBE Effect Parade");
@@ -23,7 +16,6 @@ function findEffectByName(_name, _layer){
2316
return null;
2417
}
2518

26-
2719
function getFolder(_name){
2820
//function for gettin a specific folder
2921
var bFolder;
@@ -67,9 +59,9 @@ if (textFile != null) {
6759
newComp.parentFolder = targetFolder;
6860

6961
//accessing variables
70-
var nameText = findLayerByName("name", newComp).property("ADBE Text Properties").property("ADBE Text Document");
71-
var regionText = findLayerByName("region", newComp).property("ADBE Text Properties").property("ADBE Text Document");
72-
var numberValue = findEffectByName("amount", findLayerByName("number", newComp)).property("ADBE Slider Control-0001");
62+
var nameText = newComp.layer("name").property("ADBE Text Properties").property("ADBE Text Document");
63+
var regionText = newComp.layer("region").property("ADBE Text Properties").property("ADBE Text Document");
64+
var numberValue = findEffectByName("amount", newComp.layer("number")).property("ADBE Slider Control-0001");
7365

7466
//setting variables
7567
nameText.setValue(line[0]);

csvreader_final.jsx

+61-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,61 @@
1-
//This script is an example of parsing csv file into AE compsfunction findCompByName(_name){ for(var i=1;i<=app.project.numItems;i++){ if(app.project.item(i).name==_name && app.project.item(i) instanceof CompItem) return app.project.item(i); } return null}function findLayerByName(_name, _comp){ for(var l = 1; l <= _comp.layers.length; l++){ if(_comp.layers[l].name == _name) return _comp.layers[l]; } return null;}function findEffectByName(_name, _layer){ //looks for an effect with given name inside given layer var eff = _layer.property("ADBE Effect Parade"); for(var e = 1; e<= eff.numProperties; e++){ if(eff.property(e).name == _name) return eff.property(e); } return null;}function getFolder(_name){ //function for gettin a specific folder var bFolder; for(var i=1;i<=app.project.numItems;i++){ if(app.project.item(i).name==_name && app.project.item(i) instanceof FolderItem) bFolder = app.project.item(i); } //if ther is no such folder, add it if(!bFolder) bFolder = app.project.items.addFolder(_name); return bFolder}var textFile = File.openDialog ("Choose a csv file","*.csv");if (textFile != null) { var textLines = []; textFile.open("r"); }while (!textFile.eof){ //reading file into lines textLines.push(textFile.readln()); }var template = findCompByName("info_template"); //reference compvar bFolder = getFolder("broadcast");app.beginUndoGroup("tst");for(var t = 1; t<textLines.length; t++){ var newComp = template.duplicate(); newComp.name = "info_"+String(t); newComp.parentFolder = bFolder; var infoName = findLayerByName("name", newComp).property("ADBE Text Properties").property("ADBE Text Document"); var infoRegion = findLayerByName("region", newComp).property("ADBE Text Properties").property("ADBE Text Document"); var infoNumber = findEffectByName("amount", findLayerByName("number", newComp)).property("ADBE Slider Control-0001"); var infoLine = textLines[t].split(','); infoName.setValue(infoLine[0]); infoRegion.setValue(infoLine[1]); infoNumber.setValueAtTime(infoNumber.keyTime(2), Number(infoLine[2])/100000);}app.endUndoGroup();
1+
//This script is an example of parsing csv file into AE comps
2+
3+
function findCompByName(_name){
4+
for(var i=1;i<=app.project.numItems;i++){
5+
if(app.project.item(i).name==_name && app.project.item(i) instanceof CompItem) return app.project.item(i);
6+
}
7+
return null
8+
}
9+
10+
function findEffectByName(_name, _layer){
11+
//looks for an effect with given name inside given layer
12+
var eff = _layer.property("ADBE Effect Parade");
13+
for(var e = 1; e<= eff.numProperties; e++){
14+
if(eff.property(e).name == _name) return eff.property(e);
15+
}
16+
return null;
17+
}
18+
19+
function getFolder(_name){
20+
//function for gettin a specific folder
21+
var bFolder;
22+
for(var i=1;i<=app.project.numItems;i++){
23+
if(app.project.item(i).name==_name && app.project.item(i) instanceof FolderItem) bFolder = app.project.item(i);
24+
}
25+
26+
//if ther is no such folder, add it
27+
if(!bFolder) bFolder = app.project.items.addFolder(_name);
28+
return bFolder
29+
}
30+
31+
var textFile = File.openDialog ("Choose a csv file","*.csv");
32+
33+
if (textFile != null) {
34+
var textLines = [];
35+
textFile.open("r");
36+
}
37+
38+
while (!textFile.eof){
39+
//reading file into lines
40+
textLines.push(textFile.readln());
41+
}
42+
43+
var template = findCompByName("info_template"); //reference comp
44+
var bFolder = getFolder("broadcast");
45+
app.beginUndoGroup("tst");
46+
for(var t = 1; t<textLines.length; t++){
47+
var newComp = template.duplicate();
48+
newComp.name = "info_"+String(t);
49+
newComp.parentFolder = bFolder;
50+
51+
var infoName = newComp.layer("name").property("ADBE Text Properties").property("ADBE Text Document");
52+
var infoRegion = newComp.layer("region").property("ADBE Text Properties").property("ADBE Text Document");
53+
var infoNumber = findEffectByName("amount", newComp.layer("number").property("ADBE Slider Control-0001");
54+
55+
var infoLine = textLines[t].split(',');
56+
infoName.setValue(infoLine[0]);
57+
infoRegion.setValue(infoLine[1]);
58+
infoNumber.setValueAtTime(infoNumber.keyTime(2), Number(infoLine[2])/100000);
59+
}
60+
61+
app.endUndoGroup();

filterInput.jsx

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//snippet to filter edittext input for only numbers for example
2+
3+
edittext.onChanging = function(){
4+
preFilter = /[+-]?([0-9\:\.]*)/; //this one does not allow to input anything but numbers and some symbols;
5+
this.text = this.text.match(preFilter)[0];
6+
}

removeStrokes.jsx

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
PropertyGroup.prototype.removeStrokes=function(){
2+
var strokeName="ADBE Vector Graphic - Stroke";
3+
4+
if (this.property(strokeName)!=null)//если есть Stroke
5+
this.property(strokeName).remove();
6+
7+
for(var i=1;i<=this.numProperties;i++)
8+
if(this.property(i) instanceof PropertyGroup)
9+
this.property(i).removeStrokes();
10+
}
11+
12+
13+
function removeStrokes(){
14+
15+
var myComp=app.project.activeItem;
16+
if (!(myComp!== null && myComp instanceof CompItem))
17+
return 0;
18+
var selLayers=myComp.selectedLayers;
19+
for(var i=0;i<selLayers.length;i++)
20+
{
21+
var curLayer=selLayers[i];
22+
if (curLayer instanceof ShapeLayer)
23+
curLayer.property("ADBE Root Vectors Group").removeStrokes();
24+
}
25+
26+
}
27+
28+
app.beginUndoGroup("Remove Strokes");
29+
removeStrokes();
30+
app.endUndoGroup();

upscaleComp.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*This script is used to rescale composition with all its contentspreserving keyframes etc Nik Ska, 2014CC-BY-SA */#script "Rescale precomp";var ddRescale = this;ddRescale.buildGUI = function(thisObj){ thisObj.w = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Rescale precomp", undefined, {resizeable:true}); thisObj.w.alignChildren = ['left', 'top'] var g = thisObj.w.add("group{orientation:'column', alignChildren: ['left', 'top']}"); g.add("staticText", undefined, "New scale"); var scaleLine = g.add("group{orientation:'row', alignChildren: ['left', 'top']}"); var scaleText = scaleLine.add("editText", undefined, "0"); scaleText.size = [60, 30]; var goBttn = scaleLine.add("button", undefined, "Go!"); goBttn.size = [30,30]; scaleText.text = 100; scaleText.onChanging = function(){ preFilter = /[+-]?([0-9\:]*)/; //this one does not allow to input anything but numbers and some symbols; this.text = this.text.match(preFilter)[0]; } scaleText.onEnterKey = function(){ thisObj.run(Number(scaleText.text)); } goBttn.onClick = function(){ thisObj.run(Number(scaleText.text)); } if (thisObj.w instanceof Window){ thisObj.w.center(); thisObj.w.show(); } else thisObj.w.layout.layout(true);}ddRescale.rescale = function(comp, scaleFactor){ var moveVector = [comp.width, comp.height]*(scaleFactor-1)/2; comp.width *= scaleFactor; comp.height *= scaleFactor; //adding null for auto-rescale var cNull = comp.layers.addNull(); cNull.moveToBeginning(); //moving it to comp center cNull.transform.position.setValue([comp.width/2, comp.height/2]); for(var l = 2; l <= comp.layers.length; l++){ //now parent each parentless layer to it var layer = comp.layers[l]; if(!layer.hasParent) layer.parent = cNull; if(layer.canSetCollapseTransformation) layer.collapseTransformation = true; //now move if(layer.transform.position.isTimeVarying == false) layer.transform.position.setValue(layer.transform.position.value + moveVector); else{ //if we have keyframes var pos = layer.transform.position; for(var k = 1; k <= pos.numKeys; k++){ pos.setValueAtKey(k, pos.keyValue(k) + moveVector) } } } cNull.transform.scale.setValue([100,100,100]*scaleFactor); cNull.remove(); }ddRescale.run = function(newScale){ var activeComp = app.project.activeItem; if(activeComp && activeComp instanceof CompItem){ app.beginUndoGroup("Upscaling comp"); var sel = activeComp.selectedLayers; if(sel.length > 0){ var factor = 100; if(!isNaN(newScale)) factor = newScale/100; for(var s = 0; s < sel.length; s++){ if(sel[s].source instanceof CompItem){ //scale precomp contents up this.rescale(sel[s].source, factor); //and precomp itself down sel[s].transform.scale.setValue((1/factor)*sel[s].transform.scale.value); } } } app.endUndoGroup(); }}ddRescale.buildGUI(ddRescale);

0 commit comments

Comments
 (0)