def doExposeTransforms(): """Adds user properties to objects with am_exposeTransform nodes.""" # a list of attributes to extract attributeList = [u'reference', u'rotateOrder', u'objectAxis', u'referenceAxis'] try: nodes = cmds.ls(type='am_exposeTransform') for node in nodes: util.addAttributeValues(cmds.am_exposeTransform(node, q=True, object=True), node, attributeList) except: pass
def doHipConstraints(): """Adds user properties to objects with am_hipConstraint nodes.""" # a list of attributes to extract attributeList = [u'hip', u'hipAimAxis', u'hipFrontAxis', u'pelvis', u'pelvisAimAxis', u'pelvisFrontAxis'] try: nodes = cmds.ls(type='am_hipConstraint') for node in nodes: # a constrained object is one attached to the rotate plug constrainedObjects = cmds.listConnections('%s.rotate'%node, source=False, scn=True) for obj in constrainedObjects: util.addAttributeValues(obj, node, attributeList) except: pass
def doShoulderConstraints(): """Adds user properties to objects with am_shoulderConstraint nodes.""" # a list of attributes to extract attributeList = [u'raisedAngleOffset', u'shoulder', u'shoulderAimAxis', u'shoulderFrontAxis', u'spine', u'spineAimAxis', u'spineFrontAxis'] try: nodes = cmds.ls(type='am_shoulderConstraint') for node in nodes: # a constrained object is one attached to the rotate plug constrainedObjects = cmds.listConnections('%s.rotate'%node, source=False, scn=True) for obj in constrainedObjects: util.addAttributeValues(obj, node, attributeList) except: pass
def doExposeTransforms(): """Adds user properties to objects with am_exposeTransform nodes.""" # a list of attributes to extract attributeList = [ u'reference', u'rotateOrder', u'objectAxis', u'referenceAxis' ] try: nodes = cmds.ls(type='am_exposeTransform') for node in nodes: util.addAttributeValues( cmds.am_exposeTransform(node, q=True, object=True), node, attributeList) except: pass
def doConstraints(constraintType): """Adds user properties to objects controlled by constraints.""" # determine the outgoing plug name and attribute lists based on the constraint type outPlug = '' attributeList = [] if (constraintType == 'aimConstraint'): outPlug = 'constraintRotate' attributeList = ['offset', 'aimVector', 'upVector', 'worldUpVector', 'worldUpMatrix', 'worldUpType'] elif (constraintType == 'orientConstraint'): outPlug = 'constraintRotate' attributeList = ['offset', 'interpType'] elif (constraintType == 'pointConstraint'): outPlug = 'constraintTranslate' attributeList = ['offset', 'constraintOffsetPolarity'] # set up each constraint constraints = cmds.ls(type=constraintType) for constraint in constraints: # first resolve naming conflicts in case any exist constraint = cmds.rename(constraint, constraint) # NOTE: Unity implementation does not allow per-child-plug behavior, so just check first child plug constrainedObjects = cmds.listConnections('%s.%sX'%(constraint, outPlug), source=False) if not constrainedObjects: continue for obj in constrainedObjects: if constraintType == 'pointConstraint': util.addAttributeValues(obj, constraint, attributeList) else: util.addAttributeValues(obj, constraint, attributeList, eulerAttributes=['offset']) util.addAttributeValues(obj, constraint, mel.eval('%s -q -wal %s'%(constraintType, constraint))) try: targets = ['target[%s].targetParentMatrix'%re.search('\d+$', t).group(0) for t in mel.eval('%s -q -wal %s'%(constraintType, constraint))] util.addAttributeValues(obj, constraint, targets) except: pass
def doHipConstraints(): """Adds user properties to objects with am_hipConstraint nodes.""" # a list of attributes to extract attributeList = [ u'hip', u'hipAimAxis', u'hipFrontAxis', u'pelvis', u'pelvisAimAxis', u'pelvisFrontAxis' ] try: nodes = cmds.ls(type='am_hipConstraint') for node in nodes: # a constrained object is one attached to the rotate plug constrainedObjects = cmds.listConnections('%s.rotate' % node, source=False, scn=True) for obj in constrainedObjects: util.addAttributeValues(obj, node, attributeList) except: pass
def doShoulderConstraints(): """Adds user properties to objects with am_shoulderConstraint nodes.""" # a list of attributes to extract attributeList = [ u'raisedAngleOffset', u'shoulder', u'shoulderAimAxis', u'shoulderFrontAxis', u'spine', u'spineAimAxis', u'spineFrontAxis' ] try: nodes = cmds.ls(type='am_shoulderConstraint') for node in nodes: # a constrained object is one attached to the rotate plug constrainedObjects = cmds.listConnections('%s.rotate' % node, source=False, scn=True) for obj in constrainedObjects: util.addAttributeValues(obj, node, attributeList) except: pass