Liam Collins
Liam Collins

Reputation: 19

Change text content from .txt file

I would like to get a text file from 10.51.1.101:8080/Home_Score.txt and get the content in a text layer in After Effects 2019 to change to that number. We have a piece of software on one computer controlling a scoreboard essentailly, and it outputs .txt files. It doesn't need to be every 100ms or anything like that, it just needs to read it every few seconds or so.

Currently I have to change the text manually when a point is added to After Effects which is annoying for the way we've set up graphics. What's the best way to start this? I have no idea how to script Source Text in AE.

Thanks!

Upvotes: 0

Views: 2010

Answers (1)

Alex Munteanu
Alex Munteanu

Reputation: 106

You have several options (add the expressions below to the Source Text property of your text layer):

A. Read from an external file (will not work with the Javascript expressions engine):

var filePath = "/DRIVE_LETTER/path/to/file.txt";
$.evalFile(filePath);

B. Use the new features implemented in AE CC 2019 and import your file as footage.

In your case .jsx, .csv or a .txt file formatted as a .csv will work.

.jsx files:

footage("filename.jsx").sourceData;

.csv files:

footage("filename.csv").dataValue([0,0]);

Where [0,0] is the [column_index, row_index] you want to read.

Here's a sample .aep file showing all the above solutions: https://url.io/ae_read_text_from_file

For option A, if you don't see the Text Layer being updated in real-time, just purge the memory (CTRL/CMD + ALT + Numpad /).

Upvotes: 1

Related Questions