Last active
February 17, 2021 14:52
-
-
Save draconiansolo/6744801 to your computer and use it in GitHub Desktop.
Self-contained nuke knobChanged callbacks...To be able to add a callback when knobs change on a group or gizmo without having to create init callback scripts on the menu.py and stuff.So it is waaay better to do it like this for copypastas :D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#based on http://forums.thefoundry.co.uk/phpBB2/viewtopic.php?t=3602&sid=7c140135632c783e7147e0e1b577eaa6 | |
#which is most interesting... | |
#code=""" | |
print 'knobChanged fired...' | |
n=nuke.thisNode() | |
k=nuke.thisKnob() | |
if k.name()=='number': | |
print 'yyyay!!!!!' | |
#""" | |
#node['knobChanged'].setValue(code) | |
#node['help'].setValue( "Help me, I'm in hell!!!!" ) | |
#####################################alternatively#################################: | |
nuke.selectedNode()['knobChanged'].setValue(""" | |
###your code here | |
n = nuke.thisNode() | |
k = nuke.thisKnob() | |
if k.name() == "p_a": | |
n['p_b'].setValue(k.value()) | |
elif k.name() == "p_b": | |
n['p_a'].setValue(k.value()) | |
""") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi, this might be a stupid question, but where does the code below "##alternatively###" line go.
Does the code in a PyScript knob on the node? in the menu.py file? Having a hard time getting the code to run in the appropriate place.