def _matchNodesToPoseData(self, nodes): ''' Main filter to extract matching data pairs prior to processing return : tuple such that : (poseDict[key], destinationNode) NOTE: I've changed this so that matchMethod is now an internal PoseData attr :param nodes: nodes to try and match from the poseDict ''' matchedPairs = [] log.info('using matchMethod : %s' % self.matchMethod) if self.matchMethod == 'stripPrefix' or self.matchMethod == 'base': log.info('matchMethodStandard : %s' % self.matchMethod) matchedPairs = r9Core.matchNodeLists( [key for key in self.poseDict.keys()], nodes, matchMethod=self.matchMethod) if self.matchMethod == 'index': for i, node in enumerate(nodes): for key in self.poseDict.keys(): if int(self.poseDict[key]['ID']) == i: matchedPairs.append((key, node)) log.info('poseKey : %s %s >> matchedSource : %s %i' % (key, self.poseDict[key]['ID'], node, i)) break if self.matchMethod == 'mirrorIndex': getMirrorID = r9Anim.MirrorHierarchy().getMirrorCompiledID for node in nodes: mirrorID = getMirrorID(node) if not mirrorID: continue for key in self.poseDict.keys(): if self.poseDict[key]['mirrorID'] and self.poseDict[key][ 'mirrorID'] == mirrorID: matchedPairs.append((key, node)) log.info( 'poseKey : %s %s >> matched MirrorIndex : %s' % (key, node, self.poseDict[key]['mirrorID'])) break if self.matchMethod == 'metaData': getMetaDict = self.metaRig.getNodeConnectionMetaDataMap # optimisation poseKeys = dict(self.poseDict) # optimisation for node in nodes: try: metaDict = getMetaDict(node) for key in poseKeys: if poseKeys[key]['metaData'] == metaDict: matchedPairs.append((key, node)) poseKeys.pop(key) break except: log.info( 'FAILURE to load MetaData pose blocks - Reverting to Name' ) matchedPairs = r9Core.matchNodeLists( [key for key in self.poseDict.keys()], nodes) return matchedPairs
def _buildPoseDict(self, nodes): ''' Build the internal poseDict up from the given nodes. This is the core of the Pose System ''' getMirrorID = r9Anim.MirrorHierarchy().getMirrorCompiledID if self.metaPose: getMetaDict = self.metaRig.getNodeConnectionMetaDataMap # optimisation for i, node in enumerate(nodes): key = r9Core.nodeNameStrip(node) self.poseDict[key] = {} self.poseDict[key]['ID'] = i # selection order index self.poseDict[key]['longName'] = node # longNode name mirrorID = getMirrorID(node) if mirrorID: self.poseDict[key]['mirrorID'] = mirrorID if self.metaPose: self.poseDict[key]['metaData'] = getMetaDict( node) # metaSystem the node is wired too channels = r9Anim.getSettableChannels(node, incStatics=True) if channels: self.poseDict[key]['attrs'] = {} for attr in channels: if attr in self.skipAttrs: log.debug('Skipping attr as requested : %s' % attr) continue try: if cmds.getAttr( '%s.%s' % (node, attr), type=True ) == 'TdataCompound': # blendShape weights support attrs = cmds.aliasAttr( node, q=True )[:: 2] # extract the target channels from the multi for attr in attrs: self.poseDict[key]['attrs'][ attr] = cmds.getAttr('%s.%s' % (node, attr)) else: self.poseDict[key]['attrs'][attr] = cmds.getAttr( '%s.%s' % (node, attr)) except: log.debug('%s : attr is invalid in this instance' % attr)