Skip to content

Commit f157b3c

Browse files
author
Nik Ska
committed
Добавлен keyReverse, найден planeResolve, поправлены какие-то ошибки и косяки
1 parent 04183c6 commit f157b3c

File tree

5 files changed

+121
-1
lines changed

5 files changed

+121
-1
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/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()
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 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()

changeAllNames.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/**Snippet to change target name project-wise.*Comp names and layer names are going to be affected.*I believe there are going to be problems with expressions.*Though I'm not sure**CC-BY, Nik Ska, 2015*/var wrongName = "??";var targetName = "WATWAT";var howMuch = 0;var changeNames = this;changeNames.go = function(wrongName, targetName) { app.beginUndoGroup("Changeallnames"); //1. Disable all expressions changeNames.switchAllExpressions(false, wrongName, targetName); //2. Now change names for(var i = app.project.numItems; i > 0; i--){ var thisItem = app.project.item(i); if(thisItem.name == wrongName){ thisItem.name = targetName; howMuch++; } if(thisItem instanceof CompItem){ for(var c = thisItem.layers.length; c > 0; c--){ var thisLayer = thisItem.layers[c]; if(thisLayer.name == wrongName){ thisLayer.name = targetName; thisLayer.selected = true; thisItem.openInViewer(); howMuch++ } } } } //3. Enable all expressions changeNames.switchAllExpressions(true, '', ''); app.endUndoGroup(); alert("Changed " + String(howMuch) + " names");}changeNames.switchAllExpressions = function(enable, find, replace){ //if enabled == true, enables all expressions. disables otherwise for(var i = app.project.numItems; i > 0; i--){ var thisItem = app.project.item(i); if(thisItem instanceof CompItem){ for(var l = thisItem.layers.length; l > 0; l--){ var thisLayer = thisItem.layers[l]; changeNames.switchExpressions(thisLayer, enable, find, replace); } } }}changeNames.switchExpressions = function(layer, activate, find, replace){ function replaceAll(string, find, replace) { return string.replace(new RegExp(escapeRegExp(find), 'g'), replace); } var enableDisableExpressions = function(_prop, activate, find, replace){ for(var i=1; i<=_prop.numProperties; i++){ var curProp=_prop.property(i); if(curProp instanceof PropertyGroup || curProp instanceof MaskPropertyGroup){ enableDisableExpressions(curProp, activate, find, replace); } else if (curProp.canSetExpression == true){ try{ if(curProp.expressionEnabled == true && activate == false){ curProp.expressionEnabled = false;//выкл } if(curProp.expressionEnabled == false && activate == true){ curProp.expressionEnabled = true;//вкл } if(activate == false){ //replacing target text in expression //when we disable expression curProp.expression = replaceAll(curProp.expression, find, replace); } } catch(err){ null } } } } enableDisableExpressions(layer, activate, find, replace);}changeNames.go(wrongName, targetName);

keyReverse.jsx

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//ReverseKeys just does what it says is does - reverses keyframes
2+
//Just select a bunch of keyframes and the script will reverse them at the playhead
3+
4+
//CC-BY, Nik Ska, 2015
5+
6+
var reverseKeys = this;
7+
8+
reverseKeys.go = function() {
9+
var activeComp = app.project.activeItem;
10+
if(activeComp && activeComp instanceof CompItem){
11+
var sel = activeComp.selectedLayers;
12+
if(sel.length > 0){
13+
app.beginUndoGroup("reversing keys");
14+
15+
16+
for(var l = 0; l < sel.length; l++){
17+
thisLayer = sel[l];
18+
19+
if(thisLayer.selectedProperties.length > 0){
20+
for(var p = 0; p < thisLayer.selectedProperties.length; p++){
21+
thisProperty = thisLayer.selectedProperties[p];
22+
23+
//if there are more than 1 keyframes selected
24+
if(thisProperty.selectedKeys.length > 1){
25+
var keys = thisProperty.selectedKeys;
26+
27+
28+
var newKeyTime = activeComp.time;
29+
for (var k = 0; k < keys.length; k++) {
30+
31+
//creating a new key
32+
var newKeyIndex = thisProperty.addKey(newKeyTime);
33+
34+
//getting spatial and temporal ease values
35+
var newKeyInSpatialTangent = thisProperty.keyInSpatialTangent(keys[keys.length - k - 1]);
36+
var newKeyOutSpatialTangent = thisProperty.keyOutSpatialTangent(keys[keys.length - k - 1]);
37+
38+
var newKeyInTemporalEase = thisProperty.keyInTemporalEase(keys[keys.length - k - 1]);
39+
var newKeyOutTemporalEase = thisProperty.keyOutTemporalEase(keys[keys.length - k - 1]);
40+
41+
//setting both value and tangents / easing
42+
thisProperty.setValueAtKey(newKeyIndex, thisProperty.keyValue(keys[keys.length - k - 1]));
43+
thisProperty.setSpatialTangentsAtKey(newKeyIndex, newKeyOutSpatialTangent, newKeyInSpatialTangent)
44+
thisProperty.setTemporalEaseAtKey(newKeyIndex, newKeyOutTemporalEase, newKeyInTemporalEase)
45+
46+
//updating time
47+
if(k < keys.length - 1){
48+
newKeyTime += thisProperty.keyTime(keys[keys.length - k - 1]) - thisProperty.keyTime(keys[keys.length - k - 2]);
49+
}
50+
}
51+
}
52+
}
53+
54+
}
55+
}
56+
57+
app.endUndoGroup();
58+
59+
}
60+
}
61+
}
62+
63+
reverseKeys.go();
64+

mixIt.jsx

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//MixIt! Remixes layers based on thier position
2+
//CC-BY, Nik Ska, 2015
3+
4+
5+
var activeComp = app.project.activeItem;
6+
if(activeComp && activeComp instanceof CompItem){
7+
var sel = activeComp.selectedLayers;
8+
if(sel.length > 0){
9+
10+
app.beginUndoGroup("Remix");
11+
var posArray = [];
12+
13+
//creating anchor point - pos array
14+
for(var s = 0; s < sel.length; s++){
15+
posArray.push([sel[s].property("ADBE Transform Group").property("ADBE Anchor Point").value, sel[s].property("ADBE Transform Group").property("ADBE Position").value]);
16+
}
17+
18+
var i = posArray.length;
19+
20+
while(i > 0){
21+
var rand = parseInt(Math.random()*i); //getting random index
22+
23+
//setting its pos and ap
24+
sel[i-1].property("ADBE Transform Group").property("ADBE Anchor Point").setValue(posArray[rand][0]);
25+
sel[i-1].property("ADBE Transform Group").property("ADBE Position").setValue(posArray[rand][1]);
26+
27+
posArray.splice(rand, 1);
28+
29+
i--;
30+
}
31+
32+
app.endUndoGroup();
33+
}
34+
}

planeResolve.jsx

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Plane Resolve is a script to find a fourth point based on position of three points
3+
4+
Assumption:
5+
6+
*/
7+
8+
var alpha, beta, gamma, delta;
9+
var A_0, B_0, C_0, D_0, M_0; //initial states
10+
var A, B, C, D, M; //current states
11+
var refFrame = 0;
12+
13+
A =
14+
B =
15+
C =
16+
D =
17+
18+
//Добавить везде _0
19+
var M = [0,0];
20+
M[1] = ((A[1]*(C[0] - A[0])/(C[1] - A[1])) - (B[1]*((D[0] - B[0])/(D[1] - B[1]))) - (A[0] - B[0]))/(((C[0] - A[0])/(C[1] - A[1])) - ((D[0] - B[0])/(D[1] - B[1])));
21+
M[0] = ((M[1] - A[1])/(C[1] - A[1]))*(C[0] - A[0]) + A[0];

0 commit comments

Comments
 (0)