-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeepcut.jsx
More file actions
48 lines (44 loc) · 1.22 KB
/
deepcut.jsx
File metadata and controls
48 lines (44 loc) · 1.22 KB
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
#include 'lib.jsx'
var doc = app.activeDocument;
function duplicate(l) {
var al = doc.activeLayer;
doc.activeLayer = l;
var idDplc = charIDToTypeID( "Dplc" );
var desc = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref.putEnumerated( idLyr, idOrdn, idTrgt );
desc.putReference( idnull, ref );
var idVrsn = charIDToTypeID( "Vrsn" );
desc.putInteger( idVrsn, 5 );
executeAction( idDplc, desc, DialogModes.NO );
var r = doc.activeLayer;
doc.activeLayer = al;
return r;
}
function applyToLayerSet(set) {
map(set.layers, function(l) {
doc.activeLayer = l;
if (l.typename == 'LayerSet')
applyToLayerSet(l);
if (l.typename == 'ArtLayer')
doc.selection.clear();
});
}
function exec() {
var al = doc.activeLayer;
if (doc.activeLayer.typename != 'LayerSet') {
alert('deepcut script requires layer set');
}
var dupl = duplicate(doc.activeLayer);
dupl.name = al.name + ' (deepcut)';
applyToLayerSet(al);
doc.activeLayer = al;
doc.selection.invert();
applyToLayerSet(dupl);
doc.activeLayer = al;
}
exec();