Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Collecting layers from a comp to an array only returns 20 elements Extendscript

  • Collecting layers from a comp to an array only returns 20 elements Extendscript

    Posted by Miguel De mendoza on July 10, 2016 at 4:48 pm

    I have this script:
    var comp = app.project.activeItem;
    var layers = [];
    for (var i = 1; i < comp.numLayers; i++){
    layers.push(comp.layer(i));
    }

    I have about 30 layers on the comp, but when the loop arrives to 20, the loop continues but stops pushing the layers in the array. No matter what kind of layers are inside of the comp or if all the layers are the same layer duplicated, it stops at 20. Somenone can figure out why is this happening?

    Miguel De mendoza replied 9 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    July 10, 2016 at 5:12 pm

    I just tried your code, and it works for me, but it doesn’t get the last layer unless you change this:

    for (var i = 1; i < comp.numLayers; i++){

    to this:

    for (var i = 1; i <= comp.numLayers; i++){

    I’m not sure why it stops at 20 for you.

    Dan

  • Miguel De mendoza

    July 10, 2016 at 7:33 pm

    Thanks Dan, I forgot to write the equals sign on the snipped.
    Well, it looks that I only can see 20 items in the data browser, but the array is filled by all elements. I was working on a bigger script and th problema was on other loop.

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