Ejemplo n.º 1
0
    def _buildSkeletonData(self, rootJnt):
        '''
        :param rootNode: root of the skeleton to process
        '''
        self.skeletonDict = {}
        if not rootJnt:
            log.info('skeleton rootJnt joint was not found')
            return

        fn = r9Core.FilterNode(rootJnt)
        fn.settings.nodeTypes = 'joint'
        fn.settings.incRoots = False
        skeleton = fn.ProcessFilter()

        for jnt in skeleton:
            key = r9Core.nodeNameStrip(jnt)
            self.skeletonDict[key] = {}
            self.skeletonDict[key]['attrs'] = {}
            for attr in [
                    'translateX', 'translateY', 'translateZ', 'rotateX',
                    'rotateY', 'rotateZ'
            ]:
                try:
                    self.skeletonDict[key]['attrs'][attr] = cmds.getAttr(
                        '%s.%s' % (jnt, attr))
                except:
                    log.debug('%s : attr is invalid in this instance' % attr)
Ejemplo n.º 2
0
 def matchInternalPoseObjects(self, nodes=None, fromFilter=True):
     '''
     This is a throw-away and only used in the UI to select for debugging!
     from a given poseFile return or select the internal stored objects
     '''
     InternalNodes = []
     if not fromFilter:
         #no filter, we just pass in the longName thats stored
         for key in self.poseDict.keys():
             if cmds.objExists(self.poseDict[key]['longName']):
                 InternalNodes.append(self.poseDict[key]['longName'])
             elif cmds.objExists(key):
                 InternalNodes.append(key)
             elif cmds.objExists(r9Core.nodeNameStrip(key)):
                 InternalNodes.append(r9Core.nodeNameStrip(key))
     else:
         #use the internal Poses filter and then Match against scene nodes
         if self.settings.filterIsActive():
             filterData = r9Core.FilterNode(nodes,
                                            self.settings).ProcessFilter()
             matchedPairs = self._matchNodesToPoseData(filterData)
             if matchedPairs:
                 InternalNodes = [node for _, node in matchedPairs]
     if not InternalNodes:
         raise StandardError('No Matching Nodes found!!')
     return InternalNodes
Ejemplo n.º 3
0
 def matchInternalPoseObjects(self, nodes=None, fromFilter=True):
     '''
     This is a throw-away and only used in the UI to select for debugging!
     from a given poseFile return or select the internal stored objects
     '''
     InternalNodes=[]
     if not fromFilter:
         #no filter, we just pass in the longName thats stored
         for key in self.poseDict.keys():
             if cmds.objExists(self.poseDict[key]['longName']):
                 InternalNodes.append(self.poseDict[key]['longName'])
             elif cmds.objExists(key):
                 InternalNodes.append(key)
             elif cmds.objExists(r9Core.nodeNameStrip(key)):
                 InternalNodes.append(r9Core.nodeNameStrip(key))
     else:
         #use the internal Poses filter and then Match against scene nodes
         if self.settings.filterIsActive():
             filterData=r9Core.FilterNode(nodes,self.settings).ProcessFilter()
             matchedPairs=self._matchNodesToPoseData(filterData)
             if matchedPairs:
                 InternalNodes=[node for _,node in matchedPairs]
     if not InternalNodes:
         raise StandardError('No Matching Nodes found!!')
     return InternalNodes
Ejemplo n.º 4
0
 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=='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
Ejemplo n.º 5
0
 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
Ejemplo n.º 6
0
    def _buildPoseDict(self, nodes):
        """
        Build the internal poseDict up from the given nodes. This is the
        core of the Pose System
        """
        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

            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)
Ejemplo n.º 7
0
    def getAudioInRange(self,
                        time=(),
                        asNodes=True,
                        start_inRange=True,
                        end_inRange=True):
        '''
        return any audio in the handler within a given timerange

        :param time: tuple, (min,max) timerange which returned audio has to fall
             within else it's ignored.
        :param asNodes: return the data as r9Audio.AudioNodes, default=True
        :param start_inRange: check if the audio startFrame is after the time[0] value
        :param end_inRange: check if the audio endFrame is before the time[1] value

        .. note::
            if you pass in time as (None, 100) then we only validate against the end time.
            if we pass in time as (10, None) we only validate against the start time
            else we validate that the audio's start and end times are fully within the time range given
        '''
        audio_in_range = []
        for a in self.audioNodes:
            if r9Core.timeIsInRange(time, (a.startFrame, a.endFrame),
                                    start_inRange=start_inRange,
                                    end_inRange=end_inRange):
                audio_in_range.append(a)
        if not asNodes:
            return [a.audioNode for a in audio_in_range]
        return audio_in_range
Ejemplo n.º 8
0
 def buildOffsetCloud(self, rootReference=None, raw=False):
     '''
     Build a point cloud up for each node in nodes
     :param nodes: list of objects to be in the cloud
     :param rootReference: the node used for the initial pivot location
     :param raw: build the cloud but DON'T snap the nodes into place - an optimisation for the PoseLoad sequence
     '''
     self.posePointRoot=cmds.ls(cmds.spaceLocator(name='posePointCloud'),l=True)[0]
     
     ppcShape=cmds.listRelatives(self.posePointRoot,type='shape')[0]
     cmds.setAttr("%s.localScaleZ" % ppcShape, 30)
     cmds.setAttr("%s.localScaleX" % ppcShape, 30)
     cmds.setAttr("%s.localScaleY" % ppcShape, 30)
     
     if self.settings:
         if self.prioritySnapOnly:
             self.settings.searchPattern=self.settings.filterPriority
         self.inputNodes=r9Core.FilterNode(self.inputNodes, self.settings).ProcessFilter()
     if self.inputNodes:
         self.inputNodes.reverse()  # for the snapping operations
     
     if self.mayaUpAxis=='y':
         cmds.setAttr('%s.rotateOrder' % self.posePointRoot, 2)
     if rootReference:  # and not mesh:
         r9Anim.AnimFunctions.snap([rootReference,self.posePointRoot])
     for node in self.inputNodes:
         pnt=cmds.spaceLocator(name='pp_%s' % r9Core.nodeNameStrip(node))[0]
         if not raw:
             r9Anim.AnimFunctions.snap([node,pnt])
         cmds.parent(pnt,self.posePointRoot)
         self.posePointCloudNodes.append((pnt,node))
     cmds.select(self.posePointRoot)
     if self.mesh:
         self.shapeSwapMesh()
     return self.posePointCloudNodes
