Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Delete layer marker with specific comment

  • Delete layer marker with specific comment

    Posted by Kevin Snyder on October 10, 2022 at 4:07 pm

    I’ve been looking through the AE scripting guide, and I’ve been able to write a script to add a layer marker with a comment, but how can I delete the same layer marker with the comment? I can’t seem to find the answer.

    Kevin Snyder replied 2 years, 3 months ago 2 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    October 10, 2022 at 6:43 pm

    I was surprised to find that removeKey() doesn’t accept markerComment as an index, so I guess you have to do it the brute force way:

    var myProp = app.project.activeItem.layer(1).property("Marker");
    for (var i = 1; i <= myProp.numKeys; i++){
    if (myProp.keyValue(i).comment == "test"){
    myProp.removeKey(i);
    break;
    }
    }
  • Kevin Snyder

    October 10, 2022 at 7:26 pm

    Thanks, Dan. I gave it a go and it doesn’t remove the key. I’m not getting an error message either.

  • Dan Ebberts

    October 10, 2022 at 7:35 pm

    It worked for me. It wouldn’t give an error if it didn’t find a marker with your comment (you did change that from “test”, yes?)

  • Kevin Snyder

    October 10, 2022 at 7:59 pm

    Okay, it’s working. I just changed it to run on the selected layer. Thank you.

  • Dan Ebberts

    October 10, 2022 at 8:17 pm

    This is probably better:

    var myProp = app.project.activeItem.layer(1).property("Marker");
    try{
    var t = myProp.keyTime("test");
    var myKey = myProp.nearestKeyIndex(t);
    myProp.removeKey(myKey);
    }catch(e){
    }
  • Kevin Snyder

    October 11, 2022 at 6:19 pm

    Thanks, Dan. I really appreciate it.

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