Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def getKnobType(knob):
- ''' Return a string that identifies the type of knob.
- Useful to distinguish between different types
- of Array and Enumeration knobs that are
- serialized with a different knob ID in tcl.
- '''
- import re
- # Use knob.Class() and return early if Class() is not Array_Knob or Enumeration_Knob
- if knob.Class() not in ['Array_Knob', 'Enumeration_Knob']:
- return knob.Class()
- knobName = knob.fullyQualifiedName()
- knobID = nuke.knob(knobName, type = True)
- # Get dict of knobtypes
- knobIDs = dict([(v,k) for (k,v) in nuke.KnobType.__dict__.items()])
- # Also use knob.Class() if ID is not found in KnobTypes
- if not (knobID in knobIDs):
- return knob.Class()
- #return type as defined in KnobTypes, with some reformatting
- return re.sub( '(?<!^)(?=[A-Z])', '_', knobIDs[knobID].lstrip('e'))
Advertisement
Add Comment
Please, Sign In to add comment