Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Attach marker to source Text keyframe

  • Attach marker to source Text keyframe

    Posted by Mansouri Walid on July 6, 2018 at 1:45 pm

    Hello guys, i’m new here it’s my first post
    please i have a question, is there any way to attach marker key to source text keyframes ? , i want when i move the marker the source text keyframe move too attached to each other.

    best regards

    Dan Ebberts replied 8 years ago 3 Members · 7 Replies
  • 7 Replies
  • Jacob Roth

    July 6, 2018 at 3:12 pm

    Are you trying to get the source text to reflect marker comments? If so, here’s your code.

    m = thisComp.layer("Your Layer"); // source text layer name inside parens and quotes
    n=0;
    if (m.marker.numKeys > 0){
    n = m.marker.nearestKey(time).index;
    if (m.marker.key(n).time > time) n--;
    }
    if (n > 0) m.marker.key(n).comment else ""

  • Mansouri Walid

    July 6, 2018 at 3:59 pm

    No, what i’m trying to do is, i want to to attach markers to source text, so when i move the marker the text keyframe move too.

  • Dan Ebberts

    July 6, 2018 at 4:31 pm

    Probably like this:


    m = marker;
    n=0;
    if (m.numKeys > 0){
    n = m.nearestKey(time).index;
    if (m.key(n).time > time) n--;
    n = Math.min(n,numKeys);
    }
    if (n > 0)
    key(n).value
    else
    ""

    Dan

  • Mansouri Walid

    July 6, 2018 at 5:04 pm

    Hi Dan Ebberts thank for your help, the code is working but i don’t know why when i move the marker, the source Text stay in the same position, sorry i’m not good enough in english i hope you undrestand what i’m talking about.

    i want them to move together.

    best regards
    Walid

  • Dan Ebberts

    July 6, 2018 at 5:43 pm

    An expression can’t actually move a keyframe. It should give the same result though.

    Dan

  • Mansouri Walid

    July 6, 2018 at 6:08 pm

    is it possible to do it via scripts, if yes can you help me please.

  • Dan Ebberts

    July 6, 2018 at 9:36 pm

    This is pretty rough, but it should give you the idea:


    var myComp = app.project.activeItem;
    var myLayer = myComp.layer(1);
    var myMarker = myLayer.property("Marker");
    var times = [];
    for (var i = 1; i <= myMarker.numKeys; i++){
    times.push(myMarker.keyTime(i));
    }
    var myProp = myLayer.property("ADBE Text Properties").property("ADBE Text Document");
    var values = [];
    for (var i = 1; i <= myProp.numKeys; i++){
    values.push(myProp.keyValue(i));
    }
    for (var i = myProp.numKeys; i > 0; i--){
    myProp.removeKey(i);
    }
    for (var i = 0; i < Math.min(values.length,times.length); i++){
    myProp.setValueAtTime(times[i],values[i]);
    }

    Dan

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