ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Get an expression to reference layer index (poss thisLayer.name.split question)

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Adam Bennett
Get an expression to reference layer index (poss thisLayer.name.split question)
on Jul 15, 2020 at 3:06:13 pm
Last Edited By Adam Bennett on Jul 15, 2020 at 3:07:33 pm

Hi folks,

I've got an expression below:

thisComp.layer("dot, 01").toComp([0,0,0])

on a layer I've called beam, 01. So, two different layers.

As I want to duplicate both layers multiple times, how do I change the above expression so on every beam layer the expression references dot, 02, 03 etc without having to retype the expression each time? I know the answer lies somewhere with the thisLayer.name.split expression, hence the naming convention, but I can't figure it out.

Thanks in advance!

Adam


Return to posts index

Filip Vandueren
Re: Get an expression to reference layer index (poss thisLayer.name.split question)
on Jul 15, 2020 at 3:11:32 pm

split() changes the String (layername) into an array of textfragments delmitied by ", ".
You would want the 2nd item of that array (at index 1) which would be a string "01" or "02"…


myNamedIndex = thisLayer.name.split(", ")[1];
myTarget = "dot, "+myNamedIndex;

thisComp.layer(myTarget).toComp([0,0,0]);




Return to posts index

Adam Bennett
Re: Get an expression to reference layer index (poss thisLayer.name.split question)
on Jul 15, 2020 at 3:15:01 pm

Filip, thank you. That's exactly what I was after. Cheers mate


Return to posts index

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