SHARE
TWEET

Untitled

a guest Oct 13th, 2017 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. app.beginUndoGroup("Invert Shape Path");
  2. var curComp = app.project.activeItem;
  3. if(curComp != null && curComp instanceof CompItem){
  4.     var selectedProps = curComp.selectedProperties;
  5.     var propsNum = selectedProps.length;
  6.     if(propsNum > 0){
  7.         var targetShapeObj, verticesArray, inTangentsArray, outTangentsArray, shapeObj, curKeyIndex;
  8.         for(var i = 0; i < propsNum; i++){
  9.             if(selectedProps[i].matchName == "ADBE Vector Shape"){
  10.                 verticesArray = selectedProps[i].value.vertices.reverse();
  11.                 inTangentsArray = selectedProps[i].value.inTangents.reverse();
  12.                 outTangentsArray = selectedProps[i].value.outTangents.reverse();
  13.                 shapeObj = new Shape();
  14.                 shapeObj.vertices = verticesArray;
  15.                 shapeObj.inTangents = outTangentsArray;
  16.                 shapeObj.outTangents = inTangentsArray;
  17.                 if(selectedProps[i].numKeys > 0){
  18.                     curKeyIndex = selectedProps[i].nearestKeyIndex(curComp.time);
  19.                     selectedProps[i].setValueAtKey(curKeyIndex, shapeObj);
  20.                 } else {
  21.                     selectedProps[i].setValue(shapeObj);
  22.                 }
  23.             }
  24.         }
  25.     } else {
  26.         alert("You need to select a shape path at least.", "Invert Shape Path");
  27.     }
  28. } else {
  29.     alert("Select a composition first.", "Invert Shape Path");
  30. }
  31. app.endUndoGroup();
RAW Paste Data
Top