Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Referencing Layer Name based on integer

  • Referencing Layer Name based on integer

    Posted by Marcus Round on August 8, 2014 at 2:38 pm

    I had trouble coming up with a descriptive title for this post, but here’s my problem:

    Let’s say I have a bunch of layers named like so:

    Penguin 1
    Penguin 2
    […]
    Penguin 49
    Penguin 50

    etc.

    Now let’s say I have a variable that could return anything from 1 to 50. Call it “myVar”.

    I would like to reference a particular Penguin layer based on the result of myVar. If myVar is 30, I want the expression to be linked to Penguin 30; if myVar is 17, I want to link to Penguin 17.

    so for example,

    myPos = thisComp.layer(“Penguin ###”).transform.position;

    where ### is replaced by the integer value of myVar.

    Is this possible?
    Thanks

    Marcus Round replied 11 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    August 8, 2014 at 3:16 pm

    Something like this:

    thisComp.layer(“Penguin ” + Math.round(myVar)).transfrom.position;

    Dan

  • Marcus Round

    August 8, 2014 at 3:26 pm

    Thanks Dan, you’re the man.

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