表达式批量删除脚本。如果选择特定属性,只删除该属性的表达式。如果选择图层,则删除图层设置的所有表达式。

如果把它放在 ScriptUI Panels 文件夹中,它有一个 UI,如果你把它放在 Scripts 文件夹中,可以在没有 UI 的情况下工作。

/*-------------------------------------
Select Parents N Children

Version History
1.0.1 [Current version]  -  Aug 16, 2021
    Change file name.

1.0.0  -  Aug 13, 2021
    Initial release
-------------------------------------*/

//______Files Path______
var thisFile = new File(this);
var thisFolderPath = thisFile.path;
var resourcePath = thisFolderPath + "/Remove Expressions Resources"
//______Build Main Panel______
function buildUI(thisObj){
    if(thisObj instanceof Panel){
        var win = thisObj;
    }else{
        /*
        var win = new Window("palette", "Remove Expressions", [0, 0, 116, 236], {resizeable:true})
        win.center();
        win.show();
        */
        removeExpressions();
    }       
    return win;
}

try{
    var win = buildUI(this);
    var buttonRect = [0, 0, 100, 30];
    var panelButtonSpace = [5, 5, 5, 5];
    var buttonSpace = [55, 0, 55, 0];
    var buttonA = win.add("Button", panelButtonSpace + buttonRect, "Remove!");

    function removeExpressions(){
        app.beginUndoGroup("Remove all Expressions");

        var comp = app.project.activeItem;
        var layerNumber = comp.selectedLayers.length;
        var slLayers = comp.selectedLayers;
        var slProp;
        var propNumber;

        if(layerNumber >= 1){
            for(var i = 0; i < layerNumber; i++){
                if(slLayers[i].selectedProperties.length >= 1){
                    deleteAllExpMenuCmd();
                }else{
                    var layerNames = slLayers[i].index;
                    recurse_children(comp.layers[layerNames]);
                }
            }
        }else{    
            alert('no layer selected');
        }

        function deleteAllExpMenuCmd(){
            slProp;
            for(var i = 0; i < layerNumber; i++){
                for(var k = 0; k < slLayers[i].selectedProperties.length; k++){
                    slProp = slLayers[i].selectedProperties[k];
                    if(slProp.canSetExpression && slProp.expression) slProp.expression = '';
                }
            }
        }


        function recurse_children(propParent){
            if(propParent != null){
                var prop;
                for(var i=1; i<=propParent.numProperties; i++){
                    prop = propParent.property(i);
                    switch(prop.propertyType)
                    {
                    case PropertyType.PROPERTY:
                        // do action
                        if(prop.canSetExpression && prop.expression) prop.expression = '';
                        break;
                    case PropertyType.INDEXED_GROUP:
                        recurse_children(prop);
                        break;
                    case PropertyType.NAMED_GROUP:
                        recurse_children(prop);
                        break;
                    default:
                        break;
                    }
                }
            }
        }
        app.endUndoGroup();
    }


    buttonA.onClick = function(){
        removeExpressions();
    }

}catch (e){
}
//try catch <-- To make it work even if you don't have it in ScriptUI Panels.

 

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

请下载到本地观看!因为pdf是用的阿里云盘预览,可能部分字体加载不了。

请安装油猴脚本,并下载月离的万事屋脚本。详情请查看菜单 导航 - 用户指引

请在右上角三个点 - 下载管理 - 找到刚才的文件,选择允许下载。 或者换个浏览器