/**
 * souce:https://github.com/zlovatt/zl_Scriptlets
 * Adds Trim Paths to selected shape layers, including a keyframe to start and one to end the animation.
 * 给选定形状图层添加修建路径,并创建2个关键帧
 * 按住shift键运行,则不添加添加关键帧.
 *
 * @author Zack Lovatt <zack@zacklovatt.com>
 * @version 1.3.1
 */
 (function addTrimPaths() {
    var addKeys = !ScriptUI.environment.keyboardState.shiftKey;
  
    var comp = app.project.activeItem;
  
    if (!(comp && comp instanceof CompItem)) {
      alert("请先选择合成");
      return;
    }
  
    var layers = comp.selectedLayers;
  
    if (layers.length === 0) {
      alert("请先选择形状图层");
      return;
    }
  
    app.beginUndoGroup("Add Trim Paths");
  
    for (var ii = 0, il = layers.length; ii < il; ii++) {
      var layer = layers[ii];
  
      if (layer.matchName !== "ADBE Vector Layer") {
        continue;
      }
  
      var contents = layer.property("ADBE Root Vectors Group");
  
      if (!contents.canAddProperty("ADBE Vector Filter - Trim")) {
        continue;
      }
      var trimProp = contents.addProperty("ADBE Vector Filter - Trim");
  
      if (!addKeys) {
        continue;
      }
  
      var trimEnd = trimProp.property("ADBE Vector Trim End");
  
      var trimTimes = [layer.inPoint, layer.inPoint + 1];
      var trimValues = [0, 100];
  
      trimEnd.setValuesAtTimes(trimTimes, trimValues);
    }
  
    app.endUndoGroup();
  })();

 

您的电子邮箱地址不会被公开。 必填项已用*标注