Ejemplo n.º 9
0
    def _buildPoseDict(self, nodes):
        '''
        Build the internal poseDict up from the given nodes. This is the
        core of the Pose System
        '''
        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
            
            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:
                    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)
Ejemplo n.º 10
0
    def _buildOffsetCloud(self,nodes,rootReference=None,raw=False):
        '''
        Build a point cloud up for each node in nodes
        @param nodes: list of objects to be in the cloud
        @param rootReference: the node used for the initial pibot location
        @param raw: build the cloud but DON'T snap the nodes into place - an optimisation for the PoseLoad sequence
        '''
        self.posePointCloudNodes=[]

        self.posePointRoot=cmds.ls(cmds.spaceLocator(name='posePointCloud'),l=True)[0]   
        
        ppcShape=cmds.listRelatives(self.posePointRoot,type='shape')[0] 
        cmds.setAttr( "%s.localScaleZ" % ppcShape, 30)
        cmds.setAttr( "%s.localScaleX" % ppcShape, 30)
        cmds.setAttr( "%s.localScaleY" % ppcShape, 30)
        
        if self.mayaUpAxis=='y':
            cmds.setAttr('%s.rotateOrder' % self.posePointRoot, 2)
        if rootReference:# and not mesh:
            r9Anim.AnimFunctions.snap([rootReference,self.posePointRoot]) 
        for node in nodes:
            pnt=cmds.spaceLocator(name='pp_%s' % r9Core.nodeNameStrip(node))[0]
            if not raw:
                r9Anim.AnimFunctions.snap([node,pnt])
            cmds.parent(pnt,self.posePointRoot)
            self.posePointCloudNodes.append((pnt,node))
        return self.posePointCloudNodes
Ejemplo n.º 11
0
 def _snapNodestoPosePnts(self):
     '''
     snap each MAYA node to it's respective pntCloud point
     '''
     for pnt, node in self.posePointCloudNodes:
         log.debug('snapping Ctrl : %s > %s : %s' % (r9Core.nodeNameStrip(node), pnt, node))
         r9Anim.AnimFunctions.snap([pnt,node])
Ejemplo n.º 12
0
 def _snapNodestoPosePnts(self):
     '''
     snap each MAYA node to it's respective pntCloud point
     '''
     for pnt, node in self.posePointCloudNodes:
         log.debug('snapping Ctrl : %s > %s : %s' %
                   (r9Core.nodeNameStrip(node), pnt, node))
         r9Anim.AnimFunctions.snap([pnt, node])
Ejemplo n.º 13
0
 def formatAudioNode_to_Path(self):
     '''
     rename the AudioNode so it ties to the wav name
     '''
     try:
         cmds.rename(self.audioNode, r9Core.nodeNameStrip(os.path.splitext(os.path.basename(self.path))[0]))
     except:
         log.debug('failed to Rename node : %s' % self.audioNode)
Ejemplo n.º 14
0
 def formatAudioNode_to_Path(self):
     '''
     rename the AudioNode so it ties to the wav name
     '''
     try:
         cmds.rename(
             self.audioNode,
             r9Core.nodeNameStrip(
                 os.path.splitext(os.path.basename(self.path))[0]))
     except:
         log.debug('failed to Rename node : %s' % self.audioNode)
Ejemplo n.º 15
0
 def formatAudioNode_to_Path(self):
     '''
     rename the AudioNode so it ties to the wav name
     '''
     try:
         cmds.rename(self.audioNode, r9Core.nodeNameStrip(os.path.splitext(os.path.basename(self.path))[0]))
     except:
         if cmds.referenceQuery(self.audioNode,inr=True):
             log.info('failed to Rename Referenced Audio Node : %s' % self.audioNode)
         else:
             log.info('failed to Rename Audio node : %s' % self.audioNode)
Ejemplo n.º 16
0
    def buildOffsetCloud(self, rootReference=None, raw=False):
        '''
        Build a point cloud up for each node in nodes
        :param nodes: list of objects to be in the cloud
        :param rootReference: the node used for the initial pivot location
        :param raw: build the cloud but DON'T snap the nodes into place - an optimisation for the PoseLoad sequence
        '''
        self.posePointRoot = cmds.ls(cmds.spaceLocator(name='posePointCloud'),
                                     l=True)[0]

        ppcShape = cmds.listRelatives(self.posePointRoot, type='shape')[0]
        cmds.setAttr("%s.localScaleZ" % ppcShape, 30)
        cmds.setAttr("%s.localScaleX" % ppcShape, 30)
        cmds.setAttr("%s.localScaleY" % ppcShape, 30)

        if self.settings:
            if self.prioritySnapOnly:
                self.settings.searchPattern = self.settings.filterPriority
            self.inputNodes = r9Core.FilterNode(self.inputNodes,
                                                self.settings).ProcessFilter()
        if self.inputNodes:
            self.inputNodes.reverse()  # for the snapping operations

        if self.mayaUpAxis == 'y':
            cmds.setAttr('%s.rotateOrder' % self.posePointRoot, 2)
        if rootReference:  # and not mesh:
            r9Anim.AnimFunctions.snap([rootReference, self.posePointRoot])
        for node in self.inputNodes:
            pnt = cmds.spaceLocator(name='pp_%s' %
                                    r9Core.nodeNameStrip(node))[0]
            if not raw:
                r9Anim.AnimFunctions.snap([node, pnt])
            cmds.parent(pnt, self.posePointRoot)
            self.posePointCloudNodes.append((pnt, node))
        cmds.select(self.posePointRoot)
        if self.mesh:
            self.shapeSwapMesh()
        return self.posePointCloudNodes
Ejemplo n.º 17
0
 def getNodes(self, nodes):
     '''
     get the nodes to process
     This is designed to allow for specific hooks to be used from user
     code stored in the pose folder itself.
     '''
     if not type(nodes) == list:
         nodes = [nodes]
     if self.useFilter:
         log.debug('getNodes - useFilter=True : no custom poseHandler')
         if self.settings.filterIsActive():
             return r9Core.FilterNode(
                 nodes, self.settings).ProcessFilter()  # main node filter
     else:
         log.debug('getNodes - useFilter=False : no custom poseHandler')
         return nodes
Ejemplo n.º 18
0
    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)
Ejemplo n.º 19
0
 def shapeSwapMesh(self):
     '''
     Swap the mesh Geo so it's a shape under the PPC transform root
     TODO: Make sure that the duplicate message link bug is covered!!
     '''
     cmds.duplicate(self.mesh, rc=True, n=self.refMesh)[0]
     r9Core.LockChannels().processState(self.refMesh,['tx','ty','tz','rx','ry','rz','sx','sy','sz'],\
                                        mode='fullkey',hierarchy=False)
     try:
         #turn on the overrides so the duplicate geo can be selected
         cmds.setAttr("%s.overrideDisplayType" % self.refMeshShape, 0)
         cmds.setAttr("%s.overrideEnabled" % self.refMeshShape, 1)
         cmds.setAttr("%s.overrideLevelOfDetail" % self.refMeshShape, 0)
     except:
         log.debug('Couldnt set the draw overrides for the refGeo')
     cmds.parent(self.refMesh, self.posePointRoot)
     cmds.makeIdentity(self.refMesh, apply=True, t=True, r=True)
     cmds.parent(self.refMeshShape, self.posePointRoot, r=True, s=True)
     cmds.delete(self.refMesh)
Ejemplo n.º 20
0
    def __init__(self, filterSettings=None):
        '''
        I'm not passing any data in terms of nodes here, We'll deal with
        those in the PoseSave and PoseLoad calls. Leaves this open for
        expansion
        '''
        self.poseDict = {}
        self.infoDict = {}
        self.skeletonDict = {}
        self.posePointCloudNodes = []
        self.filepath = ''
        self.mayaUpAxis = r9Setup.mayaUpAxis()
        self.thumbnailRes = [128, 128]
        self.poseCurrentCache = {
        }  # cached dict storing the current state of the objects prior to applying the pose

        self.__metaPose = False
        self.metaRig = None  # filled by the code as we process
        self.matchMethod = 'base'  # method used to match nodes internally in the poseDict
        self.relativePose = False
        self.relativeRots = 'projected'
        self.relativeTrans = 'projected'
        self.useFilter = True
        self.prioritySnapOnly = False
        self.skipAttrs = []  # attrs to completely ignore in any pose handling

        # make sure we have a settings object
        if filterSettings:
            if issubclass(type(filterSettings), r9Core.FilterNode_Settings):
                self.settings = filterSettings
                self.__metaPose = self.settings.metaRig
            else:
                raise StandardError(
                    'filterSettings param requires an r9Core.FilterNode_Settings object'
                )
        else:
            self.settings = r9Core.FilterNode_Settings()
            self.__metaPose = self.settings.metaRig

        self.settings.printSettings()
Ejemplo n.º 21
0
def batchPatchPoses(posedir, config, poseroot, load=True, save=True, patchfunc=None,\
                    relativePose=False, relativeRots=False, relativeTrans=False):
    '''
    whats this?? a fast method to run through all the poses in a given dictionary and update
    or patch them. If patchfunc isn't given it'll just run through and resave the pose - updating
    the systems if needed. If it is then it gets run between the load and save calls.
    :param posedir: directory of poses to process
    :param config: hierarchy settings cfg to use to ID the nodes (hierarchy tab preset = filterSettings object)
    :param poseroot: root node to the filters - poseTab rootNode/MetaRig root
    :param patchfunc: optional function to run between the load and save call in processing, great for
            fixing issues on mass with poses. Note we now pass pose file back into this func as an arg
    :param load: should the batch load the pose
    :param save: should the batch resave the pose
    '''

    filterObj = r9Core.FilterNode_Settings()
    filterObj.read(os.path.join(r9Setup.red9ModulePath(), 'presets',
                                config))  # 'Crytek_New_Meta.cfg'))
    mPose = PoseData(filterObj)

    files = os.listdir(posedir)
    files.sort()
    for f in files:
        if f.lower().endswith('.pose'):
            if load:
                mPose.poseLoad(poseroot,
                               os.path.join(posedir, f),
                               useFilter=True,
                               relativePose=relativePose,
                               relativeRots=relativeRots,
                               relativeTrans=relativeTrans)
            if patchfunc:
                patchfunc(f)
            if save:
                mPose.poseSave(poseroot,
                               os.path.join(posedir, f),
                               useFilter=True,
                               storeThumbnail=False)
            log.info('Processed Pose File :  %s' % f)
Ejemplo n.º 22
0
 def getAudioInRange(self, time=(), asNodes=True, start_inRange=True, end_inRange=True):
     '''
     return any audio in the handler within a given timerange
     
     :param time: tuple, (min,max) timerange within which returned audio has 
         fall within else it's ignored.
     :param asNodes: return the data as r9Audio.AudioNodes
     :param start_inRange: check is the testRange[0] value falls fully in the baseRange
     :param end_inRange: check is the testRange[1] value falls fully in the baseRange
 
     .. note::
         if you pass in time as (None, 100) then we only validate against the end time.
         if we pass in time as (10, None) we only validate against the start time
         else we validate that testRange is fully within the times
     '''
     audio_in_range=[]
     for a in self.audioNodes:
         if r9Core.timeIsInRange(time, (a.startFrame,a.endFrame), start_inRange=start_inRange, end_inRange=end_inRange):
             audio_in_range.append(a)
     if not asNodes:
         return [a.audioNode for a in audio_in_range]
     return audio_in_range
Ejemplo n.º 23
0
 def _buildSkeletonData(self, rootJnt):
     '''
     :param rootNode: root of the skeleton to process
     '''
     self.skeletonDict={}
     if not rootJnt:
         log.info('skeleton rootJnt joint was not found')
         return
     
     fn=r9Core.FilterNode(rootJnt)
     fn.settings.nodeTypes='joint'
     fn.settings.incRoots=False
     skeleton=fn.ProcessFilter()
     
     for jnt in skeleton:
         key=r9Core.nodeNameStrip(jnt)
         self.skeletonDict[key]={}
         self.skeletonDict[key]['attrs']={}
         for attr in ['translateX','translateY','translateZ', 'rotateX','rotateY','rotateZ']:
             try:
                 self.skeletonDict[key]['attrs'][attr]=cmds.getAttr('%s.%s' % (jnt,attr))
             except:
                 log.debug('%s : attr is invalid in this instance' % attr)
Ejemplo n.º 24
0
    def _buildSkeletonData(self, rootJnt):
        """
        :param rootNode: root of the skeleton to process
        """
        self.skeletonDict = {}
        if not rootJnt:
            log.info("skeleton rootJnt joint was not found")
            return

        fn = r9Core.FilterNode(rootJnt)
        fn.settings.nodeTypes = "joint"
        fn.settings.incRoots = False
        skeleton = fn.ProcessFilter()

        for jnt in skeleton:
            key = r9Core.nodeNameStrip(jnt)
            self.skeletonDict[key] = {}
            self.skeletonDict[key]["attrs"] = {}
            for attr in ["translateX", "translateY", "translateZ", "rotateX", "rotateY", "rotateZ"]:
                try:
                    self.skeletonDict[key]["attrs"][attr] = cmds.getAttr("%s.%s" % (jnt, attr))
                except:
                    log.debug("%s : attr is invalid in this instance" % attr)
Ejemplo n.º 25
0
 def compare(self):
     '''
     Compare the 2 PoseData objects via their internal [key][attrs] blocks
     return a bool. After processing self.fails is a dict holding all the fails
     for processing later if required
     '''
     self.fails = {}
     logprint = 'PoseCompare returns : ========================================\n'
     currentDic = getattr(self.currentPose, self.compareDict)
     referenceDic = getattr(self.referencePose, self.compareDict)
     
     if not currentDic or not referenceDic:
         raise StandardError('missing pose section <<%s>> compare aborted' % self.compareDict)
     
     for key, attrBlock in currentDic.items():
         if self.filterMap and not key in self.filterMap:
             log.debug('node not in filterMap - skipping key %s' % key)
             continue
         if key in referenceDic:
             referenceAttrBlock = referenceDic[key]
         else:
             if not 'missingKeys' in self.ignoreBlocks:
                 logprint += 'ERROR: Key Mismatch : %s\n' % key
                 if not 'missingKeys' in self.fails:
                     self.fails['missingKeys'] = []
                 self.fails['missingKeys'].append(key)
             else:
                 log.debug('missingKeys in ignoreblock : node is missing from data but being skipped "%s"' % key)
             continue
         
         for attr, value in attrBlock['attrs'].items():
             # attr missing completely from the key
             if not attr in referenceAttrBlock['attrs']:
                 if not 'failedAttrs' in self.fails:
                     self.fails['failedAttrs'] = {}
                 if not key in self.fails['failedAttrs']:
                     self.fails['failedAttrs'][key] = {}
                 if not 'missingAttrs' in self.fails['failedAttrs'][key]:
                     self.fails['failedAttrs'][key]['missingAttrs'] = []
                 self.fails['failedAttrs'][key]['missingAttrs'].append(attr)
                 # log.info('missing attribute in data : "%s.%s"' % (key,attr))
                 logprint += 'ERROR: Missing attribute in data : "%s.%s"\n' % (key, attr)
                 continue
             
             # test the attrs value matches
             value = r9Core.decodeString(value)  # decode as this may be a configObj
             refValue = r9Core.decodeString(referenceAttrBlock['attrs'][attr])  # decode as this may be a configObj
             
             if type(value) == float:
                 matched = False
                 if attr in self.angularAttrs:
                     matched = r9Core.floatIsEqual(value, refValue, self.angularTolerance, allowGimbal=True)
                 else:
                     matched = r9Core.floatIsEqual(value, refValue, self.linearTolerance, allowGimbal=False)
                 if not matched:
                     self.__addFailedAttr(key, attr)
                     # log.info('AttrValue float mismatch : "%s.%s" currentValue=%s >> expectedValue=%s' % (key,attr,value,refValue))
                     logprint += 'ERROR: AttrValue float mismatch : "%s.%s" currentValue=%s >> expectedValue=%s\n' % (key, attr, value, refValue)
                     continue
             elif not value == refValue:
                 self.__addFailedAttr(key, attr)
                 # log.info('AttrValue mismatch : "%s.%s" currentValue=%s >> expectedValue=%s' % (key,attr,value,refValue))
                 logprint += 'ERROR: AttrValue mismatch : "%s.%s" currentValue=%s >> expectedValue=%s\n' % (key, attr, value, refValue)
                 continue
             
     if 'missingKeys' in self.fails or 'failedAttrs' in self.fails:
         logprint += 'PoseCompare returns : ========================================'
         print logprint
         return False
     self.status = True
     return True
