Had a long/elaborate description of the problem, but this chunk of code
explains it better:
import time
def calc_path(node = None):
if node is None:
node = nuke.thisNode()
knob = nuke.thisKnob()
if knob is None or knob.name() == 'file':
# knob is none when called manually,
# and ignore all knobs but 'file' to avoid noise
print "Setting file"
node['file'].setValue("test_%s" % time.time())
# Remove existing callbacks, add new callback after making node
# Makes it easier to test changes to the callbacks
nuke.callbacks.knobChangeds['Write'] = []
w = nuke.nodes.Write()
nuke.callbacks.knobChangeds['Write'] = [(calc_path, (), {})]
# Run callback manually
calc_path(node = w)
The problem is, when the callback function is run manually, any setValue
call triggers the actual callback to run (which runs the function again)
Not a big problem (the callback is only triggered once more) but real
function takes a bit of time to execute (maybe about 0.5 seconds), and
setValue might be called several times, and there may be several Write
nodes - it all adds up to an annoying delay (can be 5-10 seconds)
So, is there a clean way to either:
...pretend a function call is a callback? I.e prevent the setValue calls
triggering the callbacks? I could possibly clear the knobChangeds and
restore it after, but that seems.. slightly inelegant
...or, trigger a callback for a specific node? I can't easily change a
knob, since the callback ignores most knob's, and the value has to
actually change for the callback to trigger.
--
ben dickson
2D TD | [email protected]
rising sun pictures | www.rsp.com.au
_______________________________________________
Nuke-python mailing list
[email protected]
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python