Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to create Text markers using script?

  • How to create Text markers using script?

    Posted by Johanna Peterson on September 19, 2012 at 5:32 pm

    Hi ! I was wondering if there’s a way using script to add Markers in the text layers? I have the time codes where I wanted the words to appear but its more efficient if I can use a script to input all the Markers in the Text layers. Thanks!

    Aleks Cicha replied 11 years, 9 months ago 4 Members · 12 Replies
  • 12 Replies
  • Dan Ebberts

    September 19, 2012 at 6:27 pm

    You can use a script to add markers to any layer, but I’m not sure how that helps you exactly. Were you going to link marker comments to the source text via an expression, or are you actually thinking of source text keyframes, or ???

    Dan

  • Johanna Peterson

    September 19, 2012 at 6:43 pm

    Hello again! Im sorry if I didn’t explain it in the beginning on how it will help me. I’m actually using the subtitle script online, that loads the subtitles from a text file and creates the Text Keyframes from the created Markers on the Text layer. I’ve added the markers manually by inputting the timecodes on the timeline. So I was wondering how to possibly create the Markers on the Text layers without doing it manually. I have the all time codes were the subtitles should appear. Thank you!

  • Dan Ebberts

    September 19, 2012 at 9:38 pm

    I’m still not completely sure what you’re trying to do, but this little script example will create a marker on the selected layer at 2 seconds with the comment “test comment”:

    {
    var myLayer = app.project.activeItem.selectedLayers[0];
    var myMarkerVal = new MarkerValue(“test comment”);
    myLayer.property(“Marker”).setValueAtTime(2, myMarkerVal);
    }

    I hope that helps.

    Dan

  • Johanna Peterson

    September 20, 2012 at 3:03 pm

    Hi Dan, thanks for this. This is helpful too, but what I really wanted to do is if say for example, I have these time codes (0;01;00;08, 0;01;03;03, 0;01;03;04, 0;01;05;09, 0;01;05;10) were I need to put the Marker on my Text Layer how do you do that in script? I really dont need the Marker Value at the moment, just placing the Markers into the Text layer.

    Like this:

    THanks Dan!

  • Dan Ebberts

    September 20, 2012 at 11:14 pm

    Maybe like this then:


    {
    var timeCodes = "0;01;00;08, 0;01;03;03, 0;01;03;04, 0;01;05;09, 0;01;05;10";
    var splitTC = timeCodes.split(",");
    var myComp = app.project.activeItem;
    var myLayer = myComp.selectedLayers[0];
    for(var i = 0; i < splitTC.length; i++){
    t = currentFormatToTime(splitTC[i],myComp.frameRate);
    myLayer.property("Marker").addKey(t)
    }
    }

    Dan

  • Johanna Peterson

    September 20, 2012 at 11:50 pm

    You are amazing Dan! Thanks a lot!

  • Federico Ponce

    September 19, 2013 at 10:53 pm

    Hi, were do you enter this script?

    {
    var timeCodes = “0;01;00;08, 0;01;03;03, 0;01;03;04, 0;01;05;09, 0;01;05;10”;
    var splitTC = timeCodes.split(“,”);
    var myComp = app.project.activeItem;
    var myLayer = myComp.selectedLayers[0];
    for(var i = 0; i < splitTC.length; i++){
    t = currentFormatToTime(splitTC[i],myComp.frameRate);
    myLayer.property(“Marker”).addKey(t)
    }
    }

  • Dan Ebberts

    September 19, 2013 at 11:02 pm

    You would first save that as a .jsx file and then run it from the File menu: File>Scripts>Run Script File…

    Dan

  • Federico Ponce

    September 19, 2013 at 11:25 pm

    unable to run script line 1. syntax error:

    var timeCodes = “0;01;00;08, 0;01;03;03, 0;01;03;04, 0;01;05;09, 0;01;05;10”;
    var splitTC = timeCodes.split(“,”);
    var myComp = app.project.activeItem;
    var myLayer = myComp.selectedLayers[0];
    for(var i = 0; i < splitTC.length; i++)
    t = currentFormatToTime(splitTC[i],myComp.frameRate);
    myLayer.property(“Marker”).addKey(t)

  • Aleks Cicha

    October 10, 2014 at 9:43 am

    Hi there, I am trying to create a number of intervals in a set time intervals, let’s say 1 marker every 10 frames…. Is there any way to include that in the script?

Page 1 of 2

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