Q100460: Setting knob defaults for file specific formats in Nuke

Follow

SUMMARY

This article explains how to set knob defaults for file format specific knobs, otherwise known as context sensitive or dynamically updating knobs.

MORE INFORMATION

File format specific knobs are knobs which only appear on nodes after a file format has been set for that node. For example, on the Read and Write nodes, the exr knobs only appear after the file type has been defined.

i.e. EXR Options

Normally, knob defaults can be set by using the following Python command:

nuke.knobDefault(“nodeClass.knobName”, “value”).

However, as these file format specific knobs depend on the file format chosen, accessing them only via their knob name does not work.

In order to set the knob defaults for file specific knobs, such as those under the EXR Options on an exr Read node, the file format needs to be defined when calling the knobDefault() function, separating the format from the node class and knob name with full stops. So the command would look like:

nuke.knobDefault(“nodeClass.fileFormat.knobName”, “value”)

Below are a couple of usage examples for the above command:

nuke.knobDefault("Read.mov.mov64_first_track_only", "False")
nuke.knobDefault("Read.exr.edge_pixels","2")

nuke.knobDefault("Write.exr.compression", "DWAB")
nuke.knobDefault("Write.exr.dw_compression_level", "10")

The knobDefault() functions can be run in the Script Editor, to apply for any future nodes created in that Nuke session, or they can be added to the init.py or menu.py in the users .nuke directory to apply to future Nuke sessions.

FURTHER READING 

More information about the knobDefault() command can be found in our Python reference guide: 

knobDefault(classknob, value)

Information about finding the .nuke directory can be found here:

Q100048: Nuke Directory Locations

 

    We're sorry to hear that

    Please tell us why