Reassign keyboard shortcuts in Nuke6.3v8 -- now it's simple!
Now that Nuke 6.3v8 is out, the Foundry has given us a simple way to reassign keyboard shortcuts for items that are already in menus. This used to be rather complicated, but now it's easy. Here's how.
As an example we'll reassign the Posterize node to the control-p shortcut. In the "Nodes" panel, the vertical one with all the icons, Posterize lives in the "Color" submenu.
# We start by finding the "Nodes" menu.
nodes_menu = nuke.menu('Nodes')
# Here we verify that we got it correctly.
print nodes_menu.name()
# From there, we find the "Color" menu.
color = nodes_menu.findItem('Color')
# Also verifying that we got it.
print color.name()
# Now we grab the Posterize item.
posterize = color.findItem('Posterize')
# Verifying that we got it correctly and seeing if it already has a shortcut.
print posterize.name(), 'has this shortcut assigned:', posterize.shortcut()
You probably won't see any shortcut at all. Posterize doesn't have anything assigned by default. So let's set one.
posterize.setShortcut('Ctrl+P')
Now let's try printing the shortcut again.
print posterize.name(), 'has this shortcut assigned:', posterize.shortcut()
You should see in the script editor that Posterize has now been set to control-p. Try it and you'll drop a Posterize in the node graph. You can also see the shortcut when you find "Posterize" in the "Color" submenu from the "Nodes" panel.
You can use this technique to assign shortcuts to anything you find in Nuke's menus. The tricky bit is to know where to start. Earlier, we used the "Nodes" panel, but you can also change shortcuts in the menu bar along the top of the Nuke window by replacing "Nodes" with "Nuke" in the nuke.menu command. These two are the most common menus, but there are a few more. You can find out all about them by using the "help" command in the script editor.
help(nuke.menu)
Comments
ms = nuke.menu("Nodes").menu("ToolSets").addMenu("shortcuts")
ms.addCommand("Multiply", "nuke.createNod e("Merge2", "operation multiply")","Shift+m")
ms.addCommand("Stencil", "nuke.createNod e("Merge2", "operation stencil")","Ctrl+m")
ms.addCommand("Copy", "nuke.createNod e("Merge2", "operation copy")","Ctrl+shift+m")
and voilà ! Hope that help
Cheers
philhub
any idea. i need some help
RSS feed for comments to this post