-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathSeparate_Size_Dimensions.jsx
59 lines (53 loc) · 1.89 KB
/
Separate_Size_Dimensions.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* @name Separate Size Dimensions
* @version 1.2
* @author Kyle Martinez <www.kyle-martinez.com>
*
* @description Separate the size dimensions for a parametric rectangle or ellipse by adding a
* slider for both "X Size" and "Y Size" to the layer.
*
* @license This script is provided "as is," without warranty of any kind, expressed or implied. In
* no event shall the author be held liable for any damages arising in any way from the use of this
* script.
*
* I'm just trying to help make life as an After Effects animator a little easier.
*/
(function separateSizeDimensions() {
var matchnames = {
"ADBE Vector Rect Size": true,
"ADBE Vector Ellipse Size": true
};
function getLayer(property) {
while (property.parentProperty !== null) {
property = property.parentProperty;
}
return property;
}
function addSlider(layer, name, value) {
var slider = layer.property("ADBE Effect Parade").addProperty("ADBE Slider Control");
slider.name = name;
slider.property(1).setValue(value);
}
function separateSize(property) {
var currentSize = property.value;
var layer = getLayer(property);
addSlider(layer, "X Size", currentSize[0]);
addSlider(layer, "Y Size", currentSize[1]);
property.expression = [
"var x = effect(\"X Size\")(\"Slider\").value;",
"var y = effect(\"Y Size\")(\"Slider\").value;",
"[x, y];"
].join("\n");
}
app.beginUndoGroup("Separate Size");
var comp = app.project.activeItem;
var properties = comp.selectedProperties;
var numProperties = properties.length;
for (var p = 0; p < numProperties; p++) {
var property = properties[p];
if (matchnames.hasOwnProperty(property.matchName) === true) {
separateSize(property);
}
}
app.endUndoGroup();
})();