Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Linking source text to separate lines.

  • Linking source text to separate lines.

    Posted by Riccardo Sinti on September 1, 2011 at 8:54 pm

    I have about 40 comps each with it’s own title as a text layer.
    I want to simplify changing the titles by making it unnecessary to open each comp and manually changing the text layer for each title.
    So far i have created a “Titles” comp with 40 text layers and I pick-whiped the source text of each of the 40 comps title text layers to it’s corresponding source text in the “Titles” comp. This way if I need to change titles I can just open the “Titles” comp and then manually change each of the 40 text layers and then the tiles will change for the 40 comps. Great.
    But it just occurred to me that maybe I could have just one layer in the “titles” where I could just type all at once or copy and paste all the titles in 40 lines and have the source text expression extract the titles from it’s corresponding line.

    All that to ask- can a source text expression get info out of specific line of a single text layer?

    Matthew Ingram replied 3 months, 2 weeks ago 3 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    September 1, 2011 at 9:05 pm

    This should give you the third line of text layer “text” in comp “other comp”:

    txt = comp(“other comp”).layer(“text”).text.sourceText;
    txt.split(“r”)[2]

    Note: there should be a backslash character before the r in the second line, but I can’t get those to show up reliably, so you may have to add it yourself.

    Dan

  • Riccardo Sinti

    September 1, 2011 at 9:17 pm

    I am amazed at the speed in which I get responses at on The Cow!
    Unfortunately I get the warning that ” Class ‘Array’ has no property or method named ‘2’ ”
    Can you elucidate as to what split, “r” and [2] means in this expression?
    you wrote that this would return the third line of text. i gather that means that the first line would be [0] as in an array?
    Thanks!

    Thank You

  • Dan Ebberts

    September 1, 2011 at 9:24 pm

    split(_backslash_r) splits your text at carriage returns into an array. So if this is your text:

    line 1
    line 2
    line 3
    line 4

    The expression should return “line 3”. You did put the backslash in, right?

    Dan

  • Riccardo Sinti

    September 1, 2011 at 9:31 pm

    I didn’t see any backslash is your original reply: txt.split(“r”)[2]
    not sure where to put in the backslash

    Thank You

  • Riccardo Sinti

    September 1, 2011 at 9:34 pm

    Got it thanks!

    Thank You

  • Matthew Ingram

    November 2, 2024 at 9:58 am

    Hi Dan,

    I was wondering if this will still work in 2024? Trying and failing right now 🙁

  • Matthew Ingram

    November 2, 2024 at 10:47 am

    I imported a CSV file into the comp with the text stacked in multiple rows in one column. Then created a bunch of text layers pointing each source text to the top layer – it returned a value like this footage(“text.csv”).dataValue([0,0]). That looks like it will work fine for me. Then I can swap out the text layer.

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