Menu.py customization

I have spent some time this last month learning some basic Python and learning how to customize Nuke in order to improve my productivity. Apart from little scripts that I have created (which I will share in next posts), I found that configuring nodes’ default values in the meny.py file is a very powerful way to start making things easier.

For those who are not familiar with Python, don’t be afraid. Customizing Nuke’s nodes default values only require this command:

nuke.knobDefault('A.B', 'C')
  • nuke.knobDefault(): This is the command that tells Nuke to set a default value to a certain node’s knob.
  • A: This is the place where the node class goes. Sometimes the node’s classdoesn’t match the name we use to find it. You can use Script Editor’s “Echo python commands to output window” to check the class or you can also select the node and press ‘i’.
  • B: Here you must put the knob’s name. Sometimes the knob’s name doesn’t match the name that is given in the interface display. To be sure, put the mouse over the knob and Nuke will tell you it’s “real” name.
  • C: This is where you put the desired value

Remember that A.B and C must be between quotation marks.

These are some custom default values that I have set in my menu.py that avoid me doing certain repetitive tasks:

# Write
#### Default for EXR files: 16bit Half, No Compression
nuke.knobDefault("Write.exr.compression","0")
#### Default for TIFF files: No Compression
nuke.knobDefault("Write.tiff.compression","0")
#### Default for JPEG files: Max Quality
nuke.knobDefault("Write.jpeg._jpeg_quality","1")

# DeepWrite
#### Default for EXR files: 16bit Half, no compression
nuke.knobDefault("DeepWrite.exr.compression","0")

# CameraTracker
#### Calc lens distortion by default
nuke.knobDefault("CameraTracker.lensDistortionTypeLink","1")
#### No linked output
nuke.knobDefault("CameraTracker.linkOutput","0")
#### Refine features by default
nuke.knobDefault("CameraTracker.refineFeatures","1")
#### Preview features by default
nuke.knobDefault("CameraTracker.previewFeatures","1")

# Card
#### Minimun amount of rows and columns
nuke.knobDefault('Card.rows','1')
nuke.knobDefault('Card.columns','1')

# ModelBuilder
#### Card subd to 1
nuke.knobDefault("ModelBuilder.newCardRows","1")
nuke.knobDefault("ModelBuilder.newCardCols","1")

These involve a little bit of TCL and Python coding, but I find them very useful to make my Nuke files more readable:

# LensDistortion
#### Show the action of the node in the label
nuke.knobDefault('LensDistortion.label','[if [knob invertDistortion] {return "UNDISTORT"} else {return "DISTORT"}]')

# Tracker
#### Show the action of the node in the label
nuke.knobDefault('Tracker4.label','[python {nuke.thisNode().knob("transform").value().upper()}]')

# Project3D
#### Show the projection type in the label
nuke.knobDefault('Project3D2.label','[python {nuke.thisNode().knob("project_on").value().upper()}]')

# Shuffle
#### Show the action in the label
nuke.knobDefault('Shuffle.label','[python {nuke.thisNode().knob("in").value().upper()}] to [python {nuke.thisNode().knob("out").value().upper()}]')

#Constant
#### Show the format in the label
nuke.knobDefault("Constant.label","[lrange [split [value format] ] 7 7 ]")

#Colorspace
#### Show color space transfer in the label
nuke.knobDefault("Colorspace.label","[value colorspace_in] to [value colorspace_out]")

If you need any help or you want to share your own configuration or tips, please feel free to contact me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.