Ejemplo n.º 26
0
    def compare(self):
        '''
        Compare the 2 PoseData objects via their internal [key][attrs] blocks
        return a bool. After processing self.fails is a dict holding all the fails
        for processing later if required
        '''
        self.fails = {}
        logprint = 'PoseCompare returns : ========================================\n'
        currentDic = getattr(self.currentPose, self.compareDict)
        referenceDic = getattr(self.referencePose, self.compareDict)

        if not currentDic or not referenceDic:
            raise StandardError('missing pose section <<%s>> compare aborted' %
                                self.compareDict)

        for key, attrBlock in currentDic.items():
            if self.filterMap and not key in self.filterMap:
                log.debug('node not in filterMap - skipping key %s' % key)
                continue
            if key in referenceDic:
                referenceAttrBlock = referenceDic[key]
            else:
                if not 'missingKeys' in self.ignoreBlocks:
                    logprint += 'ERROR: Key Mismatch : %s\n' % key
                    if not 'missingKeys' in self.fails:
                        self.fails['missingKeys'] = []
                    self.fails['missingKeys'].append(key)
                else:
                    log.debug(
                        'missingKeys in ignoreblock : node is missing from data but being skipped "%s"'
                        % key)
                continue

            for attr, value in attrBlock['attrs'].items():
                # attr missing completely from the key
                if not attr in referenceAttrBlock['attrs']:
                    if not 'failedAttrs' in self.fails:
                        self.fails['failedAttrs'] = {}
                    if not key in self.fails['failedAttrs']:
                        self.fails['failedAttrs'][key] = {}
                    if not 'missingAttrs' in self.fails['failedAttrs'][key]:
                        self.fails['failedAttrs'][key]['missingAttrs'] = []
                    self.fails['failedAttrs'][key]['missingAttrs'].append(attr)
                    # log.info('missing attribute in data : "%s.%s"' % (key,attr))
                    logprint += 'ERROR: Missing attribute in data : "%s.%s"\n' % (
                        key, attr)
                    continue

                # test the attrs value matches
                value = r9Core.decodeString(
                    value)  # decode as this may be a configObj
                refValue = r9Core.decodeString(
                    referenceAttrBlock['attrs']
                    [attr])  # decode as this may be a configObj

                if type(value) == float:
                    matched = False
                    if attr in self.angularAttrs:
                        matched = r9Core.floatIsEqual(value,
                                                      refValue,
                                                      self.angularTolerance,
                                                      allowGimbal=True)
                    else:
                        matched = r9Core.floatIsEqual(value,
                                                      refValue,
                                                      self.linearTolerance,
                                                      allowGimbal=False)
                    if not matched:
                        self.__addFailedAttr(key, attr)
                        # log.info('AttrValue float mismatch : "%s.%s" currentValue=%s >> expectedValue=%s' % (key,attr,value,refValue))
                        logprint += 'ERROR: AttrValue float mismatch : "%s.%s" currentValue=%s >> expectedValue=%s\n' % (
                            key, attr, value, refValue)
                        continue
                elif not value == refValue:
                    self.__addFailedAttr(key, attr)
                    # log.info('AttrValue mismatch : "%s.%s" currentValue=%s >> expectedValue=%s' % (key,attr,value,refValue))
                    logprint += 'ERROR: AttrValue mismatch : "%s.%s" currentValue=%s >> expectedValue=%s\n' % (
                        key, attr, value, refValue)
                    continue

        if 'missingKeys' in self.fails or 'failedAttrs' in self.fails:
            logprint += 'PoseCompare returns : ========================================'
            print logprint
            return False
        self.status = True
        return True
