Copy link to clipboard
Copied
Hi All,
I have a bit of the problem for the past several days and it seems like I can't get my head around it...
Tried looking everywhere and simply can't find any solution. I've went through AE Scripting guide that is written by Adobe and still can't get it...
Anyway, my problem is that I simply can't get the script to delete a vertex from a mask path that already existing in my project.
Here is the code I wrote for it:
var Ver = TarLayer.mask(1).property("Mask Path").value.vertices;
delete Ver[4];
alert (Ver[4]);
Practically, this code seem to run fine, but the specified vertex still exists in my project... Like nothing happened.
I've intentionally placed 'alert' at the end to see if there is any value in the specified array that was previously deleted, and the alert returns a message that the targeted array is undefined, which is fine. But the bloody vertex still exists in my project...
I've even tried placing the "alert (Ver[4]);" method before the delete operator and then once more after just to see what it will report, and it reports correctly. First alert gives me an X,Y coordinate of the specified vertex, then the second alert, which comes after the delete operator, gives me this message: "undefined", which should be alright considering it was just deleted, but the actual mask in the project on my composition still has that bloody vertex...
I presume that there must be some sort of a deconstruct method that should be used in order to remove a specific vertex, but I cant find it...
It would be much appreciated if someone could have a look at this and suggest some viable solution...
Using delete will remove the entry of the array, but doesnt lower the array length, so it's like setting the entry to undefined. But entries of a shape.vertices should not be undefined. Additionnally you need to use setValue to actually modify the mask in after effects.
The following should work (havent tried).
...var shape = TarLayer.mask(1).property("Mask Path").value;
var myShape = new Shape();
var myVertices = shape.vertices.slice(0); myVertices.splice(4,1); myShape.vertices = myVertices;
var myInTa
Copy link to clipboard
Copied
Using delete will remove the entry of the array, but doesnt lower the array length, so it's like setting the entry to undefined. But entries of a shape.vertices should not be undefined. Additionnally you need to use setValue to actually modify the mask in after effects.
The following should work (havent tried).
var shape = TarLayer.mask(1).property("Mask Path").value;
var myShape = new Shape();
var myVertices = shape.vertices.slice(0); myVertices.splice(4,1); myShape.vertices = myVertices;
var myInTangents = shape.inTangents.slice(0); myInTangents.splice(4,1); myShape.inTangents = myIntangents;
var myOutTangents = shape.outTangents.slice(0); myOutTangents.splice(4,1); myShape.outTangents = myOutTangents;
myShape.closed = shape.closed;
TarLayer.mask(1).property("Mask Path").setValue(myShape);
Xavier
Copy link to clipboard
Copied
Works perfectly!
Thanks a lot mate!
I figured that I will need some sort of a method...
Did try splicing the array directly but the result was the same.
Now I got it with setting the value! Thanks.
PS > If there are key frames on the mask path property, setValueAtTime() or setValueAtKey() must be used. Also, I've removed the part of the code that was splicing In and Out Tangents and it still gives the right result.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now