Hey there - 

I'm trying to do something simple, but I'm getting a difference in results when 
using a python button vs a callback.

Here's a simplified example:

def loadCamera():
    n = nuke.thisNode()
    n['read_from_file'].setValue(True)
    n['file'].setValue('/path/to/fbxCamera.fbx')
    n['fbx_take_name'].setValue('Take 001')
    n['read_from_file'].setValue(False)
    nuke.tprint('------Camera Loaded--------')

def getCameraCallback():
    k = nuke.thisKnob()
    n = nuke.thisNode()
    if k and k.name() == 'getCamera':
        nuke.tprint('########  Loading Camera via callback ########')
        loadCamera()

nuke.addKnobChanged(getCameraCallback)
camera = nuke.nodes.Camera2()
kgetCamera  = nuke.PyScript_Knob('GetCamera', "Import Shot's Camera", 
"loadCamera()")
camera.addKnob(kgetCamera)
kGetWithCallback= nuke.Boolean_Knob('getCamera', 'Get Camera')
camera.addKnob(kGetWithCallback)

Using the python button in the camera node after it's created always pops up a 
dialog asking if I want to load the camera. 
Good.
When I use the callback by checking the getCamera checkbox, I don't get the 
dialog and the camera is not loaded. 
Bad.
Even without an fbx to test with, just running the above code will error the 
node with the button (since it tries to load a bad path), but while the 
checkbox sets the file knob, it doesn't load the file. I want to checkbox to 
reload the camera, as it's actually being used to grab a different camera 
within the fbx file.

Is there a way around this? 
Or is there a better way of writing the callback? Or is it a bug?

Cheers
jrab
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to