Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Iterate expressions that reference a “starting layer”

  • Iterate expressions that reference a “starting layer”

    Posted by Paul Connors on October 3, 2017 at 2:56 pm

    Hi Guys. I’m wondering if there is a way to iterate expressions that reference a “starting layer”. Here is the example I’m working on.

    I’m making a line chart with 10 data points. Those points are spread across an XY chart. To “connect” layer Point 1 and layer Point 2 I use a solid layer named “Point_1-2” which has a Beam Effect with the following expressions:

    ON STARTING POINT PARAMETER:
    thisComp.layer(“Point 1”).transform.position

    ON ENDING POINT PARAMETER:
    thisComp.layer(“Point 2”).transform.position

    That all is working fine. Here’s my question: What’s the best way to iterate those expressions for the next “connector layer”? Up next I’ll want to connect layer “Point 2” and layer “Point 3” with a solid layer named: “Point_2-3”. The expression on the beam effect would look like this if manually entered:

    ON STARTING POINT PARAMETER:
    thisComp.layer(“Point 2”).transform.position

    ON ENDING POINT PARAMETER:
    thisComp.layer(“Point 3”).transform.position

    That would work fine, but I’m hoping there is some cool “index” usage I can apply so everytime I duplicate the “connector layer” the expression will update and the beam/connecting line will work automatically as opposed to having to go in and update manually.

    Hopefully that makes sense. Haha. Thanks in advance for any help!

    ON STARTING POINT PARAMETER:
    thisComp.layer("Point 1").transform.position

    ON ENDING POINT PARAMETER:
    thisComp.layer("Point 2").transform.position

    Paul Connors replied 8 years, 7 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    October 3, 2017 at 4:44 pm

    I think this works:

    // Starting Point

    s = name.split(“_”);
    s = s[s.length-1].split(“-“);
    thisComp.layer(“Point ” + s[0]).transform.position

    // Ending Point

    s = name.split(“_”);
    s = s[s.length-1].split(“-“);
    thisComp.layer(“Point ” + s[1]).transform.position

    Dan

  • Paul Connors

    October 3, 2017 at 5:36 pm

    Hi Dan. That absolutely works! Thank you very much.

    For learning purposes, would you be able to explain what exactly is going on in that expression you wrote? I’m looking at it trying to figure out what it is and how it works, but I’m just scratching my head really.

    Thank you.

  • Dan Ebberts

    October 3, 2017 at 6:20 pm

    It’s all string operations based on the layer’s name. If you have access to a good JavaScript reference, look up the String split() method, length attribute, and concatenation (+) operator.

    Dan

  • Paul Connors

    October 5, 2017 at 4:48 pm

    Hi Dan. As always, thanks very much for your feedback and for your time! I’m excited to look into those things and hopefully add a new tool to my collection. Cheers!

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