-
Notifications
You must be signed in to change notification settings - Fork 0
/
ab-selectAllChilds.jsx
54 lines (41 loc) · 1.51 KB
/
ab-selectAllChilds.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
/***************************************************************************
* Select all child layers of a selected parent layer **********************
* by Arne Breusing @dezignphreak ******************************************
* version: 0.2 ************************************************************
***************************************************************************/
selectAllChilds(this);
/* select all child layers of the selected parent layer in the current composition
*/
function selectAllChilds(thisObj) {
app.beginUndoGroup("Select all parents");
var myComp = app.project.activeItem;
if (myComp && myComp instanceof CompItem) {
for(var j = 1; j <= myComp.selectedLayers.length-1; j++){
myComp.selectedLayers[j].selected = false;
}
var myParent = myComp.selectedLayers[0];
if(myParent != null){
for (var i = 1; i <= myComp.layers.length; i++) {
if (myComp.layer(i).parent == myParent) {
// layer is a child = select
myComp.layer(i).selected = true;
} else {
// layer has no parent = select
myComp.layer(i).selected = false;
}
}
// execution successfull
if (myComp.selectedLayers.length > 1) {
myParent.selected = false;
} else {
myParent.selected = true;
alert(myParent.name + " had no child layers.");
}
} else {
alert("Please select a layer first.");
}
} else {
alert("Please select a composition first.");
}
app.endUndoGroup();
};