-
Using the layer name within an expression
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.