Skip to main content
kevinsmock
Participant
March 29, 2020
Question

ExtendScript - Premiere - Open Sequence Without Its ID

  • March 29, 2020
  • 1 reply
  • 445 views

I have a variable that I’ve targeted by means of using for loops and if statements.

And, I happen to know it’s a sequence.

But, from what I know of ExtendScript (and it’s not that much), I’m under the impression I’d need the sequenceID of the sequence this variable is holding in order to open it or clone it - or whatever.

 

The thing is, I’m trying to work in a way that I’m just altering sequences based on the fact that they live in a particular bin. So, accessing sequences the traditional way of “app.project.sequences” doesn’t seem sensible to me.

 

Looking at what I have, is there a way to open a sequence without the ID?

Or, better yet, is there a way for me to conveniently access the sequence ID?

 

Below is the code I’ve been working with thus far:

 

 

for (i = 0; i < app.project.rootItem.children.numItems; i++) {

    if (app.project.rootItem.children[i].name == "SEQUENCES") {
    
    var theBin = app.project.rootItem.children[i];

    }

}

for (j = 0; j < theBin.children.numItems; j++) {
    
    if (theBin.children[j].name == "*ARCHIVE") {
        var theArchiveBin = theBin.children[j];
        theArchiveBin.setColorLabel(4);
        }
    
            if (theBin.children[j].type != ProjectItemType.BIN) {
            var theSeq = theBin.children[0];
            //At any given time in this "SEQUENCES" bin, there's only ever one sequence and then a bin called "*ARCHIVE" -- that's how I know "children[0]" is what I need.
            }  
}

//Confirming I have the correct sequence
alert(theBin.children[0].name);

//Here is where I'd like to CLONE or OPEN the sequence, but I don't have the ID!

 

 

Thanks very much!

    This topic has been closed for replies.

    1 reply

    Participant
    December 4, 2020

    From the sequences you can grab the sequenceID as follows:

    app.project.sequences[index].sequenceID

     

    The sequence object also has a projectItem property, which has a nodeId.

    app.project.sequences[index].projectItem
    app.project.rootItem.children[index].nodeId

     

    Thus, to get theBin.children[0]'s sequenceID, you have to iterate through your app.project.sequences, then compare app.project.sequences[i].projectItem.nodeId to the nodeId of theBin.children[0]. Once you have a match, you can grab app.project.sequences[i].sequenceID for opening the sequence. For cloning, you can run the clone command directly on the app.project.sequences[i]

    app.project.sequences[index].clone()