Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Map text file to Marker Comments

  • Map text file to Marker Comments

    Posted by Robin Kumar on June 18, 2018 at 1:55 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!

    Robin Kumar replied 8 years, 2 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    June 18, 2018 at 9:39 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

  • Robin Kumar

    June 18, 2018 at 12:37 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

  • Dan Ebberts

    June 18, 2018 at 1:32 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

  • Robin Kumar

    June 18, 2018 at 3:56 pm

    Thank you so much Dan! You are a lifesaver! 🙂

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy