Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression to pull name of group of layers?

  • Expression to pull name of group of layers?

    Posted by Ben Cone on July 31, 2015 at 4:21 pm

    Hey guys, so I have a set of layers that moves x amount based on how many layers there are involved.

    Is there any way to pull the amount of layers there are in a comp with a name starting with some string? I basically want to be able to add as many layers with some modifier so that the expression works regardless.

    For example, all the layers might start with “01_” or something and then any time the expression sees that it could add that to the sum of layers.

    Thanks in advance

    Xavier Gomez replied 11 years, 1 month ago 2 Members · 1 Reply
  • 1 Reply
  • Xavier Gomez

    July 31, 2015 at 4:46 pm

    To retrieve that number, you can use

    num = 0;
    str = “01_”;

    N=thisComp.numlayers;
    for (n=1; n<=N; n++){if (thisComp.layer(n).name.indexOf(str)===0) ++num;}; // at this stage, num is the number of layers in the comp whose name starts with "01_". // then you use it to calculate your position offset. Xavier

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