Python - Make a subfolder folder (bin) active?

Posted:
Tue Feb 09, 2021 5:35 pm
by jensenni
I am running a custom python(v3) script with DaVinciResolve(v15) API and need to make a folder (bin) named "OUTPUT" active (selected). Is there a way to do this?
Thank you!
Re: Python - Make a subfolder folder (bin) active?

Posted:
Thu Feb 11, 2021 8:19 am
by Igor Riđanović
You use SetCurrentFolder(f) where "f" is the instance representing the bin you want to make current (active). First you have to traverse the bin tree using GetFoldersInCurrentFolder(). If you have multiple bins with the same name you have to use some additional logic to determine which one is the one you're looking for.
Re: Python - Make a subfolder folder (bin) active?

Posted:
Thu Feb 11, 2021 10:45 pm
by jensenni
MacOS 10.13.2. | DVR v15.3.1 | Python 3.6.8
Thank you very much for your feedback. Doing what you suggested gives me these errors in the terminal:
film:~ jens$ Python
Python 2.7.10 (default, Jul 15 2017, 17:16:57)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import DaVinciResolveScript as dvr
>>> resolve = dvr.scriptapp('Resolve')
>>> pm = resolve.GetProjectManager()
>>> proj = pm.GetCurrentProject()
>>> tl = proj.GetCurrentTimeline()
>>> mp = proj.GetMediaPool()
>>> ms = resolve.GetMediaStorage()
>>> folder = mp.GetRootFolder()
>>> folder.GetName()
'Master'
>>> SetCurrentFolder(TRANSCRIBE)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'SetCurrentFolder' is not defined
>>> GetFoldersInCurrentFolder()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'GetFoldersInCurrentFolder' is not defined
>>>
I am not sure why this isn't working for me. Any suggestions?
Re: Python - Make a subfolder folder (bin) active?

Posted:
Fri Feb 12, 2021 12:28 am
by Igor Riđanović
In your case:
- Code: Select all
mp.SetCurrentFolder(folder)
Where "folder" is an instance of a Resolve folder, not a string. You could however make your own convenience method that accepts a bin name as the argument. The trouble with that as I mentioned in the previous post is that the user could have any number of bins with the same name in one project.
- Code: Select all
pm.GetFoldersInCurrentFolder()