• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

How to get the currently opened bin?

Community Beginner ,
Apr 25, 2024 Apr 25, 2024

Copy link to clipboard

Copied

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?

TOPICS
SDK

Views

267

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Apr 26, 2024 Apr 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
...

Votes

Translate

Translate
Adobe Employee ,
Apr 25, 2024 Apr 25, 2024

Copy link to clipboard

Copied

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/PPR...

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 26, 2024 Apr 26, 2024

Copy link to clipboard

Copied

It looks like that if app.getProjectViewIDs() returns only one element, either that bin is selected or you are inside it. Is this a safe assumption?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 26, 2024 Apr 26, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Apr 26, 2024 Apr 26, 2024

Copy link to clipboard

Copied

>...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'?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 27, 2024 Apr 27, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Apr 27, 2024 Apr 27, 2024

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

LATEST

You may need the ViewID stuff, to figure out which open project's insertion bin to get. 🙂


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines