Reputation: 8277
My question is Foundary Nuke specific.
I have a tab added to Project Settings, that contains some data I can later access via the root node. Now since I have callback invoked by a checkbox knob I added to enable disable a custom knob I added to that tab I added to Project Settings Panel. It works fine. The problem is when I close nuke I get error:
Traceback (most recent call last):
File "/system/runtime/plugins/nuke/callbacks.py", line 127, in knobChanged
_doCallbacks(knobChangeds)
File "/system/runtime/plugins/nuke/callbacks.py", line 44, in _doCallbacks
for f in list:
ValueError: A PythonObject is not attached to a node
Now this error happens if I have a callback function added to the checkbox knob like this:
my_callbacks.py
import nuke
def on_checkbox_clicked():
try:
root_node = nuke.root()
if not root_node:
return
except ValueError as er:
print(er)
nuke.addKnobChanged(on_checkbox_clicked, nodeClass='Root', node=nuke.root())
nuke.addonScriptClose(lambda: nuke.removeKnobChanged(on_checkbox_clicked, nodeClass-'Root', node=nuke.root())
but if I create a grade node named Grade1 and run the below code in script editor it works fine.
try:
node = nuke.toNode('Grade1')
nuke.delete(node)
node.fullname() # <-- should throw error
except ValueError:
print(error caught.)
Upvotes: 1
Views: 1033
Reputation: 11
Have you tried using nuke.thisNode()
in your callback?
and reduce to nuke.addKnobChanged(on_checkbox_clicked, nodeClass='Root')
Like you I'm confused by this error, sometimes it appears but it shouldn't and when it should appear it doesn't...
Upvotes: 0
Reputation: 373
Certainly seems like an internal nuke issue. Which nuke are you running? I know 11 and 12 will almost always spit out some kind of python error on close - either threading or something like this.
If your my_callbacks.py is being loaded by init/menu, try just adding the callback to the root node itself (rather than the global knob change process) with node.knob('knob_changed').setValue(YOUR CODE in string format)
In this case of course, the knob changed code will only fire on the Root node, and you'll have to run that setValue
code in each script you want. You might be able to use init/menu and another callback (onScriptLoad
) to accomplish that.
Upvotes: 0