-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisolate.jsx
More file actions
47 lines (45 loc) · 1.04 KB
/
isolate.jsx
File metadata and controls
47 lines (45 loc) · 1.04 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
#include 'lib.jsx'
var doc = app.activeDocument;
var activeTree = [];
doc.suspendHistory('Isolate Active Layer', 'exec()');
function isActiveTree(l) {
for (var c = 0; c < activeTree.length; c++) {
if (l == activeTree[c])
return true;
}
return false;
}
function handleLayers(layers, active){
map(layers, function(l) {
if (/^#/.test(l.name))
return;
if (active || isActiveTree(l)) {
if (!l.visible)
l.visible = true;
if (l.typename == 'LayerSet')
handleLayers(l.layers, l == doc.activeLayer);
}
else if (l.visible)
l.visible = false;
});
}
function updateCompSafe(id){
try {
updateComp(id);
}
catch (e) {
addComp(id);
}
}
function exec() {
updateCompSafe('PRE_ISOLATION');
var l = doc.activeLayer;
for (var c = 0; c < 256; c++) {
activeTree.push(l);
if (l.parent == doc.activeLayer || l.parent == null)
break;
l = l.parent;
}
handleLayers(doc.layers, false);
updateCompSafe('POST_ISOLATION');
}