AfterEffect插件-常规功能开发-图层排序-js脚本开发-AE插件

1.图层排序功能

  AfterEffect(AE)插件是Adobe公司开发的特效制作软件,稳定快速的功能和特效,在视频制作领域使用非常广泛,本文向大家介绍如何在项目里进行图层排序功能。源代码如下所示:

{
    // Sort Layers by In Point.jsx
    //
    // This script reorders layers in the active comp, sorted by inPoint.
    //
    
    function SortLayersByInPoint(thisObj)
    {
        var proj = app.project;
        var scriptName = "Sort Layers by In Point";
        
        
        function sortByInpoint(comp_layers, unlockedOnly) {
            var total_number = comp_layers.length;
            while (total_number >= 2) { 
                var layer_was_moved = false;
                for (j = 1; j <= total_number; j++) {
                    // if you want to reverse the sort order, use "<" instead of ">".
                    if (comp_layers[j].inPoint > comp_layers[total_number].inPoint) {
                        if (comp_layers[j].locked) {
                            if (unlockedOnly==false) {
                                comp_layers[j].locked = false;
                                comp_layers[j].moveAfter(comp_layers[total_number]);
                                comp_layers[total_number].locked = true;
                                layer_was_moved = true;
                            }
                        } else {
                            comp_layers[j].moveAfter(comp_layers[total_number]);
                            layer_was_moved = true;
                        }
                    }
                }
                if (!layer_was_moved) {
                    total_number = total_number-1 ;
                }
            }
        }
        
        // change this to true if you want to leave locked layers untouched.
        var unlockedOnly = false;
        if (proj) {
            var activeItem = app.project.activeItem;
            if (activeItem != null && (activeItem instanceof CompItem)) {
                app.beginUndoGroup(scriptName);
                var activeCompLayers = activeItem.layers;
                sortByInpoint(activeCompLayers, unlockedOnly);
                app.endUndoGroup();
            } else {
                alert("Please select an active comp to use this script", scriptName);
            }
        } else {
            alert("Please open a project first to use this script.", scriptName);
        }
    }
    
    
    SortLayersByInPoint(this);
}

  合理的脚本代码可以有效的提高工作效率,减少重复劳动。

2.作者答疑


  如有疑问,请留言。

提示: 作者知了-联系方式1
提示: 作者知了-联系方式2

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容