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?
1 Correct answer
I tested using this code:
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();
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
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?
Copy link to clipboard
Copied
I tested using this code:
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'?
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.
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?
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!
Copy link to clipboard
Copied
You may need the ViewID stuff, to figure out which open project's insertion bin to get. 🙂

