Skip to main content
Inspiring
April 25, 2024
Answered

How to get the currently opened bin?

  • April 25, 2024
  • 1 reply
  • 1364 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.
Inspiring
April 29, 2024

Views are tricky. 🙂

Users can create N views into M projects; loads of complexity. Panels can obtain the currently active project based on the active view, which enables finding that project's insertion bin, which tells it "If the user imported something via File --> Import right now, where would it land?"

>But in case #3, if you are inside a bin and highlighted an existing bin inside it, it returns the bin where you are, not the selected one.

In that state, does getInsertionBin() return the currently open bin, or the selected bin?


In case #3, getInsertionBin() returns the selected bin, viewSelection[0] returns the open bin. If I unselect the bin inside the open bin, both methods return the open bin.

 

I tried out how import behaves in Premiere by default, and it looks like it always respects the selected bin, otherwise, the opened bin. I didn't think I should consider the selected bin as the insertion point, but now I believe I should to be consistent with Premiere's behaviour.

 

So it looks like app.project.getInsertionBin() is all that I need after all. Thank you for your patience in answering my questions!