<s> """<STR_LIT>""" <EOL> import maya . cmds as cmds <EOL> import maya . mel as mel <EOL> import maya . OpenMaya as OM <EOL> import math , re <EOL> kUserPropertyDelimeter = "<STR_LIT>" <EOL> def generateUserPropertyName ( nodeName , attributeName ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT>' % ( cmds . nodeType ( nodeName ) , kUserPropertyDelimeter , nodeName , kUserPropertyDelimeter , re . sub ( '<STR_LIT>' , '<STR_LIT>' , re . sub ( '<STR_LIT>' , '<STR_LIT>' , re . sub ( '<STR_LIT>' , '<STR_LIT>' , attributeName ) ) ) ) <EOL> def addAttributeValues ( targetObject , sourceNode , attributeList , ** keywords ) : <EOL> """<STR_LIT>""" <EOL> existingAttributes = cmds . listAttr ( targetObject ) <EOL> for attribute in attributeList : <EOL> attrType = cmds . getAttr ( '<STR_LIT>' % ( sourceNode , attribute ) , type = True ) <EOL> userPropertyName = generateUserPropertyName ( sourceNode , attribute ) <EOL> if attrType == None : continue <EOL> userPropertyType = attrType <EOL> unsupportedTypes = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> if attrType in unsupportedTypes : userPropertyType = '<STR_LIT:string>' <EOL> if not userPropertyName in existingAttributes : <EOL> if userPropertyType == '<STR_LIT:string>' : mel . eval ( '<STR_LIT>' % ( userPropertyName , userPropertyType , targetObject ) ) <EOL> else : mel . eval ( '<STR_LIT>' % ( userPropertyName , userPropertyType , targetObject ) ) <EOL> attrValue = '<STR_LIT>' <EOL> if attrType == '<STR_LIT>' : <EOL> if not userPropertyName in existingAttributes : <EOL> cmds . addAttr ( targetObject , ln = '<STR_LIT>' % userPropertyName , p = userPropertyName , at = '<STR_LIT>' ) <EOL> cmds . addAttr ( targetObject , ln = '<STR_LIT>' % userPropertyName , p = userPropertyName , at = '<STR_LIT>' ) <EOL> cmds . addAttr ( targetObject , ln = '<STR_LIT>' % userPropertyName , p = userPropertyName , at = '<STR_LIT>' ) <EOL> attrValue = cmds . getAttr ( '<STR_LIT>' % ( sourceNode , attribute ) ) [ <NUM_LIT:0> ] <EOL> attrValue = ( - <NUM_LIT:1> * attrValue [ <NUM_LIT:0> ] , attrValue [ <NUM_LIT:1> ] , attrValue [ <NUM_LIT:2> ] ) <EOL> if ( '<STR_LIT>' in keywords and attribute in keywords [ '<STR_LIT>' ] ) : <EOL> euler = OM . MEulerRotation ( - math . radians ( attrValue [ <NUM_LIT:0> ] ) , - math . radians ( attrValue [ <NUM_LIT:1> ] ) , - math . radians ( attrValue [ <NUM_LIT:2> ] ) , cmds . getAttr ( '<STR_LIT>' % targetObject ) ) <EOL> euler . reorderIt ( OM . MEulerRotation . kZXY ) <EOL> attrValue = ( math . degrees ( euler . x ) , math . degrees ( euler . y ) , math . degrees ( euler . z ) ) <EOL> elif attrType == '<STR_LIT>' : <EOL> attrValue = cmds . listConnections ( '<STR_LIT>' % ( sourceNode , attribute ) ) <EOL> if attrValue : attrValue = attrValue [ <NUM_LIT:0> ] <EOL> else : attrValue = cmds . getAttr ( '<STR_LIT>' % ( sourceNode , attribute ) ) <EOL> if attrValue == None : cmds . deleteAttr ( '<STR_LIT>' % ( targetObject , userPropertyName ) ) <EOL> else : <EOL> if userPropertyType == '<STR_LIT:string>' : cmds . setAttr ( '<STR_LIT>' % ( targetObject , userPropertyName ) , attrValue , type = '<STR_LIT:string>' ) <EOL> elif userPropertyType == '<STR_LIT>' : cmds . setAttr ( '<STR_LIT>' % ( targetObject , userPropertyName ) , attrValue [ <NUM_LIT:0> ] , attrValue [ <NUM_LIT:1> ] , attrValue [ <NUM_LIT:2> ] ) <EOL> else : cmds . setAttr ( '<STR_LIT>' % ( targetObject , userPropertyName ) , attrValue ) </s>
