Problem summary
When using the nuke.knobDefault function to add custom knobs within the Preferences menu, when creating the custom knob to an active function, it will not be set to active on creation.
Customer reported version
nuke.10.0v6
Customer reported platform
centos7
Steps to reproduce
1) Open a new Nuke session
2) Paste the following code into the Script Editor (to create a custom knob in the Preferences node)
prefsNode = nuke.toNode('preferences')nuke.knobDefault('myKnob', 'True')myKnob = nuke.Boolean_Knob('myKnob', 'my custom knob')prefsNode.addKnob(myKnob)print prefsNode
Result: myKnob will be set to false and not true
Workaround
As an alternative, you can use the setDefaultValue() function, which does not have this issue.
Based on the above code, below is the revised version using the setDefaultValue() function.
prefsNode = nuke.toNode('preferences')nuke.knobDefault('Preferences.myKnob', 'True')myKnob = nuke.Boolean_Knob('myKnob', 'my custom knob')myKnob.setDefaultValue([True])prefsNode.addKnob(myKnob)print prefsNode
Following the same principle with the default preferences knobs, adding the following snippet to your
.nuke/init.py file will set
ShowMenusUnderCursor to '
False' after each launch:
Add snippet to your init.py file within your /.nuke directory:
prefsNode = nuke.toNode('preferences')nuke.knobDefault('Preferences.ShowMenusUnderCursor', 'False')prefsNode.knob('ShowMenusUnderCursor').setDefaultValue([False])
Reproduced by support
This bug has been reproduced in:
Nuke 11.2v3 - Windows 7 - CentOS 6.9 - MacOS 10.13.6
Nuke 11.2v1 - Windows 7
Nuke 11.1v6 - Windows 7
Nuke 11.1v1 - Windows 7
Nuke 11.0v4 - Windows 7
Nuke 11.0v1 - Windows 7
Nuke 10.5v7 - Windows 7
Nuke 10.5v1 - Windows 7
Nuke 10.0v6 - Windows 7
Nuke 10.0v1 - Windows 7
Nuke 9.0v9 - Windows 7
Nuke 9.0v1 - Windows 7
Nuke 8.0v7 - Windows 7
Nuke 8.0v1 - Windows 7
Nuke 7.0v10 - Windows 7 - CentOS 6.9 - MacOS 10.13.6
Earliest version tested
Nuke 7.0v10
- This issue appears to be in all versions of the product
Expected behaviour
When adding a custom knob to the preferences menu using the nuke.knobDefault, this knob should remain in the same state as created.
Actual behaviour
When adding a custom knob to the preferences menu using the nuke.knobDefault, this created knob will not be in the same state as created