forked from zlovatt/zl_Scriptlets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Reverse Shape Group Order.jsx
47 lines (35 loc) · 987 Bytes
/
Reverse Shape Group Order.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
/**
* Reverses the selected shape group order in a shape layer
*
* @author Zack Lovatt <zack@lova.tt>
* @version 0.2.4
*/
(function reverseShapeGroupOrder() {
var comp = app.project.activeItem;
if (!(comp && comp instanceof CompItem)) {
return;
}
var layers = comp.selectedLayers;
if (layers.length === 0) {
alert("Select shape layer(s)!");
return;
}
var jj;
app.beginUndoGroup("Reverse Shape Group Order");
for (var ii = 0, il = layers.length; ii < il; ii++) {
var layer = layers[ii];
if (!(layer instanceof ShapeLayer)) {
continue;
}
var vecGroup = layer.property("ADBE Root Vectors Group");
var numGroups = vecGroup.numProperties;
var shapeArrayByName = [];
for (jj = 1; jj <= numGroups; jj++) {
shapeArrayByName.push(vecGroup(jj).name);
}
for (jj = numGroups - 1; jj > 0; jj--) {
vecGroup.property(shapeArrayByName[jj]).moveTo(numGroups - ii);
}
}
app.endUndoGroup();
})();