June 17th 2016 08:00:31am
Welcome to Free Function Friday episode setMaskPaths. In this episode we will be creating the companion function for the getMaskPaths function. Please make sure you have watched the getMaskPaths episode before continuing here.
I will be referring to that code in this episode and it is required knowledge to make setMaskPaths work properly. We will be going over the shape path attributes again as well since we will now need to assign each of them. The attributes are listed below as reference.
Follow along with the Adobe After Effects Scripting Guide as I go through the Shape Object section on page 172. Again I recommend using the AENhancers After Effects Scripting Guide for future use.
Shape object attributes:
Source Code:
function setMaskPaths(layObj, maskData){
var maskDataLen, curData, newShape, newMask, comp, addShape, addVectorGroup;
maskDataLen = maskData[1].length;
if(maskDataLen > 0){
for(var s=0; s < maskDataLen; s++){
curData = maskData[1][s];
newShape = new Shape();
newShape.vertices = curData.vertices;
newShape.inTangents = curData.inTangents;
newShape.outTangents = curData.outTangents;
newShape.closed = curData.closed;
newShape.featherTypes = curData.featherTypes;
newShape.featherSegLocs = curData.featherSegLocs;
newShape.featherRelSegLocs = curData.featherRelSegLocs;
newShape.featherRadii = curData.featherRadii;
newShape.featherInterps = curData.featherInterps;
newShape.featherRelCornerAngles = curData.featherRelCornerAngles;
newShape.featherTensions = curData.featherTensions;
newMask = layObj.property("ADBE Mask Parade").addProperty("Mask");
newMask.property("ADBE Mask Shape").setValue(newShape);
newMask.name = maskData[0][s];
}
}
}