Skip to main content
Inspiring
April 25, 2024
Answered

How to get the currently opened bin?

  • April 25, 2024
  • 1 reply
  • 1358 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 27, 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'?


Sorry, it's more of an ignorance on my side. I probably don't understand the term "view", and can't guess exactly what those two methods (app.getProjectViewIDs, app.getProjectViewSelection) exactly do.

 

In the tests I did above, case #1 seems to imply that getProjectViewSelection returns all selected/highlighted bins. 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. So case #2 does what I need, but I don't understand fully why.

I'm still using this site as a reference: https://ppro-scripting.docsforadobe.dev/introduction/index.html, do you guys have other suggestions?

Thank you Dan for steering me in the right direction.