简体   繁体   English

Extendscript Comp 创建

[英]Extendscript Comp creation

I have a quick question and I've seem to hit a deadend here.我有一个快速的问题,我似乎在这里遇到了死胡同。 I'm trying to cycle through a selected folder and import all the assets from said folder, create a comp out of one specific asset and then layer the rest of the assets ontop of that specific comp.我正在尝试循环浏览选定的文件夹并从所述文件夹导入所有资产,从一个特定资产创建一个组合,然后将资产的 rest 分层到该特定组合之上。 It all seems to work until it tries to layer the rest of the assets.在它尝试对资产的 rest 进行分层之前,这一切似乎都有效。 Is there something I'm missing here?我在这里缺少什么吗?

Thanks so much!非常感谢!

 //Source Folder
//Manually select folder
var sourceFolder = Folder.selectDialog("Select folder with source files");


// Array holding source footage and directories
var sourceList = new Array();
var sourceList2 = new Array();
var sFolder = new Array();


//calls functions
importPlate(sourceFolder, sourceList, sourceList2);
genComp(sourceList);
//imports plate into project

function importPlate(sourceFolder, sourceList, sourceList2)
{
    var sourceFiles = sourceFolder.getFiles();
    $.writeln(sourceFolder);
    var footage;
    var footage2;
    var str = "";
    var word = new Array();
    var plate = "";
    for (var i = 0; i < sourceFiles.length; i++) 
    {
        str = sourceFiles[i].toString();
        word = str.split(".");
        plate = word[1];
        if(plate == "mov")
        {
            $.writeln(typeof footage)
            $.writeln(sourceList);
            $.writeln(typeof sourceList);
            $.write("This ran once");
            footage = app.project.importFile(new ImportOptions(sourceFiles[i]));
            sourceList.push(footage);            
        }
        else
        {
            sourceList2.push(footage2);
            footage2 = app.project.importFile(new ImportOptions(sourceFiles[i]));            
        }
    }

}


// Generate Compositions
function genComp(footage, footage2)
{
    for (var i = 0; i < sourceList.length; i++) 
    {
        var sourceFootage = sourceList[i];
        $.writeln(sourceFootage);
        var compName = sourceFootage.name.substring(0, sourceFootage.name.indexOf(".")) + "_" + i;
        $.writeln(compName);
        var newComp = app.project.items.addComp(compName, 4096, 2160, 1, sourceFootage.duration, sourceFootage.frameRate);
        $.writeln(newComp);
        newComp.layers.add(sourceFootage);
        for (var i = 0; i < sourceList2.length; i++)
        {
            $.writeln(sourceList[i]);
            var sourceFootage2 = sourceList2[i];
            $.writeln(sourceFootage2);
            newComp.layers.add ();
        }
    }
}

In your importPlate function, the else statement to help populate your variable for footage2 pushes the empty variable to sourceList2 before defining what it is.在您的footage2 function 中,else 语句可帮助填充您的变量,以便在定义它是什么之前将空变量推送到sourceList2 This is likely what's causing your 'undefined' when adding sourceFootage2 into your newComp.layers.add() at the bottom of the genComp function.这可能是在将sourceFootage2添加到 genComp function 底部的genComp newComp.layers.add()时导致“未定义”的原因。

EG例如

         else
        {
            sourceList2.push(footage2);
            footage2 = app.project.importFile(new ImportOptions(sourceFiles[i]));            
        }

Should be:应该:

        else
        {
            footage2 = app.project.importFile(new ImportOptions(sourceFiles[i])); 
            sourceList2.push(footage2);              
        }

I tested this and it seems to do what you had intended!我对此进行了测试,它似乎符合您的预期! Cheers!干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM