Merge pull request #3168 from quadproduction/103-add-a-scripts-menu-definition-to-openpeype-nuke-settings

Add the scripts menu definition to nuke
This commit is contained in:
Jakub Ježek 2022-05-26 11:34:03 +02:00 committed by GitHub
commit 3207909ece
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 63 additions and 1 deletions

View file

@ -1,4 +1,5 @@
import nuke
import os
from openpype.api import Logger
from openpype.pipeline import install_host
@ -9,6 +10,7 @@ from openpype.hosts.nuke.api.lib import (
WorkfileSettings,
dirmap_file_name_filter
)
from openpype.settings import get_project_settings
log = Logger.get_logger(__name__)
@ -28,3 +30,32 @@ nuke.addOnScriptLoad(WorkfileSettings().set_context_settings)
nuke.addFilenameFilter(dirmap_file_name_filter)
log.info('Automatic syncing of write file knob to script version')
def add_scripts_menu():
try:
from scriptsmenu import launchfornuke
except ImportError:
log.warning(
"Skipping studio.menu install, because "
"'scriptsmenu' module seems unavailable."
)
return
# load configuration of custom menu
project_settings = get_project_settings(os.getenv("AVALON_PROJECT"))
config = project_settings["nuke"]["scriptsmenu"]["definition"]
_menu = project_settings["nuke"]["scriptsmenu"]["name"]
if not config:
log.warning("Skipping studio menu, no definition found.")
return
# run the launcher for Maya menu
studio_menu = launchfornuke.main(title=_menu.title())
# apply configuration
studio_menu.build_from_configuration(studio_menu, config)
add_scripts_menu()

View file

@ -15,6 +15,18 @@
"destination-path": []
}
},
"scriptsmenu": {
"name": "OpenPype Tools",
"definition": [
{
"type": "action",
"sourcetype": "python",
"title": "OpenPype Docs",
"command": "import webbrowser;webbrowser.open(url='https://openpype.io/docs/artist_hosts_nuke_tut')",
"tooltip": "Open the OpenPype Nuke user doc page"
}
]
},
"create": {
"CreateWriteRender": {
"fpath_template": "{work}/renders/nuke/{subset}/{subset}.{frame}.{ext}",

View file

@ -49,7 +49,7 @@
},
{
"type": "schema",
"name": "schema_maya_scriptsmenu"
"name": "schema_scriptsmenu"
},
{
"type": "schema",

View file

@ -79,6 +79,10 @@
}
]
},
{
"type": "schema",
"name": "schema_scriptsmenu"
},
{
"type": "dict",
"collapsible": true,

View file

@ -0,0 +1,14 @@
---
id: admin_hosts_nuke
title: Nuke
sidebar_label: Nuke
---
## Custom Menu
You can add your custom tools menu into Nuke by extending definitions in **Nuke -> Scripts Menu Definition**.
![Custom menu definition](assets/nuke-admin_scriptsmenu.png)
:::note Work in progress
This is still work in progress. Menu definition will be handled more friendly with widgets and not
raw json.
:::

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View file

@ -88,6 +88,7 @@ module.exports = {
items: [
"admin_hosts_blender",
"admin_hosts_maya",
"admin_hosts_nuke",
"admin_hosts_resolve",
"admin_hosts_harmony",
"admin_hosts_aftereffects",