Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Using the layer name within an expression

  • Using the layer name within an expression

    Posted by Paul Connors on September 19, 2019 at 7:29 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.

    Paul Connors replied 6 years, 7 months ago 3 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    September 19, 2019 at 10:14 pm

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

    Dan

  • Paul Connors

    September 20, 2019 at 12:58 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)

  • Walter Soyka

    September 20, 2019 at 6:19 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   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Paul Connors

    September 23, 2019 at 4:12 pm

    Huzzah! That worked like a charm. Thank you!

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