Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Run with a node like this selected:
- '''
- NoOp {
- name NodeColor
- addUserKnob {20 NodeColor}
- addUserKnob {4 node_color t "Set Node Color" M {red green blue yellow}}
- }
- '''
- n = nuke.selectedNode()
- n['knobChanged'].setValue('''
- # nuke.thisNode() returns the node that this code is running in
- n = nuke.thisNode()
- # nuke.thisKnob() returns the value of the current knob being changed when run as a callback
- k = nuke.thisKnob()
- # Only trigger the callback if the changed knob name is 'node_color'
- if k.name() == 'node_color':
- # Figure out which color the menu was set to
- menu_val = k.value()
- if menu_val == 'red':
- color = (1,0,0)
- elif menu_val == 'green':
- color = (0,1,0)
- elif menu_val == 'blue':
- color = (0,0,1)
- elif menu_val == 'yellow':
- color = (0.5,0.5,0)
- # Format the color into the proper hex code that the tile_color knob accepts.
- hex_color = int('%02x%02x%02x%02x' % (color[0]*255, color[1]*255, color[2]*255, 1), 16)
- n['tile_color'].setValue(hex_color)''')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement