ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Iterate expressions that reference a "starting layer"

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Paul Connors
Iterate expressions that reference a "starting layer"
on Oct 3, 2017 at 2:56:09 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


Return to posts index

Dan Ebberts
Re: Iterate expressions that reference a "starting layer"
on Oct 3, 2017 at 4:44:49 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



Return to posts index

Paul Connors
Re: Iterate expressions that reference a "starting layer"
on Oct 3, 2017 at 5:36:20 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.


Return to posts index


Dan Ebberts
Re: Iterate expressions that reference a "starting layer"
on Oct 3, 2017 at 6:20: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



Return to posts index

Paul Connors
Re: Iterate expressions that reference a "starting layer"
on Oct 5, 2017 at 4:48:38 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!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]