Scripting in Resolve - Subscribing to events

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

piersdeseilligny

  • Posts: 33
  • Joined: Tue Apr 07, 2020 8:45 pm
  • Real Name: Piers Deseilligny

Scripting in Resolve - Subscribing to events

PostTue Sep 21, 2021 2:16 pm

Is there any way for a lua or python function inside a script to be triggered by an action in Resolve?

I'm looking to write a script which would cause a streamdeck to automatically change profile based on the currently selected page. An option would be to poll
Code: Select all
Resolve.GetCurrentPage()
every 500ms, or something along those lines, however it seems like a pretty inelegant and hacky solution, which may or may not have a detrimental effect on performance.

Is there a more elegant way of doing things?
Offline
User avatar

Igor Riđanović

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

Re: Scripting in Resolve - Subscribing to events

PostTue Sep 21, 2021 5:38 pm

No, that's the only solution for what you're trying to achieve.

Looping Resolve.GetCurrentPage() will not be sufficient though. Assuming this is an external script and you want to run it as a process you will need to make a resolve instance each time Resolve restarts. You'd need something like
Code: Select all
while true:
    try resolve.GetProjectManager():
        page = resolve.GetCurrentPage()
    except:
        resolve = get_your_resolve_instance()
        page = resolve.GetCurrentPage()
    time.sleep(.5)

You'll need to experiment to fins a sleep interval that's optimal. Of course, try to be more specific with the exception catching than the blanket "except" I have up there.
www.metafide.com - DaVinci Resolve™ Apps
Offline

pinthenet

  • Posts: 138
  • Joined: Mon May 18, 2020 3:23 pm
  • Real Name: John Payne

Re: Scripting in Resolve - Subscribing to events

PostTue Sep 21, 2021 6:34 pm

I can confirm Igor's explanation. I created a plugin for the Touch Portal app to control & monitor Resolve. The only solution to keep track of the selected page was similar to Igor's, and in fact GetCurrentPage is only a recent addition to the API. In my first attempt, before the call was added, I was monitoring the Resolve log file to recognise when the page changed ("Main view page is changed to nn" where "nn" is the number of the page). What a relief when one of the Beta releases introduced the new feature. I think I'm using a 500ms loop.
[size=85]
Laptop: Intel i7-10750H/32GB/RTX2060-6GB & Intel UHD Graphics 630
Windows 10 Home; NVIDIA 536.67 Studio; Resolve+Fusion 18.5

Return to DaVinci Resolve

Who is online

Users browsing this forum: Bing [Bot], Charles Bennett, MagPostColor, Mathematics, Peter Cave, Uli Plank and 212 guests