Created
March 31, 2017 15:37
-
-
Save greenvfx/332ec4f3a31c1010a1c61c0810b08746 to your computer and use it in GitHub Desktop.
getDefaultColor
This file contains 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
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