Is there a way to createPath() from script
I love the new createPath() method in CC 2018. However, I'm not seeing a mechanism to modify or create paths from a script. Am I missing it?
thanks,
Clay
I love the new createPath() method in CC 2018. However, I'm not seeing a mechanism to modify or create paths from a script. Am I missing it?
thanks,
Clay
Yes, I'm pretty well traveled on using createPath() in expressions since it came out in October, but createPath() doesn't exist in scripting (extendScript). The original question was to utilize the same behavior in a script, which I've figured out since, using the shape object. For example, here's one I use to flip a path horizontally (while keeping the vertices in the same relative position so the shape doesn't flip when animated but instead morphs into the reversed shape, if that makes sense). There may be more direct ways to code it but it works.
function flipPath() {
if (activeItem != null && activeItem instanceof CompItem) {
var selectedProps = activeItem.selectedProperties;
for (i = 0; i < selectedProps.length; i++) {
if (selectedProps.name == "Path") {
var prop = selectedProps;
var p = prop.value;
var myShape = new Shape();
sVerts = p.vertices;
sIns = p.inTangents;
sOuts = p.outTangents;
numVerts = myVerts.length;
lastVert = numVerts - 1;
for (i = 0; i <= lastVert; i++) {
r = lastVert + 1 - i;
if (i == 0) r = 0;
myVerts = [-sVerts
myIns = [-sOuts
myOuts = [-sIns
}
myShape.vertices = myVerts;
myShape.inTangents = myIns;
myShape.outTangents = myOuts;
myShape.closed = true;
prop.setValue(myShape);
}
}
}
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.