Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Setting path vertices using scripting

  • Setting path vertices using scripting

    Posted by Andrew Yardy on August 22, 2022 at 2:33 am

    I’d like to spawn shape objects with small variations in the shape vertex positions.

    I seem to be able to get a handle to a shape’s vertices but not sure how to set the values for individual vertices.

    Can anyone offer suggestions??

     

    shapeLayerContents=nodeLayer.property(2);

    shape.property(2).property(1)

    pathVerticies=shape.property(2).value.vertices

    verticiesCount=pathVerticies.length

    for(var i = 0 ; i < verticiesCount;i++){

    v=pathVerticies[I]

    pathVerticies[0]=[10,10]

    }

     

    Thanks

    Andy

    Andrew Yardy replied 4 years ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    August 22, 2022 at 2:40 pm

    This example shows how you could add [10,10] to each vertex of a shape path:

     var myComp = app.project.activeItem;
    var myLayer = myComp.layer(1);
    var myPathObject = myLayer.property("Contents").property("Shape 1").property("Contents").property("Path 1").property("Path");
    var myPath = myPathObject.value;
    var myVertices = myPath.vertices;
    var v;
    for (var i = 0; i < myVertices.length; i++){
    v = myVertices[i];
    myVertices[i] = [v[0] + 10, v[1] + 10];
    }
    myPath.vertices = myVertices;
    myPathObject.setValue(myPath);
  • Andrew Yardy

    August 22, 2022 at 11:13 pm

    Thanks, Dan so much.

    Using the property names is very helpful to see the object hierarchy.

    Cheers

    Andy

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