Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Scripting – Keyframes not moving properly.

  • Scripting – Keyframes not moving properly.

    Posted by Praveen Kulk on March 17, 2020 at 2:24 pm

    I am trying to move the selected keyframes of the selected properties with script, but it is moving only first selected property keyframes and not second ones.
    Here is my script –
    var mComp = app.project.activeItem;
    var selecLayers = mComp.selectedLayers;
    for (i=0;i=0; k–){
    var newKeyValue = seleProp[j].keyValue(seleKeys[k]);
    var newKeyTime = seleProp[j].keyTime(seleKeys[k]) + 0.06;
    var newKey = seleProp[j].addKey(newKeyTime);
    seleProp[j].setValueAtKey(newKey, newKeyValue);
    seleProp[j].removeKey(seleKeys[k]);
    }
    }
    }
    what Am i doing wrong here?

    pbk

    Praveen Kulk replied 6 years, 4 months ago 2 Members · 4 Replies
  • 4 Replies
  • Walter Soyka

    March 17, 2020 at 5:21 pm

    1) Is this just a fragment of your entire script? It’s not clear to me from this what the i, j and k variables are meant to store.

    2) The flow control in your for() loop is incorrect. See here for a quick overview of how the loop should work:
    https://www.w3schools.com/js/js_loop_for.asp

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Praveen Kulk

    March 17, 2020 at 6:47 pm

    example here – if i select some keys in position property and some keys in scale property and execute this script, only position keys will move, scale keys will not.
    i represents layer, j represents property and k represents key in for loops.
    Its nested for loop – ‘keyframe’ for loop is inside ‘property’ for loop which is inside ‘layer’ for loop.

    pbk

  • Praveen Kulk

    March 17, 2020 at 6:49 pm

    here is the correct script –

    var mComp = app.project.activeItem;
    var selecLayers = mComp.selectedLayers;
    for (i=0;i=0; k–){
    var newKeyValue = seleProp[j].keyValue(seleKeys[k]);
    var newKeyTime = seleProp[j].keyTime(seleKeys[k]) + 0.06;
    var newKey = seleProp[j].addKey(newKeyTime);
    seleProp[j].setValueAtKey(newKey, newKeyValue);
    seleProp[j].removeKey(seleKeys[k]);
    }
    }
    }

    pbk

  • Praveen Kulk

    March 17, 2020 at 6:57 pm

    ok, iam not getting the script to display correctly here, so here it goes –
    so here is the screenshot

    pbk

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