Page 1 of 1

Deselect All Layers in a Comp

Posted: January 9th, 2008, 3:20 am
by sundstedt
I was looking for how to quickly deselect any selected layers in a Comp in AE using Script. Here is how I did it:

Code: Select all

// Define myComp as first comp in project   
var myComp = app.project.item(1);
// Define myLayers as the layers of this Comp
myLayers = myComp.layers;

// For loop that deselects all layers in that Comp
for (var i = 1; i <= myLayers.length; i++) 
{
	// Deselect this layer
	myLayers[i].selected = false;	
}
Let me know if there is a faster way :D

Posted: January 9th, 2008, 3:28 am
by Paul Tuersley
Well you could loop through myComp.selectedLayers instead (where the index starts from 0, not 1). Or just press F2.

Posted: January 9th, 2008, 3:35 am
by sundstedt
Thanks, the point here is that I needed to avoid any need of user interaction, so F2 wasn't an option. Thanks for the alternative tip on selectedLayers!