From cd6be19ce332843c7c5ca64452ca01364a7c5863 Mon Sep 17 00:00:00 2001 From: CAILLOT Cyprien Date: Fri, 23 Jun 2023 10:58:45 +0200 Subject: [PATCH] add rv integration in nuke --- openpype/hosts/nuke/api/pipeline.py | 51 ++++++++++++++++++- .../defaults/project_settings/openrv.json | 5 ++ .../schema_project_openrv.json | 29 ++++++++++- 3 files changed, 83 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/nuke/api/pipeline.py b/openpype/hosts/nuke/api/pipeline.py index d649ffae7f9..e69a96a6735 100644 --- a/openpype/hosts/nuke/api/pipeline.py +++ b/openpype/hosts/nuke/api/pipeline.py @@ -23,7 +23,7 @@ ) from openpype.pipeline.workfile import BuildWorkfile from openpype.tools.utils import host_tools - +from openpype.lib.applications import ApplicationManager from .command import viewer_update_and_undo_stop from .lib import ( Context, @@ -319,6 +319,8 @@ def _install_menu(): # adding shortcuts add_shortcuts_from_presets() + # adding rv + add_rv_from_presets() def change_context_label(): menubar = nuke.menu("Nuke") @@ -345,6 +347,53 @@ def change_context_label(): Context.context_label, label)) +def add_rv_from_presets(): + rv_settings = get_current_project_settings()["openrv"]['openrv_nuke_integration'] + + if not rv_settings['rvnuke_enabled']: + return + + if 'rvnuke_content_paths' not in rv_settings: + return + + for rv_nuke_path in rv_settings['rvnuke_content_paths']: + if os.path.exists(rv_nuke_path): + nuke.pluginAddPath(rv_nuke_path) + log.info("RV Nuke path added: {}".format(rv_nuke_path)) + else: + log.warning("RV Nuke path not found: {}".format(rv_nuke_path)) + + app_manager = ApplicationManager() + openrv_app = app_manager.find_latest_available_variant_for_group("openrv") + rv_exec_path = str(openrv_app.find_executable()) + + if not rv_exec_path: + return + try: + import rvNuke + rv_pref_panel = rvNuke.RvPreferencesPanel() + rv_pref_panel.rvPrefs.prefs["rvExecPath"] = rv_exec_path + rv_pref_panel.rvPrefs.saveToDisk() + except ImportError: + log.warning("rvNuke not found") + + nuke.addOnCreate(add_rv_shortcut, nodeClass="Root") + return + + +def add_rv_shortcut(): + rv_global_settings = get_current_project_settings()["openrv"] + rv_settings = rv_global_settings['openrv_nuke_integration'] + if rv_settings['rvnuke_open_in_rv_shortcut']: + menubar = nuke.menu("Nuke") + menu_item = menubar.findItem("RV/View in RV") + menu_item.setShortcut("Alt+v") + menu_item.setShortcut(rv_settings['rvnuke_open_in_rv_shortcut']) + log.info("Adding Shortcut `{}` to `{}`".format( + 'Open in RV', + rv_settings['rvnuke_open_in_rv_shortcut'])) + + def add_shortcuts_from_presets(): menubar = nuke.menu("Nuke") nuke_presets = get_current_project_settings()["nuke"]["general"] diff --git a/openpype/settings/defaults/project_settings/openrv.json b/openpype/settings/defaults/project_settings/openrv.json index bb7bc74a2de..e289727a8df 100644 --- a/openpype/settings/defaults/project_settings/openrv.json +++ b/openpype/settings/defaults/project_settings/openrv.json @@ -8,5 +8,10 @@ "enabled": true, "rules": {} } + }, + "openrv_nuke_integration": { + "rvnuke_enabled": false, + "rvnuke_content_paths" : [], + "rvnuke_open_in_rv_shortcut" : "Alt+v" } } diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_openrv.json b/openpype/settings/entities/schemas/projects_schema/schema_project_openrv.json index 0fbdf80833f..b9009c485c1 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_openrv.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_openrv.json @@ -21,6 +21,33 @@ "name": "schema_imageio_file_rules" } ] + }, + { + "key": "openrv_nuke_integration", + "type": "dict", + "label": "Nuke integration", + "collapsible": true, + "is_group": true, + "children": [ + { + "type": "boolean", + "key": "rvnuke_enabled", + "label": "Enable RV Nuke integration" + }, + + { + "type": "text", + "key": "rvnuke_open_in_rv_shortcut", + "label": "Open In Rv Shortcut" + }, + { + "type": "path", + "key": "rvnuke_content_paths", + "label": "RV Nuke Content Paths", + "multiplatform": false, + "multipath": true + } + ] } ] -} \ No newline at end of file +}