FORUMS: list search recent posts

Using the layer name within an expression

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Paul Connors
Using the layer name within an expression
on Sep 19, 2019 at 7:29:48 pm

Hello. I'm testing some data-driven expressions using a .csv file as my source. I have some expressions in my comp that reference that data, but I'm trying to incorporate the layer name into the expression as well.

Here is an expression on the source text of a layer named "Lower Third" that correctly outputs the correlated data from the .csv file:


thisComp.layer("csv test - Sheet1.csv")("Data")("Outline")("Lower Third")("Lower Third 0")


What I'm trying to do is replace the "Lower Third" and "Lower Third 0" in the above expression by referencing the layer name. (which is "Lower Third").

On a separate text layer named "Lower Third 2" I'm using as a test I put this expression on the source text:


"\"" + thisLayer.name + "\""


and the output is exactly what I want: "Lower Third 2".

However, when I apply that same strategy to the expression on the data-driven text layer it doesn't work. Here is the expression I have on that layer.


txt1 = "\"" + thisLayer.name + “\””;
txt2 = "\"" + thisLayer.name + " 0" + “\””;
thisComp.layer("csv test - Sheet1.csv")("Data")("Outline")(txt1)(txt2)


I feel like that should be working but I'm getting an error. I'm not really sure what the problem is. Any help would be greatly appreciated.


Return to posts index

Dan Ebberts
Re: Using the layer name within an expression
on Sep 19, 2019 at 10:14:53 pm

For one thing, you let some curly quotes sneak into the end of the first and second lines...

Dan



Return to posts index

Paul Connors
Re: Using the layer name within an expression
on Sep 20, 2019 at 12:58:20 pm

Oops! You're absolutely right! I've just updated that but am getting the same error:


txt1 = "\"" + thisLayer.name + "\"";
txt2 = "\"" + thisLayer.name + " 0" + "\"";
thisComp.layer("csv test - Sheet1.csv")("Data")("Outline")(txt1)(txt2)


Return to posts index


Walter Soyka
Re: Using the layer name within an expression
on Sep 20, 2019 at 6:19:16 pm

You don't need the quotes at all. They just tell JavaScript that you're passing a string literal. When you create your txt1 and txt2 variables, they're already strings as far as the expression engine is concerned.

txt1 = thisLayer.name;
txt2 = thisLayer.name + " 0";
thisComp.layer("csv test - Sheet1.csv")("Data")("Outline")(txt1)(txt2)


Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Paul Connors
Re: Using the layer name within an expression
on Sep 23, 2019 at 4:12:07 pm

Huzzah! That worked like a charm. Thank you!


Return to posts index

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