Python - Make a subfolder folder (bin) active?

Get answers to your questions about color grading, editing and finishing with DaVinci Resolve.
  • Author
  • Message
Offline

jensenni

  • Posts: 23
  • Joined: Wed Jan 27, 2021 12:26 am
  • Real Name: Jens Klein

Python - Make a subfolder folder (bin) active?

PostTue Feb 09, 2021 5:35 pm

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!
Offline
User avatar

Igor Riđanović

  • Posts: 1630
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Python - Make a subfolder folder (bin) active?

PostThu Feb 11, 2021 8:19 am

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.
www.metafide.com - DaVinci Resolve™ Apps
Offline

jensenni

  • Posts: 23
  • Joined: Wed Jan 27, 2021 12:26 am
  • Real Name: Jens Klein

Re: Python - Make a subfolder folder (bin) active?

PostThu Feb 11, 2021 10:45 pm

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?
Offline
User avatar

Igor Riđanović

  • Posts: 1630
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Python - Make a subfolder folder (bin) active?

PostFri Feb 12, 2021 12:28 am

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()
www.metafide.com - DaVinci Resolve™ Apps

Return to DaVinci Resolve

Who is online

Users browsing this forum: Bing [Bot], dirk-pel, panos_mts, qsipher and 260 guests