def _setAttribute(attribute,v,t): attrTypes = ["numeric","bool","long","short","byte","char","enum","float","double","doubleAngle","doubleLinear","compound","message","time","matrix","fltMatrix","reflectanceRGB","reflectance","spectrumRGB","spectrum","float2","float3","double2","double3","long2","long3","short2","short3","doubleArray","floatArray","Int32Array","vectorArray","nurveCurve","mesh","lattice","pointArray"] try: general.setAttr(attribute,v) except: print "complex attribute... trying with type" if v!=None and t!=None: try: general.setAttr(attribute,v,type=t) except: print "could not set! :(" else: print "type unknown, guessing:" for a in attrTypes: try: general.setAttr(attribute,v,type=a) print "success!" break; except Exception, e: pass
def setAttr(self, *args, **kwargs): from pymel.core.general import setAttr return setAttr(self, *args, **kwargs)
def _sign_the_scene(author): if not objExists('defaultLayer.Author'): addAttr('defaultLayer', longName='Author', dataType='string') setAttr('defaultLayer.Author', author, type='string', lock=True)
def mapVal(cls, mapNodeName, inputAttr, inputRange, outputRange, mappingKeys, interpType = 1): mapNode = gen.shadingNode('remapValue', asUtility = True, name = mapNodeName + '_UTL') # the shoulder rotate is inversing from the arm? #TODO: i might want to unify the rotation of shoulder and arm later gen.setAttr(mapNode.inputMin, inputRange[0]) gen.setAttr(mapNode.outputMin, outputRange[0]) gen.setAttr(mapNode.inputMax, inputRange[1]) gen.setAttr(mapNode.outputMax, outputRange[1]) for i in range(0, len(mappingKeys)): keyPos = mappingKeys[i][0] keyVal = mappingKeys[i][1] gen.setAttr(mapNode.value[i].value_Position, keyPos) gen.setAttr(mapNode.value[i].value_FloatValue, keyVal) gen.setAttr(mapNode.value[i].value_Interp, interpType) inputAttr.connect(mapNode.inputValue) return mapNode