Most industry compositors have a menu.py they take around with them to every company to make sure all their compositing hotkeys/presets are the same no matter where they go, with artists sharing their best presets & working practices.
When I go to visit universities I’m often asked what I have in my Nuke menu.py and do I use Nuke presets. Beginners often make the mistake of thinking this will improve their compositing work. However presets are best used to speed up your workflow, so you have more time to spend on creative changes within your Nuke Composite.
The further you get in your VFX compositing career you often find yourself sharing parts of your menu.py with other Nuke compositors, so it becomes a file that you take with you to every VFX company so your hotkeys & setup stays the same.
What is a menu.py?
Your menu.py file is a python file that contains scripts to run on opening Nuke. Using it we can create commands for presets that we want to use in Nuke. It is not run when NUKE is launched for a command-line session or render. Because of this, you should use menu.py just for commands that are only relevant to interacting within Nuke
Where is your Nuke menu.py?
Your menu.py can be found in user/.nuke. Your .nuke folder is a hidden directory, so you’ll have to go into your operating system settings to show your hidden files.
Where to find your first Nuke python reference
Now you’ve found your Nuke menu.py, you need to fill it with useful compositing presets to speed up your compositing workflow. The foundry have a great resource you can find click here for Nuke python developers. So it’s well worth looking at for ideas.
Check for mistakes
If there’s a mistake within the python in your Nuke menu.py, Nuke won’t open, so it’s not a good idea to do this when in the middle of compositing a project. With this in mind, it’s a great working practice to set up one new thing in your Nuke menu.py then save it out and see if Nuke still opens fine. This way it’s nice and easy to problem solve if Nuke suddenly doesn’t open.
Set a Nuke Node default
I use my menu.py to set Nuke node defaults, as any Nuke nodes you find yourself changing multiple times to the same setting, you should try to automate with you menu,py.
Here’s the python to set a default knob value for a particular type of node:
So if we wanted to set all remove nodes default operation to keep we’d put the following into our menu.py
Speed up your Nuke Compositing Workflow
Now you’ve created your first Nuke preset, here’s some python snippets I use to speed up my Nuke compositing workflow. Wherever you see a # it’s a comment to myself, this ensures python will ignore any text on this line. Make sure to put import nuke at the top of your menu.py.
Close all Nuke property panels with hotkey shift+d.
[node.hideControlPanel() for node in nuke.allNodes()] nuke.menu( ‘Nodes’ ).addCommand( ‘close’, ‘close()’ , ‘shift+d’)
Make a frame hold that will hold on the frame it’s created.
This one has sped up my Nuke compositing workflow a massive amount, it’s seriously nice to not have to go in and change the frame. Especially when setting up projections within Nuke.
#creates framehold that defaults to current frame
nuke.menu(‘Nodes’).addCommand( “Time/FrameHold”, “nuke.createNode(‘FrameHold’)[‘first_frame’].setValue( nuke.frame() )”, icon=’FrameHold.png’)
set remove node to keep rgba
It’s always a good idea to get rid of your unused channels, I use this setup a lot. Especially if your CG renders have lots of channels you don’t want travelling down your Nuke script.
set merge nodes bbox to B
## default merge node bbox to b