Skip to main content
sberic
Legend
May 19, 2017
Answered

Finding a bin with Project.findItemsMatchingMediaPath()?

  • May 19, 2017
  • 2 replies
  • 1749 views

I'm trying to figure out how to locate a known bin by name. I see that there's a Project.findItemsMatchingMediaPath() API. I've been able to use it to locate Clips but attempts to locate Bins have been unsuccessful.

What's the expected way for us to traverse the bin hierarchy? What's the best way to locate a specific bin within the project?

This topic has been closed for replies.
Correct answer e_d_

You can either do it as andymees@aje​ has suggested for an iterative "drill down" seach, or if you have a projectItem, use its treePath property for "bubble up" search (split by slashes, array length will help you figure out the "level"...)

Bins don't have a media path, they're just hierarchy objects (with projectItemType = 2).

2 replies

e_d_Correct answer
Inspiring
May 20, 2017

You can either do it as andymees@aje​ has suggested for an iterative "drill down" seach, or if you have a projectItem, use its treePath property for "bubble up" search (split by slashes, array length will help you figure out the "level"...)

Bins don't have a media path, they're just hierarchy objects (with projectItemType = 2).

andymees@aje
Legend
May 20, 2017

Hey sberic, there's a function in Bruce's PProPanel Premiere.jsx script that specifically addresses this : searchForBinWithName

Samples/Premiere.jsx at master · Adobe-CEP/Samples · GitHub

sberic
sbericAuthor
Legend
May 22, 2017

andymees@aje​ wrote

Hey sberic , there's a function in Bruce's PProPanel Premiere.jsx script that specifically addresses this : searchForBinWithName

Thanks for the pointer, andymees@aje​​. Unfortunately, that code only partially solves the problem. The function would be more aptly named "searchForBinWithNameInProjectRoot". It does not help if you have a path that goes beyond the root bin.

e.d. wrote

You can either do it as andymees@aje has suggested for an iterative "drill down" seach, or if you have a projectItem, use its treePath property for "bubble up" search (split by slashes, array length will help you figure out the "level"...)

The drill-down search I understand. It was our original approach until findItemsMatchingMediaPath() got our hopes up. I don't follow what you mean with the "bubble up", though. I guess you mean that you could iteratively search the children of each bin in the path, enabling a directed search, rather than a standard depth or breadth-first search?

e.d. wrote

Bins don't have a media path, they're just hierarchy objects (with projectItemType = 2).

Gotcha. That's a bit unfortunate. It feels very similar to file/directory traversal. Seems like some documentation for the findItemsMatchingMediaPath() is in order; some that includes the restrictions on how it may be used.

I guess I'd like to eventually see an API like findItemsMatchingPath() be added to stop us all from having to write the same "digging down" code.

Inspiring
May 23, 2017

sberic  schrieb

Thanks for the pointer, andymees@aje . Unfortunately, that code only partially solves the problem. The function would be more aptly named "searchForBinWithNameInProjectRoot". It does not help if you have a path that goes beyond the root bin.

Oh you're referring to Line#188, I was thinking in terms of Line#835, and to modify/combine this with the former. Should be doable.

The drill-down search I understand. It was our original approach until findItemsMatchingMediaPath() got our hopes up. I don't follow what you mean with the "bubble up", though. I guess you mean that you could iteratively search the children of each bin in the path, enabling a directed search, rather than a standard depth or breadth-first search?

I meant to say should you already have a (reference to a) projectItem as a result of a previous query/process/whatever, this would also give you a reference to its bin "position", right?