FORUMS: list search recent posts

How to determine the number of lights in a comp

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Rob Womack
How to determine the number of lights in a comp
on Sep 20, 2011 at 6:09:41 pm

I am writing a script that wil generate a light if the selected layer is not a light. I'm using addLight, but you can't generate a light without the two arguments, name and point of interest.

AE generates a new light name based on the number of lights in the comp, and I'd like to do that as well, but as far as I can tell there's not an easy way to do this. The Brute Force approach would be to iterate through the layers and test for the castShadows attribute, but is there an easier way?

Robert Womack
Creative Bridgekeep
http://www.CurrentMarketing.com
"Louisville's Leading Interactive Marketing Agency"


Return to posts index

Dan Ebberts
Re: How to determine the number of lights in a comp
on Sep 20, 2011 at 11:03:19 pm

I can't think of a better way than this:


var myComp = app.project.activeItem;
var numLights = 0;
for (var i = 1; i <= myComp.numLayers; i++){
if (myComp.layer(i) instanceof LightLayer) numLights++;
}



Dan



Return to posts index

Rob Womack
Re: How to determine the number of lights in a comp
on Sep 21, 2011 at 1:11:38 pm

Thank you sir. I was unaware you could use the instanceof operator to identify a Light.

Robert Womack
Creative Bridgekeep
http://www.CurrentMarketing.com
"Louisville's Leading Interactive Marketing Agency"


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]