[AE脚本源码]快速选择图层

介绍

文本框输入内容按回车 或者失焦, 就可以选择当前合成包含此文本的图层

js源码

/**
 * name:Fast Select
 * version: 0.0.1
 * description: You can input some text, then this script will select all layer that contain this text
 * author: yueli
 * link: https://www.yuelili.com/ae/ae-dev/ae-dev-script/ae-script-source-code-quickly-select-layers/

 */

var panelGlobal = undefined;
(function () {
    var fast_select =
        panelGlobal instanceof Panel
            ? panelGlobal
            : new Window('palette', undefined, undefined, {
                  resizeable: true,
              });
    if (!(panelGlobal instanceof Panel)) fast_select.text = 'Fast Select';
    fast_select.preferredSize.width = 104;
    fast_select.preferredSize.height = 61;
    fast_select.orientation = 'row';
    fast_select.spacing = 10;
    fast_select.margins = 16;
    var input = fast_select.add('edittext');
    input.text = '输入图层名';
    input.onChange = selectLayers;
    function selectLayers() {
        if (input.text.length === 0 || input.text == '输入图层名') {
            return;
        }
        var activeComp = app.project.activeItem;
        if (!activeComp || !(activeComp instanceof CompItem)) {
            return;
        } else {
            app.executeCommand(2004);
            for (var i = 1; i <= activeComp.layers.length; i++) {
                var layer = activeComp.layer(i);
                if (layer.name.indexOf(input.text) !== -1) {
                    layer.selected = true;
                }
            }
        }
    }
    fast_select.layout.layout(true);
    fast_select.layout.resize();
    fast_select.onResizing = fast_select.onResize = function () {
        this.layout.resize();
    };
    if (fast_select instanceof Window) fast_select.show();
    return fast_select;
})();

typescript源码

const panelGlobal: any = this;
(function () {
    /*
  Code for Import https://scriptui.joonas.me — (Triple click to select): 
  {"activeId":1,"items":{"item-0":{"id":0,"type":"Dialog","parentId":false,"style":{"enabled":true,"varName":"fast_select","windowType":"Palette","creationProps":{"su1PanelCoordinates":false,"maximizeButton":false,"minimizeButton":false,"independent":false,"closeButton":true,"borderless":false,"resizeable":true},"text":"Fast Select","preferredSize":[104,61],"margins":16,"orientation":"row","spacing":10,"alignChildren":["right","center"]}},"item-1":{"id":1,"type":"EditText","parentId":0,"style":{"enabled":true,"varName":"input","creationProps":{"noecho":false,"readonly":false,"multiline":false,"scrollable":false,"borderless":false,"enterKeySignalsOnChange":false},"softWrap":false,"text":"EditText","justify":"left","preferredSize":[0,0],"alignment":null,"helpTip":null}}},"order":[0,1],"settings":{"importJSON":true,"indentSize":false,"cepExport":false,"includeCSSJS":true,"showDialog":true,"functionWrapper":true,"afterEffectsDockable":true,"itemReferenceList":"None"}}
  */

    // FAST_SELECT
    // ===========
    var fast_select =
        panelGlobal instanceof Panel ? panelGlobal : new Window('palette', undefined, undefined, { resizeable: true });
    if (!(panelGlobal instanceof Panel)) fast_select.text = 'Fast Select';
    fast_select.preferredSize.width = 104;
    fast_select.preferredSize.height = 61;
    fast_select.orientation = 'row';
    fast_select.spacing = 10;
    fast_select.margins = 16;

    var input = fast_select.add('edittext');
    input.text = '输入图层名';

    input.onChange = selectLayers;

    function selectLayers() {
        if (input.text.length === 0 || input.text == '输入图层名') {
            return;
        }

        const activeComp = app.project.activeItem;
        if (!activeComp || !(activeComp instanceof CompItem)) {
            alert('请选择一个合成!');
        } else {
            app.executeCommand(2004);

            for (var i = 1; i <= activeComp.layers.length; i++) {
                const layer = activeComp.layer(i);
                if (layer.name.indexOf(input.text) !== -1) {
                    layer.selected = true;
                }
            }
        }
    }

    fast_select.layout.layout(true);
    fast_select.layout.resize();
    (fast_select as Window).onResizing = (fast_select as Window).onResize = function () {
        this.layout.resize();
    };

    if (fast_select instanceof Window) fast_select.show();

    return fast_select;
})();

给TA充电
共{{data.count}}人
人已充电
AE

[AE] AE内置插件图鉴 cc2015

2023-12-7 12:24:02

AE开发PS/PR/AI脚本

[Adobe开发] 注册表: 通过python获取软件安装路径

2024-2-5 8:07:11

2 条回复 A文章作者 M管理员
  1. 未名游客给作者打赏了¥20
  2. 秦河绮

    好东西

个人中心
今日签到
搜索