ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

How can I copy the contents inside a text file to SourceText property of a text layer by scripting?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Adirai Maji
How can I copy the contents inside a text file to SourceText property of a text layer by scripting?
on Dec 23, 2019 at 12:32:31 pm

I know the way to get the text file using evalFile. But it only read the file. What I want to achieve is to copy the file inside the text file and apply it to the SourceText property of a text layer. How can I achieve that?

==================================================================================================
Thanks in Advance...

- Adirai Maji


Return to posts index

Andrei Popa
Re: How can I copy the contents inside a text file to SourceText property of a text layer by scripting?
on Dec 26, 2019 at 2:18:20 pm

I'm not sure what your level of scripting is, but you should be able to understand this and even use the function in your own cases.


var myFile = File.openDialog("Please select a file");
var myLayer = app.project.activeItem.selectedLayers[0];
copyFileToLayer(myFile, myLayer);



function copyFileToLayer(myFile, myLayer){
if(myFile.open("r")){
var myString = myFile.read();
myLayer("ADBE Text Properties")("ADBE Text Document").setValue(myString);
myFile.close();
}else{
alert(myFile.error);
}
}



Andrei
My Envato portfolio.


Return to posts index

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