LIST OF KNOBS IN NUKE PT.2.
In the first part I showed how can you create user knobs manually.
In the second part let's focus on how to create them with Python but first a detour
on why I wanted to make this collection.
My goal here was to create a page that helps python users to easily find the best type of user knobs when making a gizmo or a template and the manually available user knobs are just not enough.
Currently, for this purpose you can search the NDK doc which contains elements you can't create with Python so when you find one you like you need to check the API if it's available then search forums if you ran into some issues. So it can easily take up more time than anticipated.
For this reason my page contains a lot of links to these pages as I merely
wanted to create a purposefully organized page to support the current documentations.
I will also only list specific functions along the Classes (which knob's are in Py) that are created for a certain knob or can be especially useful when dealing with the mentioned user knob. For a full list of them I encourege to have a look at the documentation that I linked to each knob's name.
But let's start in the beginning - ID numbers.
What are the ID numbers of the knobs and how to find it?
This is already a bit of a confusing matter so let's dive in from an easy access point:
If you add user knobs to a node and copy&paste it to a text editor you'll see a nuke syntax which is a same as in the .nk files and so how you store
your scripts!
So each manually added user knob adds a line that starts with addUserKnob followed by a curly bracket that can include first the ID number ( 7 ) than the name ( slider ) and the label ( Slider ) of the knob.
So each knob has it's unique
ID number!
Cool!
Got it!
Unfortunately, the story is not that simple!
Yes, the ID numbers are mostly correct but,
for some reasons we have cases on the list where:
1. The ID based on the documentation doesn't match with the actual ID in the syntax.
2. The ID is 0 which is the Obsolete knob therefore dissappears when the node is copied.
3. Knob has a different knob's ID.
4. Knob doesn't appear in recent API or NDK doc so the name to identify
was only possible by the use of a list provided for the KnobType. ( The API is for v14 as
v14`s KnobType just doesn't show the ID numbers, but we can still find them if you run
help(nuke.KnobType) in your script editor. )
I assume for this reason The Foundry is not using the ID numbers to sort the
available knobs anymore as it did only in the v6.3's documentation.
Also this doc goes up to 74, the current number is 89.
( Since the 'Knobs by ID' part is simply empty )
So there are 2 main issues I bumped into regarding certain knobs
Luckily, I'm not the first one who encountered these issues so will rather
reference solutions here:
Issue #1 - Changes / Disappears when copied
Mark Joey Tang or MJT Lab had already made a workaround for the disappearing knob issue which is brilliant and essentially using a callback onCreate() to create a
new knob every time it's opened. But let him explain better!
List of the knobs that are dissappearing:
Help_Knob, LookUpCurves_Knob, Range_Knob (ID 78 - partially dissappear), Histogram_Knob, Keyer_Knob ( partially dissappear ), ViewView_Knob, IArray_Knob, Font_Knob
Issue #2 - panelDropped
This is an issue that only effects RGB_Knob and RGBA_Knob.
It is essentially adding an extra knob - panelDropped - to your list when
the node gets copied. The issue can be particularly annoying when you end up with muliple lines of panelDropped in your .nk file wich is also increasing the size of the script.
Luckily there is a forum thread of the issue and a solution too!
Apparently, also a bug report that has been closed . . .
The solution is by Gene Hammond Lewis in a form of a snippet that can be run
on the scripts everytime onScriptClose:
How to check the knob's specs?
Erwan Leroy did a great job on how to check certain things about nodes and knobs in
his python tutorial which is a good starting point for anyone new to this!
To specifically ask for the Class and the name and ID number here is a useful snippet:
The Chart
( 'Total ???' reffers to those knobs that doesn't appear in the API nor the NDK doc )
Finally, the LIST
It is a mechanism for changing the name and action of knobs. Generally used when dealing with NDK development like versioning.
Using on its own not recommended.
#1 String_Knob OR EvalString_Knob
( manually: Text Input Knob or string )
A knob which holds a string value. Appears as a text entry field in a Node panel.
( manually: Filename or filename )
Presents a string plus a button which launches the NUKE file browser.
( manually: Pulldown Choice or pulldown )
Presents a single selection dropdown menu.
Note:
- ID that appears in a syntax is 4 ( Enumeration_Knob ) instead of 5
- After copying the knob turns into an Enumeration_Knob
( manually: Check box or boolean )
A single checkbox with a label to the right, and no new line by default.
( manually: 2d Position Knob or position_2d )
Two numerical input boxes with hardcoded ‘x’ and ‘y’ labels, plus a draggable Viewer handle.
( manually: 3d Position Knob or position_3d )
Three numerical input boxes with hardcoded ‘x’, ‘y’, and ‘z’ labels, plus
a draggable 3D Viewer handle.
( manually: Width/Heigh Knob or size_wh )
A single numerical input box with a slider and a button to switch to two numerical input boxes with hardcoded ‘w’ and ‘h’ labels. When stored, the horizontal value is divided by the incoming format’s pixel aspect ratio, so that if the user sees equal values, the result in the Viewer is square.
( manually: Bounding Box Knob or bbox )
Four numerical input boxes with a button to switch mode between x, y, r and t (bottom left x and y plus top right r and t) and x, y, w and h (bottom left x and y plus the box’s width and height) with hardcoded labels. It also draws a box widget into the Viewer with eight handles, allowing corner and edge dragging.
#16 Size_Knob
( manually: Size Knob or size )
Note: It's not appearing in the API or the NDK doc but you can create manually.
On the created knob the ID is 16 but the Class identified as Array_Knob.
Presents a single select dropdown of all formats currently available in the script.
( manually: RGB Color Knob or color_rgb )
Stores color values at either double or float precision. Initially shows a single entry box and slider, a button to split to 3 entry boxes, a button to pop up the NUKE color wheel, and a swatch showing the current color plus an eyedropper for sampling. The color swatch is looked up through the root monitor LUT to present an interface representation in a
familiar color space.
Note: Look above for Issue #2 - panelDropped
( manually: RGBA Color Knob or color_rgba )
As with Color_knob, but stores and allows editing of a fourth value, representing alpha.
Alpha is not represented in the swatch.
Note: Look above for Issue #2 - panelDropped
( manually: Tab or tab )
Starts a new Tab in the parameter panel and resets BeginGroup hierarchy to zero. By default, without an initial Tab declaration, the first tab on a node inherits its name from the node itself. Declaring a name up front, before any other knobs, simply renames the first tab -
it does not create a new tab.
Note: If you want to create a Group that you would create manually
you will need a Tab_Knob and a 3rd argument that turns this
type of knob into a Group.
( manually: Group or group )
( manually: Python Script Button or python_button )
Presents a push button which does not start a new line by default. It has no data storage, but executes a passed string of Python inside NUKE’s Python scripting environment using this knob as ‘context’ so that relative names work.
#23 - Was Text_Editor_Knob - Not in use
Describes an affine transform. Presents a number of lines of multiple instances of Float_knob, as well as a 2D transform jack in the Viewer. Requires Matrix4 object.
( manually: Text or text and Divider Line )
Presents as user defined text on the Properties panel, but does not start a new line by default. Note that this can be used between knobs by clearing the start line flag on
the subsequent knob. By not providing label or text appears as Divider Line.
Presents a button with a ? label, used to pop up a help line.
Note: ID is 0 (Obsolete) - dissappears when copied ( Hide turns on )
Issue #1 - Changes / Disappears when copied
Describes a 3D, 6 degrees of freedom transformation. Presents a number of lines of multiple instances of Float_knob, as well as a 3D transform jack in the Viewer. Requires Matrix4 object.
( manually: UV Coordinate Knob or uv )
Presents two numeric input boxes, with hardcoded ‘u’ and ‘v’ sub-labels, plus an
animation menu button.
( manually: TCL Script Button or tcl_button )
It has no data storage, but executes a passed string of TCL inside NUKE’s TCL scripting environment using this knob as ‘context’ so that relative names work.
Presents a curve interface with an arbitrary number of curves included.
Note: ID is 0 (Obsolete) - dissappears when copied ( Hide turns on )
Issue #1 - Changes / Disappears when copied
#34 - Was Tooltip_Knob - Not in use
( manually: Command Menu or menu )
Presents a dropdown menu where selecting an item executes TCL OR Python commands.
Presents a color swatch button that activates an eye dropper color sampling interface.
Note: ID is 0 (Obsolete) - dissappears when copied ( Hide turns on )
Issue #1 - Changes / Disappears when copied
A knob which the minimum and maximum for a range of values.
Note: ID is 78 (IArray) - slider dissappears when copied
Issue #1 - Changes / Disappears when copied
Presents a read only histogram graph interface with two sets of data .
Note: ID is 0 (Obsolete) - dissappears when copied ( Hide turns on )
Issue #1 - Changes / Disappears when copied
Presents a trapezoid graph shape with corners defined by the data values. Used in the Keyer node and generally not recommended elsewhere.
Note: ID is 78 (IArray) - graph dissappears when copied
Issue #1 - Changes / Disappears when copied
A knob which holds a single unsigned int that describes a user interface colour. The color format is 0xRRGGBB00.
Soft links to another node, identified by the name passed on construction.
Creates an expression line between the 2 nodes.
( Using a Blur node's size knob in the example )
Presents a single numerical entry box with a slider, plus a button to flip the interface to two numerical interface boxes.
Note: ID is 78 (IArray) but nothing disappears when copied
Presents a single selection dropdown list of the current views present in the script.
Note: Note: ID is 4 (Enumeration) but nothing disappears when copied
Presents a multi-selection dropdown list of the current views present in the script.
Presents a ‘patch bay’ type interface allowing the user to specify a relationship
between pairs of views.
Note: ID is 0 (Obsolete) - dissappears when copied ( Hide turns on )
Issue #1 - Changes / Disappears when copied
#48 GPUEngine_knob ?
#49 MultiArray_knob ?
A string-valued knob which evaluates its value as a Python expression.
Note: ID is 1 (String) - but nothing disappears when copied
Interestingly, there is a knob that has ID 52 and can be created with two different commands:
Both of these commands create a same type of knob.
These knobs doesn't do much on there own but allows you to use modules like QTWidget to add different type of knobs that are available in Nuke
without needing to use C++.
If you are interested in some of the best experiment on how far you can push Nuke using PyCustom I recommend the
fascinating two part tutorial of Erwan Leroy.
#55 CP_knob ?
#57 BeginTabGroup_Knob / EndTabGroup_Knob
Begin a group of tabs. Subsequent knobs will all be part of the same tab group, until a matching EndTabGroup knob is found.
Note: ID is 20 (Tab) - but nothing disappears when copied
#58 PluginPython_Knob ?
A knob which holds a password string value. Appears as a password entry field in a Node panel.
#62 Toolbox_knob ?
Presents a button interface on the Viewer, and a series of selection based handles on 3D geometry. Creation of Geoselect_knobs is not recommended, however GeoOp’s inherit one automatically (assuming you chain the knob’s call back to the GeoOp parent). This can be accessed using the name “geo_select” and addressed using the interface defined in GeoSelectKnobI.h.
#67 ControlPointCollection_knob ?
( manually: Cascading Pulldown Choice or cascading_pulldown )
Stores a single value between 0 and some maximum, and manages a set of keywords visible to the user. The words themselves are displayed on a pulldown list in the user interface, and are written to the saved scripts (so that the numerical values can change). To create cascading submenus simply use the forward slash ( '/' ) e.g. menu/item1
#73 TransformJack_knob ?
Displays a list of items as a hierarchy. The hierarchy is specified using back or forward slashes within the item names to specify their level in the tree. Handles multiple selection
of items within the tree.
Note: Items disappear when copied.
#76 VSpacer_Knob ?
#77 CancelExecution_Knob ?
Subclass of Array_Knob. Allows to set dimensions.
Note: Seems broken thank to a dropData function.
When copied turns into 1 dimension knob and gets animated values on frame 1.
From the script Editor when copied:
nuke.nodeCopy(nukescripts.cut_paste_file())
nuke.nodePaste(nukescripts.cut_paste_file())
nukescripts.dropData('text/plain', '''set cut_paste_input \[stack 0]\nversion 12.2 v1\npush \$cut_paste_input\nNoOp {\n name NoOp1\n selected true\n xpos 97\n ypos -10\n addUserKnob {20 User}\n addUserKnob {78 Array l 78_Array n 3}\n Array {\n {1 -3.795368826e-270 11}\n {-6.042383589e-311 1 -6.585614414e-311}\n {2.100775838e-312 -3.797784176e-270 1}\n }\n}\n''')
#79 ResizableArray_Knob ?
A knob which holds a boolean value representing the disabled state of a node. This appears in a Node panel as a check box.
#81 Icon_Knob ?
#82 FrameExtent_Knob ?
Stores a single value between 0 and some maximum, and manages a set of Radio Buttons visible to the user. This is essentially an Enumeration_Knob with a different widget.
Note: Technically this is a slightly different font selecting knob than the FreeType_Knob only that its ID is 0 (Obsolete) and dissappears when copied and it doesn't appear on the list of knobTypes nor in the NDK documentation.
Therefore recommended to use FreeType_Knob instead.
This is essentially an Enumeration_Knob with editable options, therefore can be manually expand the list of options.
Note: For some reasons its description in the API is about the Radio_Knob and it doesn't appear on the NDK documentaton.
#86 Colorspace_Knob ?
Note: The only mentioning of this knob in the documentations I found was the argument that
the getColorspaceList requires ( source code ), although this has little to do
with what we are after here, probably.
The familar knob from ReadGeo. Displays a list of items as a hierarchy. The hierarchy is specified using back or forward slashes within the item names to specify their level in the tree. Handles multiple selection of items within the tree.
Hope you will find it useful!