Skip to main content
Inspiring
April 25, 2024
Answered

How to get the currently opened bin?

  • April 25, 2024
  • 1 reply
  • 1369 views

By this, I mean when you double-click on a bin and you are inside it.

I need a script that imports a file in another specified bin while respecting the current active bin as its parent bin.

 

While inside a bin, simply using app.project.importFiles(<path>) without specifying a ProjectItem would respect the current active bin. So far so good. However, if I need to create a new bin and import the file inside it, then I have to create the new bin first inside the current bin so I can pass that ProjectItem to importFiles().

 

The problem is that I can't find a way to get the ProjectItem of the currently opened bin. What is a good way to achieve this?

This topic has been closed for replies.
Correct answer SuwekongHilaw

I tested using this code:

  var viewIDs = app.getProjectViewIDs();
  var viewSelection = app.getProjectViewSelection(viewIDs[0]);
 
Result:
Case #1: Selected/highlighted 2 bins - viewSelection contains 2 items
Case #2: Entered/opened a bin, where there's another bin inside - viewSelection contains only one items, and that is of the currently opened bin
Case #3: While still in the opened bin, select/highlight the bin inside it - same as above, viewSelection still contains the currently opened bin item
 
I guess I can make a workaround through Case #2, but this feels like a hack to me.

1 reply

Adobe Employee
April 25, 2024

Hi SuwekongHilaw,

"the currently open bin" is not reflected in the API - and I don't think you need it.

In the sample panel on github, you'll find 

var viewIDs = app.getProjectViewIDs();

at https://github.com/Adobe-CEP/Samples/blob/9efca02ea88ad32a8c22571f5ffe2407ae732cd8/PProPanel/jsx/PPRO/Premiere.jsx#L1954 

this view gives you the project

Then you can use getInsertionBin()

Create containing bin within insertion bin

app.project.rootItem.createBin(containing bin)
then importFiles(), specifying new containing bin as destination

 

I hope that's helpful. Play with it a bit, then post back with other questions.

-Dan

SuwekongHilawAuthorCorrect answer
Inspiring
April 26, 2024

I tested using this code:

  var viewIDs = app.getProjectViewIDs();
  var viewSelection = app.getProjectViewSelection(viewIDs[0]);
 
Result:
Case #1: Selected/highlighted 2 bins - viewSelection contains 2 items
Case #2: Entered/opened a bin, where there's another bin inside - viewSelection contains only one items, and that is of the currently opened bin
Case #3: While still in the opened bin, select/highlight the bin inside it - same as above, viewSelection still contains the currently opened bin item
 
I guess I can make a workaround through Case #2, but this feels like a hack to me.
Bruce Bullis
Community Manager
Community Manager
April 26, 2024

>...this feels like a hack to me.

Dan showed you how to get the active view within PPro, find the corresponding project, get that project's insertion bin, and create your new destination bin within it. 

 

In what way is that a 'hack'?