Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to determine the number of lights in a comp

  • How to determine the number of lights in a comp

    Posted by Rob Womack on September 20, 2011 at 6:09 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”

    Rob Womack replied 14 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    September 20, 2011 at 11:03 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

  • Rob Womack

    September 21, 2011 at 1:11 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”

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy