ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Pulling text from a .txt file

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Chris Street
Pulling text from a .txt file
on Aug 18, 2017 at 6:04:24 pm

Hi everyone

Relatively new to creating expressions After Effects expressions, but not new to After Effects.

I've coded a program that generates a .txt file. I've done this because manually typing text between " and " is fiddly and annoying in NotePad. The result is something like this (including the spaces between each batch for easier reading:


IMAGE1 = "Text here"
DESC1 = "Smaller text here"

IMAGE2 = "Text here"
DESC2 = "Smaller text here"

IMAGE3 = "Text here"
DESC3 = "Smaller text here"

and so on, up to "IMAGE20" and "DESC20".

The generated document is called "sourcetext.txt" and is saved in the same folder as the After Effects project.

Within the After Effects project there are 20 compositions containing text. Each one has an expression such as:

$.evalFile("\sourcetext.txt");
eval("IMAGE1");

which displays the text from the relevant line within the txt document.

By default, I get an error message that says "Error occurred at line 1. Comp: 'text_1', etc.

Is there anything wrong with what I'm doing? Please help! If it helps, I'm using the CS6 version of AFX.

IMAGE3 = "Text here"
DESC3 = "Smaller text here"

$.evalFile("\sourcetext.txt");
eval("IMAGE1");


Return to posts index

Dan Ebberts
Re: Pulling text from a .txt file
on Aug 18, 2017 at 11:58:03 pm

I'd be surprised if relative addressing works. I tried this with absolute addressing and it works for me:

$.evalFile("/c/test/sourcetext.txt");
IMAGE1

(You shouldn't need that eval() in the last line.)

Dan



Return to posts index

Chris Street
Re: Pulling text from a .txt file
on Aug 19, 2017 at 7:23:47 pm

Ah wonderful, so it had to be an absolute path. Many thanks, this aspect works now!

A slightly different question now (sorry)...

Within the same text file I would like to reference sizes of rooms/objects in feet and inches. How could I accommodate both single and double quotations within the file? An example would be :

IMAGE3 = "Living Room"
DESC3 = "5.93m (19'5") x 3.45m (11'4")"

I know that it's possible to include a single quotation if the text file is encapsulated with " and ", and a double quotation if the text file is encapsulated with ' and ' - but is there a way for both instances to occur?

Any help would be greatly appreciated!

IMAGE3 = "Living Room"
DESC3 = "5.93m (19'5") x 3.45m (11'4")"


Return to posts index


Chris Street
Re: Pulling text from a .txt file
on Sep 1, 2017 at 6:28:58 pm

Never mind my last post. I've now coded an app that deals with this :)


Return to posts index

Dave Morales
Re: Pulling text from a .txt file
on Aug 20, 2017 at 12:07:04 am

I an trying to do the exact same thing on AE CC 2017 Windows 10, but when I use the syntax you use for the file path with forward slashes:

/c/test/sourcetext.txt

...I get a "Syntax Error".

If I use back slashes I get "File not Found".


Return to posts index

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