-
On the mystic faculty of reading an external plain text file.
Hello everybody.
I browsed, I read, I executed… but I still can’t successfully get AE reading an external file. I’m aware it’s just about my ignorance, and yet I need help in some extent.
Attempts has been done both on a Mac and on a Windows, to no avail.
I always targeted only plain .txt files, also because that’s exactly what the contingency is all about. Let’s explain.I’m working on a project that’s being carried out both on Nuke and After Effects. Ok, that’s simply nuts, but no more than life as a whole.
It takes to transfer tracking data from Nuke to After, and it turns out that the only way Nuke can dump tracking data but through fbx or some other evolute way, is by baking a plain ASCII file, formatted as such: two or three numbers per line, separated by spaces and returns only (no commas, no semicolons, no anything).
I managed to get the job done by copying the whole text and pasting into a text layer, for I can deal with data, once they are into AE. But I couldn’t possibly get AE to read the file, straightaway.I saw several tutorials and threads that demands a specific formatting of the text. I followed them. Nonetheless, I couldn’t get the code working. All in all, I’m not gonna get any special formatting, nor I need it: as I told, spaces seem enough to get the work done through RegEx.
What I need, it is just a way to make AE read a .txt and feed everything into a variable (or the sourceText property of a text layer).
The code I write below (and associated to the sourceText parameter of a text layer), is the only one AE haven’t scolded me for. It returned the caught error: “Reference Error: function $.eval is undefined”. (And this is when I freak both hell and heaven out…)
I hope you can light my way. Thanks.
try {
myFile = "<i>absolute path to the file</i>";
$.eval(myFile);
eval(thisComp.layer("<i>the name I gave to the layer</i>").text.sourceText.value);
} catch(err) {
err;
}
