/**
 * 开关选择图层所有属性的表达式,如果开启,则关闭。如果关闭则开启
 *
 * @author Zack Lovatt <zack@zacklovatt.com>
 * @version 0.2.0
 */
 (function() {
    /**
     * Recursively loops through all properties and disables found expressions
     * 递归遍历所有属性,并禁用表达式
     * @param {PropertyGroup} propertyGroup Property group to loop through
     */
    function recursiveDisableExpressions(propertyGroup) {
      for (var ii = 1; ii <= propertyGroup.numProperties; ii++) {
        var property = propertyGroup.property(ii);
  
        if (property instanceof PropertyGroup) {
          recursiveDisableExpressions(property);
          continue;
        }
  
        if (!property.canSetExpression) {
          continue;
        }
        try {
            if (property.expressionEnabled === true) {
                property.expressionEnabled = false;
              }
            else{
                property.expressionEnabled = true;
            }
       } catch (error) {
            continue
        }
      }
    }
  
    app.beginUndoGroup('Disable All Comp Expressions');
  

  
    if (!(comp && comp instanceof CompItem)) {
      alert('Open a comp!');
      return;
    }
    // 遍历合成(我觉得不合理,改成遍历选择图层了
    // for (var ii = 1; ii <= comp.numLayers; ii++) {
    //     var layer = comp.layer(ii);


    var comp = app.project.activeItem;
    var layerNumber = comp.selectedLayers.length;
    var slLayers = comp.selectedLayers;
    for (var ii = 0; ii < layerNumber; ii++) {
      var layer = slLayers[ii];

  
      recursiveDisableExpressions(layer);
    }
  
    app.endUndoGroup();
  })();


 

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