ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Map text file to Marker Comments

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Robin Kumar
Map text file to Marker Comments
on Jun 18, 2018 at 1:55:07 am
Last Edited By Robin Kumar on Jun 18, 2018 at 7:17:02 am

Hello!

I want to map (Load) text file to marker comments. My text file has numbers like 10, 20, 30 and so on...
I would like to map these numbers on subsequent markers on a layer , so first marker will have a number 10 in comment, second have 20 and so on..






Is there any way to achieve this?

Any help is appreciated ☺

Regards!


Return to posts index

Dan Ebberts
Re: Map text file to Marker Comments
on Jun 18, 2018 at 9:39:18 am

You could do it with a script. The details would depend on how you want it to work exactly. For example, do the layer and the markers exist already and will the layer be selected when you run the script? In any case, it should be fairly straightforward.


Dan



Return to posts index

Robin Kumar
Re: Map text file to Marker Comments
on Jun 18, 2018 at 12:37:03 pm

Thank you for your reply Dan!

Yes the layer and the marker exists already, and it will be selected when we run the script. The script should prompt for the text file and it will load the numbers or words to the marker comments.

Can you please help? ☺

Regards


Return to posts index


Dan Ebberts
Re: Map text file to Marker Comments
on Jun 18, 2018 at 1:32:44 pm

This should work:


function commentsFromFile(){
var myComp = app.project.activeItem;
if ((myComp == null) || ! (myComp instanceof CompItem)){
alert ("No comp selected");
return;
}
if (myComp.selectedLayers.length == 0){
alert ("No layer selected.");
return;
}
var myLayer = myComp.selectedLayers[0];
var myMarker = myLayer.property("Marker");
if (myMarker.numKeys == 0){
alert ("Selected layer has no markers.")
return;
}
var myFile = File.openDialog("Please select input text file.");
if (myFile == null) return;
var fileOK = myFile.open("r");
if (! fileOK){
alert ("File open failed.");
return;
}
app.beginUndoGroup("Comments From File");

var commentCount = 0;
var myMarkerVal = new MarkerValue("");
var comment;

while ((! myFile.eof) && (commentCount < myMarker.numKeys)){
commentCount++;
comment = myFile.readln();
myMarkerVal.comment = comment;
myMarker.setValueAtKey(commentCount,myMarkerVal);
}

myFile.close();

app.endUndoGroup();
}
commentsFromFile();



Dan



Return to posts index

Robin Kumar
Re: Map text file to Marker Comments
on Jun 18, 2018 at 3:56:58 pm

Thank you so much Dan! You are a lifesaver! :-)


Return to posts index

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