3232
3333from . import constants
3434from . import lib
35- from .utils import get_resolve_module
35+ from .utils import (
36+ get_resolve_module ,
37+ set_resolve_module
38+ )
3639from .workio import (
3740 open_file ,
3841 save_file ,
5659
5760class ResolveHost (HostBase , IWorkfileHost , ILoadHost , IPublishHost ):
5861 name = "resolve"
62+ _app = None
5963
6064 def install (self ):
6165 """Install resolve-specific functionality of avalon-core.
@@ -79,11 +83,31 @@ def install(self):
7983 register_creator_plugin_path (CREATE_PATH )
8084 register_inventory_action_path (INVENTORY_PATH )
8185
86+ # DaVinci Resolve version >= 20
87+ # Set api resolve modules from undocumented injected cached app.
88+ # https://forum.blackmagicdesign.com/viewtopic.php?f=21&t=113252
89+ try :
90+ bmdvf = self ._app
91+ bmdvr = self ._app .GetResolve ()
92+
93+ if not bmdvr :
94+ raise RuntimeError ("Expecting valid Resolve module from app." )
95+
96+ set_resolve_module (bmdvr , bmdvf )
97+
98+ # If any issue, default to DaVinci Resolve Studio mechanism.
99+ except Exception as error :
100+ log .info (
101+ "Could not gather resolve apps from cached entry point %r. "
102+ "Default to DaVinci Resolve Studio specific logic." ,
103+ error ,
104+ )
105+ get_resolve_module ()
106+
82107 # register callback for switching publishable
83108 pyblish .register_callback ("instanceToggled" ,
84109 on_pyblish_instance_toggled )
85110
86- get_resolve_module ()
87111
88112 def open_workfile (self , filepath ):
89113 success = open_file (filepath )
@@ -119,6 +143,12 @@ def update_context_data(self, data, changes):
119143 # TODO: implement to support persisting context attributes
120144 pass
121145
146+ @classmethod
147+ def set_resolve_modules_from_app (cls , app ):
148+ """ Cache injected entry point "app" as class variable for re-use.
149+ """
150+ cls ._app = app
151+
122152 @staticmethod
123153 def _show_ayon_settings_confirmation_windows ():
124154 """
0 commit comments