knobChanged is a callback for changes made by user interaction events, while an expression is considered knob animation, and is thus evaluated a *lot* (which you almost certainly don’t want). The problem with trying to do it within an expression is you can’t time it correctly; the expression has to return the new value to set on the knob, but your knobChanged callback is reliant on this new value, so you can’t simply run your callback code "as-is" before returning this new value unless you pass it in as well.
You could implement a somewhat hacky solution using a complex Python or TCL knob expression that would store the value of the knob on *another* (hidden) knob every time for comparison. Basically: 1) Get the value of the knob pointed to by the expression. 2) See if the new value is different than the one you’ve stored. 3) If it is, trigger your Python callable, passing in the new value. 4) Store the new value on your other knob for later comparison. 5) Return the new value to set on the knob. However, this really raises the question of why you need to link a knob that’s triggering custom callback code using expressions. In general, if you find yourself in this kind of a situation, the best solution will almost always involve at least partially rethinking and/or redesigning your approach. -Nathan From: Alex Harding Sent: Monday, September 09, 2013 10:45 AM To: nuke-python@support.thefoundry.co.uk Subject: [Nuke-python] Callbacks driven by expression doesn't update Hi, I have a script running on knobchanged that dynamically creates nodes based on an integer value, which works fine. However, if I then drive that integer via live tcl expressions, the knobchanged callback doesn't run. It has to be manually modified by the user. Is there a way to force it to run with expressions instead? Cheers AH MPC NYC Alex Harding | 2D Lead 434 Broadway, 9th Floor, New York City, 10013 T 212.915.3110 www.moving-picture.com -------------------------------------------------------------------------------- _______________________________________________ Nuke-python mailing list Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________ Nuke-python mailing list Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python