Skip to content

Instantly share code, notes, and snippets.

@greenvfx
Created March 31, 2017 15:37
Show Gist options
  • Save greenvfx/332ec4f3a31c1010a1c61c0810b08746 to your computer and use it in GitHub Desktop.
Save greenvfx/332ec4f3a31c1010a1c61c0810b08746 to your computer and use it in GitHub Desktop.
getDefaultColor
node = nuke.selectedNode()
prefs = nuke.toNode('preferences')
allPrefKnobs = prefs.allKnobs()
colourClasses = [knob.name() for knob in allPrefKnobs if "NodeColourClass" in knob.name() ]
foundClass = ''
ruleFound = ''
for colorClass in colourClasses:
rules = prefs[colorClass].value().split()
print rules
for rule in rules:
if rule in node.Class().lower():
ruleFound = rule
foundClass = colorClass
print node.name()
print "Class " + foundClass
print ruleFound
if foundClass != "":
postfix = foundClass.replace("NodeColourClass", "")
colorValueKnob = "NodeColour%sColor" % postfix
#print colorValueKnob
print "Color: " + str(prefs[colorValueKnob].value())
else:
print "Default color: " + str(prefs['NodeColor'].value())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment