Copy link to clipboard
Copied
Hello, I am seeking a way to move shape points with JSFL.
I am somewhat new to JSFL and I'm confused about the different types of points. In the API documentation, I have seen these point methods: document.moveSelectedBezierPointsBy(), getCubicSegmentPoints, and vertex.setLocation(). I don't understand which I should use to move.
Here is an example of a shape I'd like to modify. It has three Bezier points.
If I use document.moveSelectedBezierPointsBy() it works as expected, however, for my script I need to be able to automate this for each layer and frame, so I would need to use JSFL to select Bezier Points, and I have not found a method in the API for doing this.
As I can select an element with element.selected, I thought I could change the shape using the vertices of the selected element. With this code, it returns an array of 12 vertices, which is different than the length of the Bezier points (3).
var verts = an.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].vertices
an.trace(verts.length); // 12
This is also the same length when getting the length of the shape's edges which is unexpected (I'd expect 2 vertices / 1 edge). If I try and move those 12 vertices, it will not move the Bezier handles of the vertices.
var shape = an.getDocumentDOM().selection[0];
shape.beginEdit();
for (i=0; i<shape.edges.length; i++)
{
var hEdge = shape.edges[i].getHalfEdge(0);
var vertex = hEdge.getVertex();
x = vertex.x-20;
y = vertex.y-20;
vertex.setLocation(x, y);
}
shape.endEdit();
Result:
My questions are:
Thank you.
Have something to add?