Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects animation path stroke

  • animation path stroke

    Posted by Alfred Steiner on July 6, 2015 at 12:50 pm

    Hey there,
    I ve made animated a path in the way that i set the starting anchor point in the first keyframe then i took a step forward to the next frame and added another anchor point which is then keyframed and so on.
    so the path grows from anchor point to anchor point in each keyframe.

    now because the path is very long (about 3000 anchor points in the end of the animation) i need an automation for the following :
    I want the path stroke to be only visible from most recent anchor point in the the keyframe i am in ( for example in keyframe number 10 ) 5 anchor points back. that means from anchor point 10 to 9, from 9 to 8, 8 to 7, 7 to 6 and 6 to 5.

    so just for understanding when im at the 50th keyframe where i already have 50 anchor points set, in that keyframe i only want to see the last five lines also.
    so that i get a construct of 5 lines in result.
    I hope anyone gets what i mean and can help me out.
    I cannot find anythin on google considering effects working with the anchor point numbers.

    Does anyone know if/ how it is possible do? i think it should work with a script
    but i dont know how to delete certain vertices via script

    i got it to select the path somehow and i can get the vertices array ( in the var Verts ) but i dont know how to remove specific vertices in specific keyframes …
    var theComp = app.project.activeItem;
    var theLayer = theComp.layer(1);
    //var thePath = theComp.selectedProperties[0];
    var myProperty = theLayer.content("Form 1").content("Pfad 1").property(2).value;

    var Verts = theLayer.content("Form 1").content("Pfad 1").property(2).value.vertices;

    best wishes,
    Alfred Steiner

    Michael Szalapski replied 11 years ago 2 Members · 5 Replies
  • 5 Replies
  • Alfred Steiner

    July 7, 2015 at 9:23 am

    thank you for answering.

    I just reformulate it quickly as good as I can.

    I just clicked on the pen tool then I set the first anchor point in the first frame, then i went to the next frame to set the next anchor point and so on.

    I made some screenshots to clear things up, the text in there is irrelevant now.

    ————————————————————–

    now what i meant with “path stroke” is whats seen in the right of this image here :

    now if you look at the first picture i put in here, you can see 4 anchor points in the rightmost block.
    i didnt set up a stroke for the image. but what i want is that in the

    only the last 2 (or any number) lines or path segments are visible.
    so in this rightmost block (you see in the bottom of the image that i am in the fourth frame)
    i only want to see the line from 4 to 3 and from 3 to 2.

    -this can be done either by manually deleting all points you dont want to have in every keyframe
    (that is not possible in my case)

    the second option could be drawing a path stroke not from a start in % to an end in % as usually but
    somehow from the last point to the two anchor points which where made right befor the last one.
    (as i described)

    the third thing i think is most likely the solution but I need help to realize it.
    I need a script which goes through all frames and in each frame through all path anchor points and then
    it just deletes the anchor points which i dont want to see .
    (therefore you must know that i changed an option in the general settings of after affects which is called somewhat like “keep constant anchorpoint number in mask edit” or so in english).
    this allows to change the path completely in the keyframes without changing the number of anchor points in the keyframes before if you know what i mean.

    the problem is how to do the deleting of those single points via script.

    this sounds actually much more complicated like it is.

    kind regards,
    Al Steiner

  • Alfred Steiner

    July 8, 2015 at 12:45 am

    Well i just got it finally via the following script.

    Sadly i didnt found any good reference on the net…

    I dont know how to know which properties my objects have and how to refer to them right.
    anyways i tried and errored it :

    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 theKeys = thePath.selectedKeys;

    var myProperty = 0;
    var Verts = 0;
    var myShape = 0;

    var theKeyTime = 0; // holds the time in seconds of a specific Frame later

    var Lines = parseInt(prompt("Enter Line Number:"));
    var spliceStart = Verts.length - (Lines+1); // + 1 because a line always consists of two points and the first line offers the first point for the second...

    for (var i = 1; i <= thePath.numKeys; i++) {
    theKeyTime = theLayer.content("Form 1").content("Pfad 1").property(2).keyTime(i); // the time in seconds at which the specific keyframe happens
    myProperty = theLayer.content("Form 1").content("Pfad 1").property(2).valueAtTime(theKeyTime,true);
    Verts = myProperty.vertices;
    spliceStart = Verts.length - (Lines+1);

    if (Verts.length > (Lines+1)) { // if there are already more lines then var Lines defined.
    // modify Shape
    myShape = 0;
    myShape = new Shape();
    myShape.closed = false;
    myShape.vertices = Verts.splice(spliceStart,(Lines+1));
    thePath.setValueAtKey(i,myShape);
    }
    }

    Thanks for your help.

    best wishes –
    Alf

  • Michael Szalapski

    July 8, 2015 at 5:20 pm

    Why not just draw the full path with a few clicks of the mouse and animate the stroke properties of the shape layer over time to show the parts you need?
    Or, heck, put a mask on a solid layer and use the Vegas effect?

    – The Great Szalam
    (The ‘Great’ stands for ‘Not So Great, in fact, Extremely Humble’)

    No trees were harmed in the creation of this message, but several thousand electrons were mildly inconvenienced.

  • Alfred Steiner

    July 8, 2015 at 7:00 pm

    please read what i wrote… i wrote that its about 3000 anchor points which should be exact lines.

  • Michael Szalapski

    July 8, 2015 at 7:13 pm

    Well, if your mask/shape path has to have 3,000 exact points on it, my question still remains. You can just keyframe your stroke to follow it without writing any code.

    – The Great Szalam
    (The ‘Great’ stands for ‘Not So Great, in fact, Extremely Humble’)

    No trees were harmed in the creation of this message, but several thousand electrons were mildly inconvenienced.

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