Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Source Text from Text File

  • Source Text from Text File

  • Mark Walczak

    March 18, 2010 at 9:30 pm

    Hi everyone,

    So, I realize that this topic has been discusses at great length on several forums (including the Cow), but I have been searching tirelessly and without success for my own application. Here’s what I’m trying to do:

    Feed a text layer a text file and have it sample one word from the document for every frame of video.

    I realize that many types of “text file to AE” questions deal with lower thirds, and generating comps, but this isn’t quite what I’m going for. I should mention that I’m on a Mac, in case that makes any difference, and I am running AE CS4.

    Thank you in advance!

    https://vimeo.com/explosivegraffix

  • Dan Ebberts

    March 18, 2010 at 11:00 pm

    With this text file:

    txt = “one two three four five six seven eight nine ten”;

    This expression displays a different word on each frame:

    myPath = “/C/Temp/text_test.txt”;
    try{
    $.evalFile (myPath);
    mySplit = txt.split(” “);
    f = timeToFrames()
    mySplit[Math.min(f,mySplit.length-1)]
    }catch (err){
    “file not found”
    }

    Of course your file path will be different, and you may want to use something other than spaces to delimit your words. This works for CS4 — if you have CS3 you’ll have to use the #include method.

    Dan

  • Mark Walczak

    March 19, 2010 at 2:00 pm

    Dan, you are my hero!

    Thanks again for another amazing expression!

    https://vimeo.com/explosivegraffix

  • Brian Byrne

    April 18, 2010 at 11:12 pm

    I have a .txt file with almost 1800 names (first and last) separated by a line break. I’d like to split all names up into single frames of one text layer for use as a sprite in Particular 2.0. I’m able to use what you have here as a good starting point, but I’m afraid I don’t know enough about expressions. I’ll keep crunching through the expressions documentation, but if anyone can provide suggestions it would be greatly appreciated.

  • Dan Ebberts

    April 19, 2010 at 3:00 am

    In my opinion, you’d be much better off using a script for this. The script would read each line of the text file and create a new keyframed value for the source text at each frame.

    Alternatively, to get the expression to work, you’d have to alter your text file so that each line is a valid expression statement, like this:

    txt = [];
    txt[0] = “your first word”;
    txt[1] = “your second word”;

    etc.

    Then you could use a source text expression that assigns a new word at each frame. like this (not tested):

    myPath = “/C/Temp/text_test.txt”;
    $.evalFile (myPath);
    f = timeToFrames();
    txt[Math.min(f,txt.length-1)]

    At each frame, the expression has to read in the enitire 1800 line text file. If you use a script rather than the expression, you only have to read the text file once. Of course, it’s a bit of work to create such a script.

    Dan

  • Tom Granberg

    May 12, 2010 at 8:30 pm

    Hi Dan

    I am using Cs3, windows, and obviously this expression doesnt quiete work.
    What changes to the expression do I need?

    Path = "I:code01.txt";
    try{
    $.evalFile (Path);
    eval(Textflow);
    }catch (err){
    "not found"
    }

  • Dan Ebberts

    May 12, 2010 at 10:21 pm

    CS3 is going to need something like this for the first line:

    #include ‘/I/code01.txt’;

    Beyond that, it’s hard to say without knowing what’s in the text file and what you’re trying to do.

    Dan

  • Tom Granberg

    May 12, 2010 at 11:51 pm

    Just trying to get a text layer to accept a txt file.
    Do I need some formatting on the slashes?

    #include ‘//I//code01.txt’;

    I running win7

    Thank you so much.

    T

  • Dan Ebberts

    May 13, 2010 at 2:16 am

    The text layer has to contain executable javascript statements. For example if I have a text file (named “text_test.txt” on my c drive in the temp folder) containing this text:

    txt = “one two three four five six seven eight nine ten”;

    I can add this expression (CS3) to a text layer:

    #include ‘/C/temp/text_test.txt’
    txt

    and the text layer will display this:

    one two three four five six seven eight nine ten

    I hope that helps.

    Dan

  • Tom Granberg

    May 13, 2010 at 8:17 pm

    I wish it worked, I am sure it does on Mac platforms.
    I cant for the world of me get it to work, I keep getting file/folder not found errors.

    I am using win7 with CS3 if that helps.
    My path is as follows:
    C:\Users\Renderbrandt\Documents\text\doce01.txt

    Is there a special way I need to format the path?

    Thanks iun advance, I wish I wasnt shuch an pia…

    Tom aka Renderbrandt

Viewing 1 - 10 of 17 posts

Log in to reply.

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