Deselect All Layers in a Comp

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
sundstedt
Posts: 15
Joined: November 30th, 2007, 8:46 am

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
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

Well you could loop through myComp.selectedLayers instead (where the index starts from 0, not 1). Or just press F2.
sundstedt
Posts: 15
Joined: November 30th, 2007, 8:46 am

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!
Post Reply