Q100159: Setting Default Values for Controls



Nuke has default settings for many things throughout the application.  You can change what the default is in many cases.  Often, this means adding a line to a python script that automatically runs each time Nuke starts up, and this file is called init.py.   Nuke has one of these files in its installation directory, but it also reads and uses additional init.py files that you may add yourself.  It is a good idea to add one of these rather than changing the default init.py in the Nuke install.  Most of Nuke's default values are not set in the installed init.py anyway, so there's often not a default value to edit.  Adding a new init.py of your own with an explicit command in it to set a new default is the proper approach.

Init.py is simply a plain-text file that you can create or edit in any text editor.  It can be empty or it can contain as many lines (commands) as you wish.  It is associated with the username under which you login into your machine, so each user would have his or her own init.py file.  The file is read each time Nuke starts up, in both interactive or render-only modes.  Create an init.py of your own and save it in your .nuke directory.  See 

Q100048: Nuke Directory Locations

for more about where your .nuke directory is located.


Some of the default values you can set are detailed below.

1. Nuke ships with default font Utopia.  The Nuke default font can be modified by adding a line to your init.py file.  For example, to change Nuke's default font to Helvetica Regular, add this code:
nuke.knobDefault('Text.font', '<path>/HelveticaRegular. ttf') 
Note that <path> should be replaced by the path to your font file.

2.  You can change Nuke's default compression setting when rendering EXR files.  When you set a path for filename.exr, the Write node default for compression is  'Zip (1 scanline)'.  You can change it to 'none' like this:

3. Nuke ships with default image resolution set to 2K_Super_35(full-ap).  To change Nuke's default image resolution to 1920x1080, for example, add this code:
nuke.knobDefault('Root.format', 'HD')

You can see in the above 3 examples that the way to specify the control you set is generally by listing the node name followed by a period, followed by the name of the knob.  You can find the name of the knob by hovering your mouse cursor over the knob in the node's control panel.

HINT:  If you copy a Nuke node from the node graph to a text editor, you can see the name of the non-default knobs and their values.  Nuke does not store the name or the value for defaults in order to save space and time when saving scripts.  Nuke 'knows' all the defaults.  So, if you want to learn the name of a particular knob, first change it from the default on the node's control panel in the GUI, then copy and paste that node into a text editor.  You will then see the actual knob name and the non-default value as you set it. Then you can use a knobDefault command in your init.py file to automatically make your new default every time.

Was this article helpful?
0 out of 0 found this helpful