Created
July 22, 2015 13:23
-
-
Save Hoikohroh/9341e25e0f5e0a961edf to your computer and use it in GitHub Desktop.
Adobe AfterEffects Script (JSX): Isolate selected Layers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Adobe AfterEffects Script (JSX) | |
Isolate selected Layers v20150721 | |
//1:Push "Isolate"button,shy unselected layers and isolate selected layers. | |
//2:Push "End Isolate"button, return shy. | |
//changelog | |
*/ | |
////////////////////////////////variable declaration//////////////////////////////// | |
var thisComp,selectedLays,unselectedLays,tmpLays,checkFlg; | |
var thisLayer = null; | |
var temp = null; | |
var dlg,w,btnSelShy; | |
var btnSelShyMode = 0; | |
////////////////////////////////body//////////////////////////////// | |
dlg = new showDialog; | |
////////////////////////////////functions//////////////////////////////// | |
// 01:create palette | |
function showDialog() | |
{ | |
w = new Window("palette","Isolate",undefined,{resizeable:true,orientation:"row"}); | |
w.center(); | |
btnSelShy = w.add("button",[10,70,180,106],"Isolate"); | |
btnSelShy.onClick = function (){ | |
btnSelShyMode = toggle(btnSelShyMode); | |
if (btnSelShyMode){ | |
thisComp = app.project.activeItem; | |
if(thisComp instanceof CompItem){ | |
pickSelectedLays (); | |
if(selectedLays.length > 0){ | |
pickUnselctedLays (); | |
changeShyMode(selectedLays,false); | |
changeShyMode(unselectedLays,true); | |
btnSelShy.text = "End Isolate"; | |
}; | |
}; | |
}else{ | |
changeShyMode(selectedLays,undefined); | |
changeShyMode(unselectedLays,undefined); | |
selectedLays= null; | |
unselectedLays= null; | |
btnSelShy.text = "Isolate"; | |
}; | |
}; | |
if(w.show()<2){w.show()}; | |
}; | |
// 02:toggle (true/false) | |
function toggle (value){ | |
if(value == 1){return 0}else{return 1}; | |
}; | |
//03:collect selected Layers | |
function pickSelectedLays (){ | |
tmpLays = null; | |
tmpLays = thisComp.selectedLayers; | |
selectedLays= new Array(); | |
if(tmpLays.length > 0){ | |
for (i = 0; i < tmpLays.length;i ++){ | |
selectedLays.push([tmpLays[i],tmpLays[i].shy]); | |
}; | |
}; | |
}; | |
//04:collect unselected Layers | |
function pickUnselctedLays (){ | |
tmpLays = null; | |
tmpLays = thisComp.layers; | |
unselectedLays = new Array(); | |
for (i = 1; i <= tmpLays.length; i++){ | |
checkFlg = 0; | |
for (j = 0; j < selectedLays.length;j ++){ | |
if (tmpLays[i] == selectedLays[j][0]){ | |
checkFlg = toggle (checkFlg); | |
}; | |
}; | |
if (checkFlg == 0){ | |
unselectedLays.push([tmpLays[i],tmpLays[i].shy]); | |
}; | |
}; | |
}; | |
//04:changeShyMode | |
function changeShyMode(Lays,mode){ | |
if (mode == undefined){ | |
for (i = 0; i < Lays.length; i++){ | |
Lays[i][0].shy = Lays[i][1]; | |
}; | |
}else{ | |
for (i = 0; i < Lays.length; i++){ | |
Lays[i][0].shy = mode; | |
}; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment