Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects add vertex point in future keyframes

  • Alfred Steiner

    July 18, 2015 at 3:18 pm

    thanks for your answer but as i wrote in all my topics i am working with too many keyframes and vertices so it is impossible to do it manually.

    i wrote a script which works but is very slow
    if anyone knows how to improve Script performance let me know
    // G L O B A L S
    var theComp = app.project.activeItem;
    var theLayer = theComp.layer(1);
    var thePath = theLayer.property("ADBE Root Vectors Group").property("ADBE Vector Group").property("ADBE Vectors Group").property("ADBE Vector Shape - Group").property("ADBE Vector Shape");
    var currentTime = theComp.time; // Current Time in seconds
    var activeKeyFrame = thePath.nearestKeyIndex(currentTime); // Number of the active Keyframe starting at 1 ----- > should be the nearest in the past
    if (thePath.keyTime(activeKeyFrame) > currentTime) { activeKeyFrame--; }
    var currentPath = thePath.keyValue(activeKeyFrame).vertices;
    var prevPath = thePath.keyValue(activeKeyFrame-1).vertices;
    var nextPath = thePath.keyValue(activeKeyFrame+1).vertices;

    if (theLayer.marker.numKeys == 0) { // save the last vertex index
    if ( Math.abs(currentTime - thePath.keyTime(activeKeyFrame)) > (app.project.activeItem.frameDuration*0.7) ) {
    var mv = new MarkerValue((currentPath.length-1)+"-1"); // Array index of last Vertex
    } else {
    var mv = new MarkerValue((currentPath.length-1)+"-0"); // Array index of last Vertex
    }
    theLayer.property("Marker").setValueAtTime(currentTime, mv);

    } else {
    var marker = theLayer.marker.keyValue(1).comment.split("-");
    //var marker_value = parseInt(theLayer.marker.keyValue(1).comment); // stores last Vertex array index of Current Path before editing
    var marker_value = parseInt(marker[0]); // stores last Vertex array index of Current Path before editing
    theLayer.marker.removeKey(1); // delete Marker

    if (marker[1] == "1") { // if new keyframe has been added
    alert("new");
    var insertPath = currentPath.slice((prevPath.length+1), currentPath.length);
    var insert_start = prevPath.length;
    var insert_length = 0;
    var getVerts;

    for (var i = (activeKeyFrame+1); i <= thePath.numKeys; i++) { // process all following Keyframes var myShape = new Shape(); // create new Shape to overwrite the original with myShape which is modified by the splice function myShape.closed = false; getVerts =thePath.keyValue(i).vertices; // get vertices Array of the Keyframe with the index i getVerts.splice.apply(getVerts, [insert_start,insert_length].concat(insertPath)); myShape.vertices = getVerts; thePath.setValueAtKey(i,myShape); // setValueAtKey(x, myShape); frame 0 => x = 1 --> es geht bei 1 los
    alert(insertPath);
    }
    } else { // if keyframe existed
    var insertPath = currentPath.slice(prevPath.length, currentPath.length);
    var insert_start = prevPath.length; // index before first new vertex in currentFrame
    var insert_length = (marker_value+1)-insert_start;
    var getVerts;

    for (var i = (activeKeyFrame+1); i <= thePath.numKeys; i++) { // process all following Keyframes // alert("path:"+insertPath+",start:"+insert_start+",length:"+insert_length); var myShape = new Shape(); // create new Shape to overwrite the original with myShape which is modified by the splice function myShape.closed = false; getVerts =thePath.keyValue(i).vertices; // get vertices Array of the Keyframe with the index i getVerts.splice.apply(getVerts, [insert_start,insert_length].concat(insertPath)); myShape.vertices = getVerts; thePath.setValueAtKey(i,myShape); // setValueAtKey(x, myShape); frame 0 => x = 1 --> es geht bei 1 los
    alert(insertPath);
    }

    }
    }

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