Ejemplo n.º 27
0
    def poseLoad(self, nodes, filepath=None, useFilter=True, relativePose=False, relativeRots='projected',
                 relativeTrans='projected', maintainSpaces=False, percent=None):
        '''
        Entry point for the generic PoseLoad.
        
        :param nodes:  if given load the data to only these. If given and filter=True 
            this is the rootNode for the filter.
        :param filepath: posefile to load - if not given the pose is loaded from a 
            cached instance on this class.
        :param useFilter: If the pose has an active Filter_Settings block and this 
            is True then use the filter on the destination hierarchy.
        :param relativePose: kick in the posePointCloud to align the loaded pose 
            relatively to the selected node.
        :param relativeRots: 'projected' or 'absolute' - how to calculate the offset.
        :param relativeTrans: 'projected' or 'absolute' - how to calculate the offset.
        :param maintainSpaces: this preserves any parentSwitching mismatches between 
            the stored pose and the current rig settings, current spaces are maintained. 
            This only checks those nodes in the snapList and only runs under relative mode.
        '''
        
        if relativePose and not cmds.ls(sl=True):
            raise StandardError('Nothing selected to align Relative Pose too')
        if not type(nodes)==list:
            nodes=[nodes]  # cast to list for consistency
        
        #push args to object - means that any poseHandler.py file has access to them
        self.relativePose = relativePose
        self.relativeRots = relativeRots
        self.relativeTrans = relativeTrans
        self.PosePointCloud = None
        self.filepath = filepath
        self.useFilter = useFilter  # used in the getNodes call
        self.maintainSpaces = maintainSpaces
        
        nodesToLoad = self._poseLoad_buildcache(nodes)
        
        if not self.matchedPairs:
            raise StandardError('No Matching Nodes found in the PoseFile!')
        else:
            if self.relativePose:
                if self.prioritySnapOnly:
                    #we've already filtered the hierarchy, may as well just filter the results for speed
                    nodesToLoad=r9Core.prioritizeNodeList(nodesToLoad, self.settings.filterPriority, regex=True, prioritysOnly=True)
                    nodesToLoad.reverse()
                    
                #setup the PosePointCloud -------------------------------------------------
                reference=cmds.ls(sl=True,l=True)[0]
                self.PosePointCloud=PosePointCloud(nodesToLoad)
                self.PosePointCloud.buildOffsetCloud(reference, raw=True)
                resetCache=[cmds.getAttr('%s.translate' % self.PosePointCloud.posePointRoot),
                            cmds.getAttr('%s.rotate' % self.PosePointCloud.posePointRoot)]
                
                if self.maintainSpaces:
                    if self.metaRig:
                        parentSpaceCache=self.getMaintainedAttrs(nodesToLoad, self.metaRig.parentSwitchAttr)
                    elif 'parentSpaces' in self.settings.rigData:
                        parentSpaceCache=self.getMaintainedAttrs(nodesToLoad, self.settings.rigData['parentSpaces'])
    
            self._applyPose(percent)

            if self.relativePose:
                #snap the poseCloud to the new xform of the referenced node, snap the cloud
                #to the pose, reset the clouds parent to the cached xform and then snap the
                #nodes back to the cloud
                r9Anim.AnimFunctions.snap([reference,self.PosePointCloud.posePointRoot])
                 
                if self.relativeRots=='projected':
                    if self.mayaUpAxis=='y':
                        cmds.setAttr('%s.rx' % self.PosePointCloud.posePointRoot,0)
                        cmds.setAttr('%s.rz' % self.PosePointCloud.posePointRoot,0)
                    elif self.mayaUpAxis=='z':  # f*****g Z!!!!!!
                        cmds.setAttr('%s.rx' % self.PosePointCloud.posePointRoot,0)
                        cmds.setAttr('%s.ry' % self.PosePointCloud.posePointRoot,0)
                    
                self.PosePointCloud._snapPosePntstoNodes()
                
                if not self.relativeTrans=='projected':
                    cmds.setAttr('%s.translate' % self.PosePointCloud.posePointRoot,
                                 resetCache[0][0][0],
                                 resetCache[0][0][1],
                                 resetCache[0][0][2])
                if not self.relativeRots=='projected':
                    cmds.setAttr('%s.rotate' % self.PosePointCloud.posePointRoot,
                                 resetCache[1][0][0],
                                 resetCache[1][0][1],
                                 resetCache[1][0][2])
               
                if self.relativeRots=='projected':
                    if self.mayaUpAxis=='y':
                        cmds.setAttr('%s.ry' % self.PosePointCloud.posePointRoot,resetCache[1][0][1])
                    elif self.mayaUpAxis=='z':  # f*****g Z!!!!!!
                        cmds.setAttr('%s.rz' % self.PosePointCloud.posePointRoot,resetCache[1][0][2])
                if self.relativeTrans=='projected':
                    if self.mayaUpAxis=='y':
                        cmds.setAttr('%s.tx' % self.PosePointCloud.posePointRoot,resetCache[0][0][0])
                        cmds.setAttr('%s.tz' % self.PosePointCloud.posePointRoot,resetCache[0][0][2])
                    elif self.mayaUpAxis=='z':  # f*****g Z!!!!!!
                        cmds.setAttr('%s.tx' % self.PosePointCloud.posePointRoot,resetCache[0][0][0])
                        cmds.setAttr('%s.ty' % self.PosePointCloud.posePointRoot,resetCache[0][0][1])
                
                #if maintainSpaces then restore the original parentSwitch attr values
                #BEFORE pushing the point cloud data back to the rig
                if self.maintainSpaces and parentSpaceCache:  # and self.metaRig:
                    for child,attr,value in parentSpaceCache:
                        log.debug('Resetting parentSwitches : %s.%s = %f' % (r9Core.nodeNameStrip(child),attr,value))
                        cmds.setAttr('%s.%s' % (child,attr), value)
                            
                self.PosePointCloud._snapNodestoPosePnts()
                self.PosePointCloud.delete()
                cmds.select(reference)
Ejemplo n.º 28
0
    def compare(self):
        """
        Compare the 2 PoseData objects via their internal [key][attrs] blocks
        return a bool. After processing self.fails is a dict holding all the fails
        for processing later if required
        """
        self.fails = {}
        logprint = "PoseCompare returns : ========================================\n"
        currentDic = getattr(self.currentPose, self.compareDict)
        referenceDic = getattr(self.referencePose, self.compareDict)

        if not currentDic or not referenceDic:
            raise StandardError("missing pose section <<%s>> compare aborted" % self.compareDict)

        for key, attrBlock in currentDic.items():
            if key in referenceDic:
                referenceAttrBlock = referenceDic[key]
            else:
                # log.info('Key Mismatch : %s' % key)
                logprint += "ERROR: Key Mismatch : %s\n" % key
                if not "missingKeys" in self.fails:
                    self.fails["missingKeys"] = []
                self.fails["missingKeys"].append(key)
                continue

            for attr, value in attrBlock["attrs"].items():
                # attr missing completely from the key
                if not attr in referenceAttrBlock["attrs"]:
                    if not "failedAttrs" in self.fails:
                        self.fails["failedAttrs"] = {}
                    if not key in self.fails["failedAttrs"]:
                        self.fails["failedAttrs"][key] = {}
                    if not "missingAttrs" in self.fails["failedAttrs"][key]:
                        self.fails["failedAttrs"][key]["missingAttrs"] = []
                    self.fails["failedAttrs"][key]["missingAttrs"].append(attr)
                    # log.info('missing attribute in data : "%s.%s"' % (key,attr))
                    logprint += 'ERROR: Missing attribute in data : "%s.%s"\n' % (key, attr)
                    continue

                # test the attrs value matches
                value = r9Core.decodeString(value)  # decode as this may be a configObj
                refValue = r9Core.decodeString(referenceAttrBlock["attrs"][attr])  # decode as this may be a configObj

                if type(value) == float:
                    matched = False
                    if attr in self.angularAttrs:
                        matched = r9Core.floatIsEqual(value, refValue, self.angularTolerance, allowGimbal=True)
                    else:
                        matched = r9Core.floatIsEqual(value, refValue, self.linearTolerance, allowGimbal=False)
                    if not matched:
                        self.__addFailedAttr(key, attr)
                        # log.info('AttrValue float mismatch : "%s.%s" currentValue=%s >> expectedValue=%s' % (key,attr,value,refValue))
                        logprint += (
                            'ERROR: AttrValue float mismatch : "%s.%s" currentValue=%s >> expectedValue=%s\n'
                            % (key, attr, value, refValue)
                        )
                        continue
                elif not value == refValue:
                    self.__addFailedAttr(key, attr)
                    # log.info('AttrValue mismatch : "%s.%s" currentValue=%s >> expectedValue=%s' % (key,attr,value,refValue))
                    logprint += 'ERROR: AttrValue mismatch : "%s.%s" currentValue=%s >> expectedValue=%s\n' % (
                        key,
                        attr,
                        value,
                        refValue,
                    )
                    continue

        if "missingKeys" in self.fails or "failedAttrs" in self.fails:
            logprint += "PoseCompare returns : ========================================"
            print logprint
            return False
        self.status = True
        return True
Ejemplo n.º 29
0
def bind_skeletons(source,
                   dest,
                   method='connect',
                   scales=False,
                   verbose=False,
                   unlock=False,
                   bindroot=True):
    '''
    From 2 given root joints search through each hierarchy for child joints, match
    them based on node name, then connect their trans/rots directly, or
    parentConstrain them. Again cmds for speed

    :param source: the root node of the driving skeleton
    :param dest: the root node of the driven skeleton
    :param method: the method used for the connection, either 'connect' or 'constrain'
    :param scale: do we bind the scales of the destination skel to the source??
    :param unlock: if True force unlock the required transform attrs on the destination skeleton first
    '''

    sourceJoints = cmds.listRelatives(source, ad=True, f=True, type='joint')
    destJoints = cmds.listRelatives(dest, ad=True, f=True, type='joint')

    if verbose:
        result = cmds.confirmDialog(
            title='Bind Skeletons SCALES',
            message=
            ("Would you also like to process the SCALE channels within the bind?"
             ),
            button=['Yes', 'No'],
            messageAlign='center',
            icon='question',
            dismissString='Cancel')
        if result == 'Yes':
            scales = True
        else:
            scales = False

    # parent constrain the root nodes regardless of bindType, fixes issues where
    # we have additional rotated parent groups on the source
    if bindroot:
        cmds.parentConstraint(source, dest)
        if scales:
            cmds.scaleConstraint(source, dest, mo=True)

    # attrs to 'connect' and also to ensure are unlocked
    attrs = [
        'rotateX', 'rotateY', 'rotateZ', 'translateX', 'translateY',
        'translateZ'
    ]
    if scales:
        attrs = attrs + ['scaleX', 'scaleY', 'scaleZ', 'inverseScale']
    if unlock:
        r9Core.LockChannels().processState(dest,
                                           attrs=attrs,
                                           mode='fullkey',
                                           hierarchy=True)

    for sJnt, dJnt in match_given_hierarchys(sourceJoints, destJoints):
        if method == 'connect':
            for attr in attrs:
                try:
                    cmds.connectAttr('%s.%s' % (sJnt, attr),
                                     '%s.%s' % (dJnt, attr),
                                     f=True)
                except:
                    pass
        elif method == 'constrain':
            # need to see if the channels are open if not, change this binding code
            try:
                cmds.parentConstraint(sJnt, dJnt, mo=True)
            except:
                chns = r9Anim.getSettableChannels(dJnt)
                if all([
                        'translateX' in chns, 'translateY' in chns,
                        'translateZ' in chns
                ]):
                    cmds.pointConstraint(sJnt, dJnt, mo=True)
                elif all(
                    ['rotateX' in chns, 'rotateY' in chns, 'rotateZ' in chns]):
                    cmds.orientConstraint(sJnt, dJnt, mo=True)
                else:
                    log.info('Failed to Bind joints: %s >> %s' % (sJnt, dJnt))

            # if we have incoming scale connections then run the scaleConstraint
            if scales:  # and cmds.listConnections('%s.sx' % sJnt):
                try:
                    cmds.scaleConstraint(sJnt, dJnt, mo=True)
                    # turn off the compensation so that the rig can still be scaled correctly by the MasterNode
                    # cmds.setAttr('%s.segmentScaleCompensate' % dJnt, 0)
                except:
                    print('failed : scales ', dJnt)
Ejemplo n.º 30
0
    def poseLoad(self,
                 nodes,
                 filepath=None,
                 useFilter=True,
                 relativePose=False,
                 relativeRots='projected',
                 relativeTrans='projected',
                 maintainSpaces=False,
                 percent=None):
        '''
        Entry point for the generic PoseLoad.
        
        :param nodes:  if given load the data to only these. If given and filter=True 
            this is the rootNode for the filter.
        :param filepath: posefile to load - if not given the pose is loaded from a 
            cached instance on this class.
        :param useFilter: If the pose has an active Filter_Settings block and this 
            is True then use the filter on the destination hierarchy.
        :param relativePose: kick in the posePointCloud to align the loaded pose 
            relatively to the selected node.
        :param relativeRots: 'projected' or 'absolute' - how to calculate the offset.
        :param relativeTrans: 'projected' or 'absolute' - how to calculate the offset.
        :param maintainSpaces: this preserves any parentSwitching mismatches between 
            the stored pose and the current rig settings, current spaces are maintained. 
            This only checks those nodes in the snapList and only runs under relative mode.
        '''

        if relativePose and not cmds.ls(sl=True):
            raise StandardError('Nothing selected to align Relative Pose too')
        if not type(nodes) == list:
            nodes = [nodes]  # cast to list for consistency

        #push args to object - means that any poseHandler.py file has access to them
        self.relativePose = relativePose
        self.relativeRots = relativeRots
        self.relativeTrans = relativeTrans
        self.PosePointCloud = None
        self.filepath = filepath
        self.useFilter = useFilter  # used in the getNodes call
        self.maintainSpaces = maintainSpaces

        nodesToLoad = self._poseLoad_buildcache(nodes)

        if not self.matchedPairs:
            raise StandardError('No Matching Nodes found in the PoseFile!')
        else:
            if self.relativePose:
                if self.prioritySnapOnly:
                    #we've already filtered the hierarchy, may as well just filter the results for speed
                    nodesToLoad = r9Core.prioritizeNodeList(
                        nodesToLoad,
                        self.settings.filterPriority,
                        regex=True,
                        prioritysOnly=True)
                    nodesToLoad.reverse()

                #setup the PosePointCloud -------------------------------------------------
                reference = cmds.ls(sl=True, l=True)[0]
                self.PosePointCloud = PosePointCloud(nodesToLoad)
                self.PosePointCloud.buildOffsetCloud(reference, raw=True)
                resetCache = [
                    cmds.getAttr('%s.translate' %
                                 self.PosePointCloud.posePointRoot),
                    cmds.getAttr('%s.rotate' %
                                 self.PosePointCloud.posePointRoot)
                ]

                if self.maintainSpaces:
                    if self.metaRig:
                        parentSpaceCache = self.getMaintainedAttrs(
                            nodesToLoad, self.metaRig.parentSwitchAttr)
                    elif 'parentSpaces' in self.settings.rigData:
                        parentSpaceCache = self.getMaintainedAttrs(
                            nodesToLoad, self.settings.rigData['parentSpaces'])

            self._applyPose(percent)

            if self.relativePose:
                #snap the poseCloud to the new xform of the referenced node, snap the cloud
                #to the pose, reset the clouds parent to the cached xform and then snap the
                #nodes back to the cloud
                r9Anim.AnimFunctions.snap(
                    [reference, self.PosePointCloud.posePointRoot])

                if self.relativeRots == 'projected':
                    if self.mayaUpAxis == 'y':
                        cmds.setAttr(
                            '%s.rx' % self.PosePointCloud.posePointRoot, 0)
                        cmds.setAttr(
                            '%s.rz' % self.PosePointCloud.posePointRoot, 0)
                    elif self.mayaUpAxis == 'z':  # f*****g Z!!!!!!
                        cmds.setAttr(
                            '%s.rx' % self.PosePointCloud.posePointRoot, 0)
                        cmds.setAttr(
                            '%s.ry' % self.PosePointCloud.posePointRoot, 0)

                self.PosePointCloud._snapPosePntstoNodes()

                if not self.relativeTrans == 'projected':
                    cmds.setAttr(
                        '%s.translate' % self.PosePointCloud.posePointRoot,
                        resetCache[0][0][0], resetCache[0][0][1],
                        resetCache[0][0][2])
                if not self.relativeRots == 'projected':
                    cmds.setAttr(
                        '%s.rotate' % self.PosePointCloud.posePointRoot,
                        resetCache[1][0][0], resetCache[1][0][1],
                        resetCache[1][0][2])

                if self.relativeRots == 'projected':
                    if self.mayaUpAxis == 'y':
                        cmds.setAttr(
                            '%s.ry' % self.PosePointCloud.posePointRoot,
                            resetCache[1][0][1])
                    elif self.mayaUpAxis == 'z':  # f*****g Z!!!!!!
                        cmds.setAttr(
                            '%s.rz' % self.PosePointCloud.posePointRoot,
                            resetCache[1][0][2])
                if self.relativeTrans == 'projected':
                    if self.mayaUpAxis == 'y':
                        cmds.setAttr(
                            '%s.tx' % self.PosePointCloud.posePointRoot,
                            resetCache[0][0][0])
                        cmds.setAttr(
                            '%s.tz' % self.PosePointCloud.posePointRoot,
                            resetCache[0][0][2])
                    elif self.mayaUpAxis == 'z':  # f*****g Z!!!!!!
                        cmds.setAttr(
                            '%s.tx' % self.PosePointCloud.posePointRoot,
                            resetCache[0][0][0])
                        cmds.setAttr(
                            '%s.ty' % self.PosePointCloud.posePointRoot,
                            resetCache[0][0][1])

                #if maintainSpaces then restore the original parentSwitch attr values
                #BEFORE pushing the point cloud data back to the rig
                if self.maintainSpaces and parentSpaceCache:  # and self.metaRig:
                    for child, attr, value in parentSpaceCache:
                        log.debug('Resetting parentSwitches : %s.%s = %f' %
                                  (r9Core.nodeNameStrip(child), attr, value))
                        cmds.setAttr('%s.%s' % (child, attr), value)

                self.PosePointCloud._snapNodestoPosePnts()
                self.PosePointCloud.delete()
                cmds.select(reference)