Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Nuke and Hiero #33

Merged
merged 1 commit into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ For more info read the [wiki](https://github.com/hannesdelbeke/unimenu/wiki)
If you use Blender, you can try the [unimenu_addon](https://github.com/hannesdelbeke/unimenu_addon)

<img src="samples/menu_screen_maya.jpg" width="400"/> <img src="samples/menu_screen_unreal5.jpg" width="400"/> <img src="samples/menu_screen_krita.jpg" width="400"/> <img src="samples/menu_screen_substance_painter.jpg" width="400"/>
<img src="samples/menu_screen_nuke.jpg" width="400"/>

# how to use

Expand Down Expand Up @@ -84,6 +85,8 @@ unimenu was tested in the following versions, and might work in other versions.
- Substance Painter 8.2.0
- Max 2024
- Marmoset 3.08
- nuke 13 (minimum)
- hiero 13 (minimum)

python 3.7+ due to f-strings and pathlib

Expand Down
Binary file added samples/menu_screen_nuke.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions samples/nuke_sample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
"""
a pure qt demo
"""

import unimenu.apps.nuke
from PySide2 import QtWidgets

data = {
'label': 'Tools',
'items':
[
{
'command': 'print("hello 1")',
'label': 'tool1',
},
{
'separator': True,
},
{
'command': 'print("hello 2")',
'label': 'tool2'
},
{
'label': 'Tools',
'items':
[
{
'command': 'print("hello 1")',
'label': 'tool1'
},
{
'command': 'print("hello 2")',
'label': 'tool2'
}
]
}
]
}

nodes_menu_data = {
"parent_path": "Nodes",
'label': 'Tools',
'items':
[
{
'command': 'print("hello 1")',
'label': 'tool1',
},
{
'separator': True,
},
{
'command': 'print("hello 2")',
'label': 'tool2'
},
{
'label': 'Tools',
'items':
[
{
'command': 'print("hello 1")',
'label': 'tool1'
},
{
'command': 'print("hello 2")',
'label': 'tool2'
}
]
}
]
}

# create a nuke menu

import unimenu
from unimenu.apps import SupportedApps


# config = Path(unimenu.__file__).parent.parent / "samples/config.json"
unimenu.setup(data, SupportedApps.NUKE)

# Create to Nodes

unimenu.setup(nodes_menu_data, SupportedApps.NUKE)
2 changes: 2 additions & 0 deletions unimenu/apps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class SupportedApps:
SUBSTANCE_DESIGNER = App(name="substance_designer", module="pysbs")
SUBSTANCE_PAINTER = App(name="substance_painter", module="substance_painter")
MARMOSET = App(name="marmoset", module="mset")
NUKE = App(name="nuke", module="nuke")
HIERO = App(name="hiero", module="hiero")

QT = App("qt", None)

Expand Down
42 changes: 42 additions & 0 deletions unimenu/apps/hiero.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from unimenu.apps._abstract import MenuNodeAbstract
import hiero
from PySide2 import QtGui


class MenuNodeHiero(MenuNodeAbstract):

@property
def _default_root_parent(self):
menubar = None
if self.parent_path:
try:
menubar = hiero.ui.findMenuAction(self.parent_path)
except Exception:
menubar = None

if not menubar:
menu = hiero.ui.menuBar()
else:
menu = menubar.menu()
return menu

def _setup_sub_menu(self, parent_app_node=None):
if not self.label:
self.label = "custom_menu"
if parent_app_node:
return parent_app_node.addMenu(self.label)
else: # make a normal sub menu
return hiero.ui.menuBar().addMenu(self.label)

def _setup_menu_item(self, parent_app_node=None):
menu_action = parent_app_node.addAction(self.label)
if self.icon:
menu_action.setIcon(QtGui.QIcon(self.icon))
menu_action.triggered.connect(self.run)

def _setup_separator(self, parent_app_node=None):
if parent_app_node:
parent_app_node.addSeparator()

def teardown(self):
raise NotImplementedError("not yet implemented")
40 changes: 40 additions & 0 deletions unimenu/apps/nuke.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import logging
from unimenu.apps._abstract import MenuNodeAbstract
import nuke


class MenuNodeNuke(MenuNodeAbstract):
nuke_menu_instance = ["Nuke", "Pane", "Nodes", "Properties", "Animation", "Viewer", "Node Graph", "Axis"]

@property
def _default_root_parent(self):
if self.parent_path:
parent_path = self.parent_path if self.parent_path in self.nuke_menu_instance else "Nuke"
else:
parent_path = self.nuke_menu_instance[0]
menubar = nuke.menu(parent_path)
return menubar

def _setup_sub_menu(self, parent_app_node=None):
if not self.label:
self.label = "custom_menu"
if parent_app_node:
if self.icon:
return parent_app_node.addMenu(self.label, self.icon)
return parent_app_node.addMenu(self.label)
else: # make a normal sub menu
return nuke.menu("Nuke").addMenu(self.label)

def _setup_menu_item(self, parent_app_node=None):
parent_app_node.addCommand(self.label, self.run)

def _setup_separator(self, parent_app_node=None):
if parent_app_node:
parent_app_node.addSeparator()

def teardown(self):
menubar = nuke.menu(self.parent_path)
menu = menubar.findItem(self.name)
for item in menu.items():
logging.info("Removing menu item: {}".format(item.name()))
menu.removeItem(item.name())