Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def setTileColour(node, red, green, blue):
- '''convert normalised rgb values to a hex value and use the result to cange node's tile_color'''
- hexColour = int('%02x%02x%02x%02x' % (red*255,green*255,blue*255,1),16)
- node["tile_color"].setValue(hexColour)
- def tileColourCB():
- '''callback script that parses a user knob's va;ue wen it's changed and calls setTileColour based on the new knob value'''
- node = nuke.thisNode()
- knob = nuke.thisKnob()
- if not knob.name() == 'myColourKnob':
- # if any knob other than the custom knob is changed, don't do anything
- return
- # store colour values for each label used in the custom knob
- colourDict = {'red':(1,0,0), 'green':(0,1,0), 'blue':(0,0,1)}
- # since the custom knob is a cascading pulldown choice knob, split the label and only take the last item as the requested colour label
- colourString = knob.value().split('/')[-1]
- # use the colour label to look up the colour values from the dictionary
- colourValues = colourDict[colourString]
- # assign the colour to the node
- setTileColour(node, *colourValues)
- nuke.addKnobChanged(tileColourCB, nodeClass='NoOp')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement