Skip to content

Commit 8dd4a9a

Browse files
author
Nik Ska
committed
Всяческие апдейты + exportSolidData
1 parent 1ef8f4d commit 8dd4a9a

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
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-SA, Nik Ska, 2013-2014//http://aescripts.com/authors/m-p/nik-ska/#script "Batch Timing Changer"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]; var unlock = false; //if layer is locked - unlock and lock afterwards if(layerToChange.locked === true){ layerToChange.locked = false; unlock = true; } 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; } } //lock if(unlock === true){ layerToChange.locked = true; } } 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/#script "Batch Timing Changer"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(this.text != this.text.match(preFilter)[0]){ this.text = this.text.match(preFilter)[0] } } 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]; var unlock = false; //if layer is locked - unlock and lock afterwards if(layerToChange.locked === true){ layerToChange.locked = false; unlock = true; } 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; } } //lock if(unlock === true){ layerToChange.locked = true; } } 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()

batchChangeTiming.txt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
PluginName = Batch Change Timing
2+
PluginVersion = 1.0.0
3+
TrialURL = http://aescripts.com/
4+
PrivNum = 267219
5+
SupportURL = http://aescripts.com/contact
6+
TrialDays = 5
7+
EnableOnNoSelection = 1
8+
EnableOnFolderSelection = 1
9+
EnableOnCompSelection = 1
10+
EnableOnFootageSelection = 1
11+
Menu = 6
12+
MenuPosition = 5
13+
BetaMode = 1
14+
BetaExpiration = 2016/16/09

exportSolidData.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//Скрипт-пример экспорта данных из выбранного слоя (выбранных слоёв)//во внешний текстовый документvar exportSolidData = this;exportSolidData.go = function() { if(app.project.file.path){ var activeComp = app.project.activeItem; if(activeComp && activeComp instanceof CompItem){ //Если мы в композиции var sel = activeComp.selectedLayers; if(sel.length > 0){ //Если выбрано хоть что-то for(var s = 0; s < sel.length; s++){ //Создаем файл под каждый выбранный слой //Но не проверяем, солид это или нет (лениво чот) exportSolidData.createFile(sel[s]); } } } }else{ alert("Save Project First!"); }}exportSolidData.createFile = function(_layer){ var sep = "/"; //разделитель для мак if($.os.substr(0,7).toLowerCase() == "windows"){sep = "\\"}; var projFile = new File(app.project.file.path); var newFolder = new Folder(Folder(app.project.file.path).fsName + sep + "dataExport"); newFolder.create() var f = new File(newFolder.fsName + sep + _layer.name + ".csv"); f.open("w"); //Вот эта строчка и пишет в файл //Имя, Длительность (в секундах) f.writeln(_layer.name + ", " + (_layer.outPoint - _layer.inPoint)); f.close(); }exportSolidData.go();

upscaleComp.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/*This script is used to rescale composition with all its contentspreserving keyframes etc Also preserves its scale in parent compNik 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){ /* Rescales the comp completely with all its contents Uses a temporary null object for that */ 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);
1+
/*This script is used to rescale composition with all its contentspreserving keyframes etc Also preserves its scale in parent compNik 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){ /* Rescales the comp completely with all its contents Uses a temporary null object for that */ 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) } } if(layer.source instanceof CompItem){ ddRescale.rescale(layer.source, scaleFactor) } } 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; var factor = 100; if(!isNaN(newScale)) factor = newScale/100; if(sel.length > 0){ 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); } } } else{ this.rescale(activeComp, factor) } app.endUndoGroup(); }}ddRescale.buildGUI(ddRescale);

0 commit comments

Comments
 (0)