-
Notifications
You must be signed in to change notification settings - Fork 0
/
SelectedLayers.jsx
46 lines (34 loc) · 1.14 KB
/
SelectedLayers.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
var docRef = app.activeDocument;
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
function newGroupFromLayers(doc) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( sTID('layerSection') );
desc.putReference( cTID('null'), ref );
var lref = new ActionReference();
lref.putEnumerated( cTID('Lyr '), cTID('Ordn'), cTID('Trgt') );
desc.putReference( cTID('From'), lref);
executeAction( cTID('Mk '), desc, DialogModes.NO );
};
function undo() {
executeAction(cTID("undo", undefined, DialogModes.NO));
};
function getSelectedLayers(doc) {
var selLayers = [];
newGroupFromLayers();
var group = doc.activeLayer;
var layers = group.layers;
for (var i = 0; i < layers.length; i++) {
selLayers.push(layers[i]);
}
undo();
return selLayers.reverse();
};
var selectedLayers = getSelectedLayers(app.activeDocument);
// alert(selectedLayers);
// for( i = 0; i < selectedLayers.length; i++) {
// selectedLayers[i].selected = true;
// docRef.activeLayer = selectedLayers[i];
// alert(docRef.activeLayer.name)
// }