Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Accessing comment number or index?

  • Accessing comment number or index?

    Posted by Corby Logue on February 1, 2013 at 7:22 pm

    Is there such a thing?

    If I have a script with the following:


    var myComp = app.project.activeItem
    var numMarkers = myComp.layer("audio.aif").marker.numKeys
    alert(numMarkers);

    It will give me the total number of markers. But how do I get a specific marker by it’s number (say, the 10th marker or the 37th marker)?

    I’ve got a loop that works using keyValue, but once the loop is done, I’m trying to hold that marker number because the next time I loop through, I want to start at that number (instead of starting over at the beginning of the layer).

    I keep trying various alert statements to see if there is any kind of index or number associated with the maker. I either get an error or “undefined”. Thanks.

    Eblu Beta replied 11 years, 12 months ago 4 Members · 8 Replies
  • 8 Replies
  • Kevin Camp

    February 1, 2013 at 7:32 pm

    the index is specified with marker.key(index)…

    so myComp.layer(“audio.aif”).marker.key(10).comment would return the comment of the 10th marker.

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Corby Logue

    February 1, 2013 at 7:51 pm

    Thanks Kevin:

    I’m getting an error when I use that (from the script toolkit from inside AE).

    Also, while ultimately I do need to get the comment from the marker, still wondering if there is just a way to access the 10-ness (for lack of a better term) from the 10th maker. I’ve got a couple of nested loops going and I’m trying to make sure that I’m starting from the proper marker when I loop back through a second time. So I’m trying to use an alert statement to tell me what number marker the script has reached at that point.

    The comment associated with the marker won’t really work, because it’s an audio file with a comment for every marker/word (done through Adobe Media Encoder). Anyway, there are around 400 markers/words, so there are too many duplicates to check the word itself. Getting the number of the marker would be way more helpful.

    Thanks

  • Kevin Camp

    February 1, 2013 at 8:54 pm

    what if you tried this in your script:
    var myComp = app.project.activeItem
    var numMarkers = myComp.layer("audio.aif").marker.key(10)
    alert(numMarkers);

    does it return ’10’?

    i will confess that i do not write java script, but i do use expressions a lot, and marker.key(integer) would be how you would specify a specific key by index number.

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Corby Logue

    February 1, 2013 at 9:22 pm

    Nope… still getting an error.

    And I tried the same thing. I just turned “myComp.layer(“audio.aif”).marker.key(10)” into a var. Then tried a trace/alert statement.

    Thanks though.

  • Dan Ebberts

    February 1, 2013 at 11:28 pm

    I think this will work:

    var myComp = app.project.activeItem;
    var numMarkers = myComp.layer(“audio.aif”).property(“Marker”).numKeys;
    alert(numMarkers);

    Dan

  • Corby Logue

    February 9, 2013 at 1:27 am

    Thanks Dan (albeit belated). I got it figured out.

    That script will just give the total number of markers, correct?

    Just wanted to clean this up for someone looking in the future. Again, I was trying to see if I could access the number of a Marker at a certain point while the script was running its routine. As for why I needed that… I have little idea what I’m doing (or I’m figuring it out as I go), so alert statements have been immense in helping me figure out where things are going wrong. I was never able to get this solved specifically, but by setting up some dummy variables that were counting, I worked around it. Pretty happy that I got everything written and it works. For now. Still one more problem to solve.

    Thanks again.

  • Eblu Beta

    May 20, 2014 at 3:32 am

    Corby,
    I was fishing on the internet for something very similar to what you were trying to do, got to the end of your thread, and was disappointed. about 5 minutes later I figured it out, after stumbling upon the valueAtKey function.

    thought I’d post it for future scripters

    here is the magic code:

    layerRef.marker.keyValue(IndexVariable).comment

    layerRef is a reference to a specific layer
    marker is the property
    keyValue is the function you need to be able to do this.
    indexVariable can be your loop variable in a for loop
    comment is how you get the value of the comment of the marker (you could use another value there like: chapter, or url.

    layerRef.marker.keyValue(IndexVariable).comment

  • Eblu Beta

    May 20, 2014 at 8:20 pm

    no it doesn’t.
    you have to use KeyValue()

    keyValue is not interchangeable with key();

    theLayer.marker.keyValue(e);

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