Ejemplo n.º 1
0
def returnClosestPointOnMeshInfo(targetObj, mesh):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Returns pertinent info of the closest point of a mesh to a target object -
    position, normal, parameterU,parameterV,closestFaceIndex,closestVertexIndex

    ARGUMENTS:
    targetObj(string)
    mesh(string)

    RETURNS:
    closestPointInfo(dict)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """

    """ make the closest point node """
    closestPointNode = mc.createNode ('closestPointOnMesh')
    controlSurface = mc.listRelatives(mesh,shapes=True)

    """ to account for target objects in heirarchies """
    attributes.doConnectAttr((targetObj+'.translate'),(closestPointNode+'.inPosition'))
    attributes.doConnectAttr((controlSurface[0]+'.worldMesh'),(closestPointNode+'.inMesh'))
    attributes.doConnectAttr((controlSurface[0]+'.matrix'),(closestPointNode+'.inputMatrix'))

    pointInfo = {}
    pointInfo['position']=attributes.doGetAttr(closestPointNode,'position')
    pointInfo['normal']=attributes.doGetAttr(closestPointNode,'normal')
    pointInfo['parameterU']=mc.getAttr(closestPointNode+'.parameterU')
    pointInfo['parameterV']=mc.getAttr(closestPointNode+'.parameterV')
    pointInfo['closestFaceIndex']=mc.getAttr(closestPointNode+'.closestFaceIndex')
    pointInfo['closestVertexIndex']=mc.getAttr(closestPointNode+'.closestVertexIndex')

    mc.delete(closestPointNode)
    return pointInfo
Ejemplo n.º 2
0
def returnClosestPointOnMeshInfo(targetObj, mesh):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Returns pertinent info of the closest point of a mesh to a target object -
    position, normal, parameterU,parameterV,closestFaceIndex,closestVertexIndex

    ARGUMENTS:
    targetObj(string)
    mesh(string)

    RETURNS:
    closestPointInfo(dict)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """

    """ make the closest point node """
    closestPointNode = mc.createNode ('closestPointOnMesh')
    controlSurface = mc.listRelatives(mesh,shapes=True)

    """ to account for target objects in heirarchies """
    attributes.doConnectAttr((targetObj+'.translate'),(closestPointNode+'.inPosition'))
    attributes.doConnectAttr((controlSurface[0]+'.worldMesh'),(closestPointNode+'.inMesh'))
    attributes.doConnectAttr((controlSurface[0]+'.matrix'),(closestPointNode+'.inputMatrix'))

    pointInfo = {}
    pointInfo['position']=attributes.doGetAttr(closestPointNode,'position')
    pointInfo['normal']=attributes.doGetAttr(closestPointNode,'normal')
    pointInfo['parameterU']=mc.getAttr(closestPointNode+'.parameterU')
    pointInfo['parameterV']=mc.getAttr(closestPointNode+'.parameterV')
    pointInfo['closestFaceIndex']=mc.getAttr(closestPointNode+'.closestFaceIndex')
    pointInfo['closestVertexIndex']=mc.getAttr(closestPointNode+'.closestVertexIndex')

    mc.delete(closestPointNode)
    return pointInfo
Ejemplo n.º 3
0
    def finalize(self):
        """
        Press action. Clears buffers.
        """
        #Clean our lists...
        self.l_created = lists.returnListNoDuplicates(self.l_created)
        self.l_return = lists.returnListNoDuplicates(self.l_return)

        if self._createMode in ['curve','jointChain','group','follicle'] and self.l_return:
            if self._createMode == 'group':
                bufferList = []
                for i,o in enumerate(self.l_created):
                    buffer = rigging.groupMeObject(o,False)
                    bufferList.append(buffer)                    
                    try:mc.delete(o)
                    except:pass
                self.l_created = bufferList

            elif self._createMode =='follicle':
                if self.mode == 'midPoint':
                    log.warning("Mid point mode doesn't work with follicles")
                    return
                bufferList = []
                for o in self.l_created:
                    mesh = attributes.doGetAttr(o,'cgmHitTarget')
                    if mc.objExists(mesh):
                        uv = distance.returnClosestUVToPos(mesh,distance.returnWorldSpacePosition(o))
                        log.info("uv: {0}".format(uv))
                        follicle = nodes.createFollicleOnMesh(mesh)
                        log.info("follicle: {0}".format(follicle))                        
                        attributes.doSetAttr(follicle[0],'parameterU',uv[0])
                        attributes.doSetAttr(follicle[0],'parameterV',uv[1])
                        try:mc.delete(o)
                        except:pass                        
            else:
                for o in self.l_created:
                    try:mc.delete(o)
                    except:pass
                if self._createMode == 'curve' and len(self.l_return)>1:
                    if len(self.l_return) > 1:
                        self.l_created = [curves.curveFromPosList(self.l_return)]
                    else:
                        log.warning("Need at least 2 points for a curve")                        
                elif self._createMode == 'jointChain':
                    self.l_created = []
                    mc.select(cl=True)
                    for pos in self.l_return:                             
                        self.l_created.append( mc.joint (p = (pos[0], pos[1], pos[2]),radius = 1) ) 
        log.debug( self.l_created)

        if self.d_tagAndName:
            for o in self.l_created:
                try:
                    i_o = cgmMeta.cgmNode(o)
                    for tag in self.d_tagAndName.keys():
                        i_o.doStore(tag,self.d_tagAndName[tag])
                    i_o.doName()
                except StandardError,error:
                    log.error(">>> clickMesh >> Failed to tag and name: %s | error: %s"%(i_o.p_nameShort,error))            	            		
Ejemplo n.º 4
0
    def __init__(self, *args, **kws):
        log.info('ChildClass.__init__ --')
        #Pull out our args/kws we need  ----------------------------------------------------------------------
        node = kws.get('node')
        name = kws.get('name')
        _setClass = kws.get('setClass') or None
        if args:
            node = args[0]
            if len(args) > 1:
                name = args[1]
            else:
                name = kws.get('name')

        if node is None or name is not None and mc.objExists(name):
            log.info("Created node")
            createdState = True
        else:
            createdState = False

        if _setClass:
            log.info(
                "Preinitialize, setClass | default {0} | Maybe you shouldn't do this..."
                .format(type(self).__name__))
            try:  #>>> TO CHECK IF WE NEED TO CLEAR CACHE ---------------------------------------------------------
                _currentMClass = attributes.doGetAttr(
                    node, 'mClass')  #...use to avoid exceptions

                if _setClass in [True, 1]:
                    _setClass = type(self).__name__

                if _setClass not in r9Meta.RED9_META_REGISTERY:
                    log.error("mClass value not registered - '{0}'".format(
                        _setClass))
                _setMClass = False
                if _setClass:  #...if we're going to set the mClass attr...
                    if _currentMClass:  #...does it have a current mClass attr value?
                        if _currentMClass != _setClass:  #...if not the same, replace
                            log.warning(
                                "mClasses don't match. Changing to '{0}'".
                                format(_setClass))
                            #mc.setAttr('%s.mClass' %(node), value = _setClass)
                            attributes.doSetAttr(node, 'mClass', _setClass,
                                                 True)
                            attributes.doSetAttr(node, 'UUID', '', True)
                            _setMClass = True
                        else:
                            log.info("mClasses match. ignoring...")
                    else:  #...if we have no value, set it
                        log.info("No mClass value, setting...")
                        _setMClass = True
                    if _setMClass:
                        if not mc.objExists("{0}.mClass".format(node)):
                            attributes.doAddAttr(node, 'mClass', 'string')
                        if not mc.objExists("{0}.UUID".format(node)):
                            attributes.doAddAttr(node, 'UUID', 'string')
                        attributes.doSetAttr(node, 'UUID', '', True)
                        attributes.doSetAttr(node, 'mClass', _setClass, True)
            except Exception, error:
                log.error("pre setClass fail >> %s" % error)
Ejemplo n.º 5
0
def returnClosestPointOnMeshInfoFromPos(pos, mesh):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Returns pertinent info of the closest point of a mesh to a position in space -
    position, normal, parameterU,parameterV,closestFaceIndex,closestVertexIndex

    ARGUMENTS:
    pos(string)
    mesh(string)

    RETURNS:
    closestPointInfo(dict)
    Keys:
    position
    normal
    parameterU
    parameterV
    closestFaceIndex
    closestVertexIndex
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """

    """ make the closest point node """
    closestPointNode = mc.createNode ('closestPointOnMesh')
    controlSurface = mc.listRelatives(mesh,shapes=True)

    """ to account for target objects in heirarchies """
    locBuffer = mc.spaceLocator()
    mc.move (pos[0],pos[1],pos[2], locBuffer[0])

    attributes.doConnectAttr((locBuffer[0]+'.translate'),(closestPointNode+'.inPosition'))
    attributes.doConnectAttr((controlSurface[0]+'.worldMesh'),(closestPointNode+'.inMesh'))
    attributes.doConnectAttr((locBuffer[0]+'.matrix'),(closestPointNode+'.inputMatrix'))
 
    pointInfo = {}
    pointInfo['position']=attributes.doGetAttr(closestPointNode,'position')
    pointInfo['normal']=attributes.doGetAttr(closestPointNode,'normal')
    pointInfo['parameterU']=mc.getAttr(closestPointNode+'.parameterU')
    pointInfo['parameterV']=mc.getAttr(closestPointNode+'.parameterV')
    pointInfo['closestFaceIndex']=mc.getAttr(closestPointNode+'.closestFaceIndex')
    pointInfo['closestVertexIndex']=mc.getAttr(closestPointNode+'.closestVertexIndex')

    mc.delete(closestPointNode)
    mc.delete(locBuffer[0])
    return pointInfo
Ejemplo n.º 6
0
def simplePuppetReturn():
    catch = mc.ls(type='network')
    returnList = []
    if catch:
        for o in catch:
            if attributes.doGetAttr(o,'mClass') in ['cgmPuppet','cgmMorpheusPuppet']:
                returnList.append(o)
    return returnList
Ejemplo n.º 7
0
def simplePuppetReturn():
    catch = mc.ls(type='network')
    returnList = []
    if catch:
        for o in catch:
            if attributes.doGetAttr(
                    o, 'mClass') in ['cgmPuppet', 'cgmMorpheusPuppet']:
                returnList.append(o)
    return returnList
Ejemplo n.º 8
0
    def verifyRotateOrderControl(self):
	assert self.transform,"'%s' has no transform"%self.nameShort	
	initialValue = attributes.doGetAttr(self.nameLong,'rotateOrder')
	try:
	    self.RotateOrderControl = AttrFactory(self,'setRO','enum',enum = 'xyz:yzx:zxy:xzy:yxz:zyx',initialValue=initialValue) 
	except:
	    raise StandardError("Failed to add rotate order control")
	
	self.stateControlRO == True
	self.RotateOrderControl.doConnectOut(self.nameShort+'.rotateOrder')
Ejemplo n.º 9
0
def returnTemplateObjects(self):
    try:
        templateNull = self.templateNull.getShortName()
        returnList = []
        for obj in mc.ls(type = 'transform'):
            if attributes.doGetAttr(obj,'templateOwner') == templateNull:
                returnList.append(obj)
        return returnList
    except StandardError,error:
        log.warning(error)        
Ejemplo n.º 10
0
def returnTemplateObjects(self):
    try:
        templateNull = self.templateNull.getShortName()
        returnList = []
        for obj in mc.ls(type='transform'):
            if attributes.doGetAttr(obj, 'templateOwner') == templateNull:
                returnList.append(obj)
        return returnList
    except StandardError, error:
        log.warning(error)
Ejemplo n.º 11
0
    def verifyRotateOrderControl(self):
	assert self.transform,"'%s' has no transform"%self.nameShort	
	initialValue = attributes.doGetAttr(self.nameLong,'rotateOrder')
	try:
	    self.RotateOrderControl = AttrFactory(self,'setRO','enum',enum = 'xyz:yzx:zxy:xzy:yxz:zyx',initialValue=initialValue) 
	except:
	    raise StandardError("Failed to add rotate order control")
	
	self.stateControlRO == True
	self.RotateOrderControl.doConnectOut(self.nameShort+'.rotateOrder')
Ejemplo n.º 12
0
    def __init__(self,*args,**kws):    
        log.info('ChildClass.__init__ --')	
        #Pull out our args/kws we need  ----------------------------------------------------------------------	
        node = kws.get('node')
        name = kws.get('name')
        _setClass = kws.get('setClass') or None
        if args:
            node = args[0]
            if len(args)>1:
                name = args[1]
            else:
                name = kws.get('name')

        if node is None or name is not None and mc.objExists(name):
            log.info("Created node")
            createdState = True
        else:
            createdState = False
            
        if _setClass:
            log.info("Preinitialize, setClass | default {0} | Maybe you shouldn't do this...".format(type(self).__name__))	
            try:#>>> TO CHECK IF WE NEED TO CLEAR CACHE ---------------------------------------------------------
                _currentMClass = attributes.doGetAttr(node,'mClass')#...use to avoid exceptions	
        
                if _setClass in [True, 1]:
                    _setClass = type(self).__name__	
        
                if _setClass not in r9Meta.RED9_META_REGISTERY:
                    log.error("mClass value not registered - '{0}'".format(_setClass))
                _setMClass = False
                if _setClass:#...if we're going to set the mClass attr...
                    if _currentMClass:#...does it have a current mClass attr value?
                        if _currentMClass != _setClass:#...if not the same, replace
                            log.warning("mClasses don't match. Changing to '{0}'".format(_setClass))				    
                            #mc.setAttr('%s.mClass' %(node), value = _setClass)	
                            attributes.doSetAttr(node,'mClass',_setClass,True)				
                            attributes.doSetAttr(node,'UUID','',True)
                            _setMClass = True
                        else:
                            log.info("mClasses match. ignoring...")				    		
                    else:#...if we have no value, set it
                        log.info("No mClass value, setting...")
                        _setMClass = True
                    if _setMClass:
                        if not mc.objExists("{0}.mClass".format(node)):
                            attributes.doAddAttr(node, 'mClass', 'string')
                        if not mc.objExists("{0}.UUID".format(node)):
                            attributes.doAddAttr(node, 'UUID', 'string')				
                        attributes.doSetAttr(node,'UUID','',True)
                        attributes.doSetAttr(node,'mClass',_setClass,True)			    
            except Exception,error:
                log.error("pre setClass fail >> %s"%error)
Ejemplo n.º 13
0
    def finalize(self):
        """
        Press action. Clears buffers.
        """
        #Clean our lists...
        self.createdList = lists.returnListNoDuplicates(self.createdList)
        self.returnList = lists.returnListNoDuplicates(self.returnList)
        
        if self.createMode in ['curve','jointChain','group','follicle'] and self.returnList:
            if self.createMode == 'group':
                bufferList = []
                for i,o in enumerate(self.createdList):
                    buffer = rigging.groupMeObject(o,False)
                    bufferList.append(buffer)                    
                    try:mc.delete(o)
                    except:pass
                self.createdList = bufferList
                
            elif self.createMode =='follicle':
                if self.mode == 'midPoint':
                    guiFactory.warning("Mid point mode doesn't work with follicles")
                    return
                bufferList = []
                for o in self.createdList:
                    mesh = attributes.doGetAttr(o,'cgmHitTarget')
                    if mc.objExists(mesh):
                        uv = distance.returnClosestUVToPos(mesh,distance.returnWorldSpacePosition(o))
                        follicle = nodes.createFollicleOnMesh(mesh)
                        attributes.doSetAttr(follicle[0],'parameterU',uv[0])
                        attributes.doSetAttr(follicle[0],'parameterV',uv[1])
                        try:mc.delete(o)
                        except:pass                        
            else:
                for o in self.createdList:
                    try:mc.delete(o)
                    except:pass
                if self.createMode == 'curve' and len(self.returnList)>1:
                    if len(self.returnList) > 1:
                        self.createdList = [curves.curveFromPosList(self.returnList)]
                    else:
                        guiFactory.warning("Need at least 2 points for a curve")                        
                elif self.createMode == 'jointChain':
                    self.createdList = []
                    mc.select(cl=True)
                    for pos in self.returnList:                             
                        self.createdList.append( mc.joint (p = (pos[0], pos[1], pos[2]),radius = 1) )
                                

        self.reset()
Ejemplo n.º 14
0
    def finalize(self):
        """
        Press action. Clears buffers.
        """
        #Clean our lists...
        self.createdList = lists.returnListNoDuplicates(self.createdList)
        self.returnList = lists.returnListNoDuplicates(self.returnList)
        
        if self.createMode in ['curve','jointChain','group','follicle'] and self.returnList:
            if self.createMode == 'group':
                bufferList = []
                for i,o in enumerate(self.createdList):
                    buffer = rigging.groupMeObject(o,False)
                    bufferList.append(buffer)                    
                    try:mc.delete(o)
                    except:pass
                self.createdList = bufferList
                
            elif self.createMode =='follicle':
                if self.mode == 'midPoint':
                    guiFactory.warning("Mid point mode doesn't work with follicles")
                    return
                bufferList = []
                for o in self.createdList:
                    mesh = attributes.doGetAttr(o,'cgmHitTarget')
                    if mc.objExists(mesh):
                        uv = distance.returnClosestUVToPos(mesh,distance.returnWorldSpacePosition(o))
                        follicle = nodes.createFollicleOnMesh(mesh)
                        attributes.doSetAttr(follicle[0],'parameterU',uv[0])
                        attributes.doSetAttr(follicle[0],'parameterV',uv[1])
                        try:mc.delete(o)
                        except:pass                        
            else:
                for o in self.createdList:
                    try:mc.delete(o)
                    except:pass
                if self.createMode == 'curve' and len(self.returnList)>1:
                    if len(self.returnList) > 1:
                        self.createdList = [mc.curve (d=3, p = self.returnList , ws=True)]
                    else:
                        guiFactory.warning("Need at least 2 points for a curve")                        
                elif self.createMode == 'jointChain':
                    self.createdList = []
                    mc.select(cl=True)
                    for pos in self.returnList:        
                        self.createdList.append( mc.joint (p = (pos[0], pos[1], pos[2])) )
                                

        self.reset()
Ejemplo n.º 15
0
def returnClosestPointOnSurfaceInfo(targetObj, surface):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Returns pertinent info of the closest point of a mesh to a target object -
    position, normal, parameterU,parameterV,closestFaceIndex,closestVertexIndex

    ARGUMENTS:
    targetObj(string)
    mesh(string)

    RETURNS:
    closestPointInfo(dict)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """   
    # make the closest point node #
    closestPointNode = mc.createNode ('closestPointOnSurface')
    pointOnSurfaceNode = mc.createNode ('pointOnSurfaceInfo')
    controlSurface = mc.listRelatives(surface,shapes=True)
        
    #>>>Surface Info
    #Thanks - http://www.kylenikolich.com/scripting/lod/parentToSurface.mel
    f_minU = attributes.doGetAttr(controlSurface[0],'mnu')
    f_maxU = attributes.doGetAttr(controlSurface[0],'mxu')
    f_sizeU = f_maxU - f_minU
    f_minV = attributes.doGetAttr(controlSurface[0],'mnv')
    f_maxV = attributes.doGetAttr(controlSurface[0],'mxv')
    f_sizeV = f_maxV - f_minV    

    # to account for target objects in heirarchies #
    pos = returnWorldSpacePosition(targetObj)
    attributes.doSetAttr(closestPointNode,'inPositionX',pos[0])
    attributes.doSetAttr(closestPointNode,'inPositionY',pos[1])
    attributes.doSetAttr(closestPointNode,'inPositionZ',pos[2])
    
    attributes.doConnectAttr((controlSurface[0]+'.worldSpace'),(closestPointNode+'.inputSurface'))
    # Connect the info node to the surface #
    attributes.doConnectAttr  ((controlSurface[0]+'.local'),(pointOnSurfaceNode+'.inputSurface'))
    # Contect the pos group to the info node#
    attributes.doConnectAttr ((closestPointNode+'.parameterU'),(pointOnSurfaceNode+'.parameterU'))
    attributes.doConnectAttr  ((closestPointNode+'.parameterV'),(pointOnSurfaceNode+'.parameterV'))

    pointInfo = {}
    pointInfo['position']=attributes.doGetAttr(pointOnSurfaceNode,'position')
    pointInfo['normal']=attributes.doGetAttr(pointOnSurfaceNode,'normal')
    pointInfo['parameterU']=mc.getAttr(pointOnSurfaceNode+'.parameterU')
    pointInfo['parameterV']=mc.getAttr(pointOnSurfaceNode+'.parameterV')
    pointInfo['normalizedU'] = (pointInfo['parameterU'] + f_minU)/f_sizeU
    pointInfo['normalizedV'] =  (pointInfo['parameterV'] + f_minV)/f_sizeV  
    pointInfo['tangentU']=mc.getAttr(pointOnSurfaceNode+'.tangentU')
    pointInfo['tangentV']=mc.getAttr(pointOnSurfaceNode+'.tangentV')
    
    mc.delete(closestPointNode)
    mc.delete(pointOnSurfaceNode)
    log.debug(pointInfo)
    return pointInfo
Ejemplo n.º 16
0
    def validateMeshArg(self, mesh=None):
        '''
        Validates a mesh and returns a dict of data
        
        :param mesh: mesh to evaluate
        
        '''
        _mesh = None
        _skin = None
        if mesh is None:
            #if self.d_kws.get('sourceMesh'):
            #log.info("Using stored sourceMesh data")
            #sourceMesh = self.d_kws.get('sourceMesh')
            #else:
            log.info("No source specified, checking if selection found")
            _bfr = mc.ls(sl=True)
            if not _bfr:
                raise ValueError, "No selection found and no source arg"
            mesh = _bfr[0]

        _type = search.returnObjectType(mesh)

        if _type in ['mesh', 'nurbsCurve', 'nurbsSurface']:
            if _type in ['nurbsCurve', 'nurbsSurface']:
                raise NotImplementedError, "Haven't implemented nurbsCurve or nurbsSurface yet"
            log.info("Skinnable object '{0}', checking skin".format(mesh))
            _mesh = mesh
            _skin = skinning.querySkinCluster(_mesh) or False
            if _skin:
                log.info("Found skin '{0}' on '{1}'".format(_skin, _mesh))
        elif _type in ['skinCluster']:
            log.info("skinCluster '{0}' passed...".format(mesh))
            _skin = mesh
            _mesh = attributes.doGetAttr(_skin, 'outputGeometry')[0]
            log.info("Found: {0}".format(_mesh))
        else:
            raise ValueError, "Not a usable mesh type : {0}".format(_type)

        _shape = mc.listRelatives(_mesh, shapes=True, fullPath=False)[0]
        _return = {
            'mesh': _mesh,
            'meshType': _type,
            'shape': _shape,
            'skin': _skin,
            'component': data._geoToComponent.get(_type, False),
            'pointCount': mc.polyEvaluate(_shape, vertex=True)
        }
        return _return
Ejemplo n.º 17
0
 def get(self,*a, **kw):
     """ 
     Get and store attribute value based on attr type
     
     Keyword arguments:
     *a, **kw
     """     
     try:
         if self.form == 'message':
             self.value = attributes.returnMessageObject(self.obj.nameShort,self.attr)
         else:
             self.value =  attributes.doGetAttr(self.obj.nameShort,self.attr)
         #guiFactory.report("'%s.%s' >> '%s'"%(self.obj.nameShort,self.attr,self.value))
         return self.value
     except:
         guiFactory.warning("'%s.%s' failed to get"%(self.obj.nameShort,self.attr))
Ejemplo n.º 18
0
def getModuleFromDict(self,checkDict):
    """
    Pass a check dict of attrsibutes and arguments. If that module is found, it returns it.
    
    checkDict = {'moduleType':'torso',etc}
    """
    assert type(checkDict) is dict,"Arg must be dictionary"
    for i_m in self.moduleChildren:
        matchBuffer = 0
        for key in checkDict.keys():
            if i_m.hasAttr(key) and attributes.doGetAttr(i_m.mNode,key) == checkDict.get(key):
                matchBuffer +=1
        if matchBuffer == len(checkDict.keys()):
            log.debug("Found Morpheus Module: '%s'"%i_m.getShortName())
            return i_m
    return False
Ejemplo n.º 19
0
 def validateMeshArg(self, mesh = None):
     '''
     Validates a mesh and returns a dict of data
     
     :param mesh: mesh to evaluate
     
     '''        
     _mesh = None 
     _skin = None
     if mesh is None:
         #if self.d_kws.get('sourceMesh'):
             #log.info("Using stored sourceMesh data")
             #sourceMesh = self.d_kws.get('sourceMesh')
         #else:
         log.info("No source specified, checking if selection found")
         _bfr = mc.ls(sl=True)
         if not _bfr:raise ValueError,"No selection found and no source arg"
         mesh = _bfr[0]
         
     _type = search.returnObjectType(mesh)
     
     if _type in ['mesh', 'nurbsCurve', 'nurbsSurface']:
         if _type in ['nurbsCurve','nurbsSurface']:
             raise  NotImplementedError, "Haven't implemented nurbsCurve or nurbsSurface yet"
         log.info("Skinnable object '{0}', checking skin".format(mesh))
         _mesh = mesh
         _skin = skinning.querySkinCluster(_mesh) or False
         if _skin:
             log.info("Found skin '{0}' on '{1}'".format(_skin,_mesh))
     elif _type in ['skinCluster']:
         log.info("skinCluster '{0}' passed...".format(mesh))
         _skin = mesh
         _mesh = attributes.doGetAttr(_skin,'outputGeometry')[0]
         log.info("Found: {0}".format(_mesh))
     else:
         raise ValueError,"Not a usable mesh type : {0}".format(_type)
     
     _shape = mc.listRelatives(_mesh,shapes=True,fullPath=False)[0]
     _return = {'mesh':_mesh,
                'meshType':_type,
                'shape':_shape,
                'skin':_skin,
                'component':data._geoToComponent.get(_type, False),
                'pointCount':mc.polyEvaluate(_shape, vertex=True)
                }
     return _return  
Ejemplo n.º 20
0
def getModuleFromDict(self, checkDict):
    """
    Pass a check dict of attrsibutes and arguments. If that module is found, it returns it.
    
    checkDict = {'moduleType':'torso',etc}
    """
    assert type(checkDict) is dict, "Arg must be dictionary"
    for i_m in self.moduleChildren:
        matchBuffer = 0
        for key in checkDict.keys():
            if i_m.hasAttr(key) and attributes.doGetAttr(
                    i_m.mNode, key) == checkDict.get(key):
                matchBuffer += 1
        if matchBuffer == len(checkDict.keys()):
            log.debug("Found Morpheus Module: '%s'" % i_m.getShortName())
            return i_m
    return False
Ejemplo n.º 21
0
 def get(self, *a, **kw):
     """ 
     Get and store attribute value based on attr type
     
     Keyword arguments:
     *a, **kw
     """
     try:
         if self.form == 'message':
             self.value = attributes.returnMessageObject(
                 self.obj.nameShort, self.attr)
         else:
             self.value = attributes.doGetAttr(self.obj.nameShort,
                                               self.attr)
         #guiFactory.report("'%s.%s' >> '%s'"%(self.obj.nameShort,self.attr,self.value))
         return self.value
     except:
         guiFactory.warning("'%s.%s' failed to get" %
                            (self.obj.nameShort, self.attr))
Ejemplo n.º 22
0
    def doTemplate(self,PuppetInstance):       
        """
        
        """
        def makeLimbTemplate (self):
            #>>>Curve degree finder
            if self.optionCurveDegree.get() == 0:
                doCurveDegree = 1
            else:
                if len(corePositionList) <= 3:
                    doCurveDegree = 1
                else:
                    doCurveDegree = len(corePositionList) - 1
                    
            #Make some storage vehicles
            self.templatePosObjectsBuffer = BufferFactory(self.infoNulls['templatePosObjects'].get())
            self.templatePosObjectsBuffer.purge()
            
            LocatorCatcher = ObjectFactory('')
            LocatorBuffer = BufferFactory(LocatorCatcher.nameLong)
            LocatorBuffer.purge()
            
            returnList = []
            self.templHandleList = []
            
            moduleColors = modules.returnModuleColors(self.ModuleNull.nameShort)
            
            #>>>Scale stuff
            moduleParent = self.msgModuleParent.get()
            
            if not moduleParent:
                length = (distance.returnDistanceBetweenPoints (corePositionList[0],corePositionList[-1]))
                size = length / self.optionHandles.get()
            else:
                #>>>>>>>>>>>>>>>>>>>>> NOT TOUCHED YET
                parentTemplatePosObjectsInfoNull = modules.returnInfoTypeNull(moduleParent,'templatePosObjects')
                parentTemplatePosObjectsInfoData = attributes.returnUserAttrsToDict (parentTemplatePosObjectsInfoNull)
                parentTemplateObjects = []
                for key in parentTemplatePosObjectsInfoData.keys():
                    if (mc.attributeQuery (key,node=parentTemplatePosObjectsInfoNull,msg=True)) == True:
                        if search.returnTagInfo((parentTemplatePosObjectsInfoData[key]),'cgmType') != 'templateCurve':
                            parentTemplateObjects.append (parentTemplatePosObjectsInfoData[key])
                createBuffer = curves.createControlCurve('sphere',1)
                pos = corePositionList[0]
                mc.move (pos[0], pos[1], pos[2], createBuffer, a=True)
                closestParentObject = distance.returnClosestObject(createBuffer,parentTemplateObjects)
                boundingBoxSize = distance.returnBoundingBoxSize (closestParentObject)
                maxSize = max(boundingBoxSize)
                size = maxSize *.25
                mc.delete(createBuffer)
                if partType == 'clavicle':
                    size = size * .5
                elif partType == 'head':
                    size = size * .75
                if (search.returnTagInfo(moduleParent,'cgmModuleType')) == 'clavicle':
                    size = size * 2
        
            #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
            # Making the template objects
            #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
            self.TemplateObject = {}
            
            #>>> Template objects
            for cnt,pos in enumerate(corePositionList):
                #Size multiplier based on PuppetMode, make it take into account module mode eventually
                if PuppetInstance.optionPuppetMode.get() == 0:
                    if cnt == 0:
                        sizeMultiplier = 1
                    elif cnt == len(corePositionList) -1:
                        sizeMultiplier = .8
                    else:
                        sizeMultiplier = .5
                else:
                    sizeMultiplier = 1
                    
                #make a sphere and move it
                createBuffer = curves.createControlCurve('sphere',(size * sizeMultiplier))
                self.TemplateObject[cnt] = ObjectFactory(createBuffer) # Instance the control to our module
                obj = self.TemplateObject[cnt]
                curves.setCurveColorByName(obj.nameLong,moduleColors[0])
                obj.store('cgmName',coreNames[cnt])
                
                obj.getNameTagsFromObject(self.ModuleNull.nameLong,['cgmName','cgmType'])

                obj.store('cgmType','templateObject')
                obj.doName()
                mc.move (pos[0], pos[1], pos[2], [obj.nameLong], a=True)
                            
                #adds it to the list
                self.templHandleList.append (obj.nameLong) 
                self.templatePosObjectsBuffer.store(obj.nameLong)
            
             
            #Aim the objects           
            position.aimObjects(self.templHandleList,
                                dictionary.axisDirectionsByString[ self.optionAimAxis.get() ],
                                dictionary.axisDirectionsByString[ self.optionUpAxis.get() ],
                                dictionary.axisDirectionsByString[ PuppetInstance.optionUpAxis.get() ])            
            
            #>>> Template curve
            crvName = mc.curve (d=doCurveDegree, p = corePositionList , os=True, n=('%s_%s' %(partName,(typesDictionary.get('templateCurve')))))            
            self.afTemplateCurve = AttrFactory(self.infoNulls['templatePosObjects'].get(),
                                               'curve','message', value=crvName)# connect it back to our template objects info null
            
            curve = ObjectFactory(crvName) # instance it
            curve.getNameTagsFromObject(self.ModuleNull.nameLong,['cgmType']) #get name tags from the module

            attributes.storeInfo(crvName,'cgmType','templateCurve') # store type
            curves.setCurveColorByName(crvName,moduleColors[1]) # set curve color
            
            # Make locators to connect the cv's to
            for cnt,obj in enumerate(self.templHandleList):
                pointLoc = locators.locMeObject(obj) # make the loc
                loc = ObjectFactory(pointLoc) #instance it
                mc.setAttr ((loc.nameShort+'.visibility'),0) # turn off visibility
                mc.parentConstraint ([obj],[loc.nameShort],mo=False) # parent constrain
                mc.connectAttr ( (loc.nameShort+'.translate'),
                                 ('%s.controlPoints[%i]' % (crvName, cnt)), f=True ) # connect the cv to the loc
                self.TemplateObject[cnt].store('loc',loc.nameLong)
                LocatorBuffer.store(loc.nameLong)
                
            #>>> Direction and size Stuff
            """
            # Directional data derived from joints 
            generalDirection = logic.returnHorizontalOrVertical(self.templHandleList)
            if generalDirection == 'vertical' and 'leg' not in self.afModuleType.get():
                worldUpVector = [0,0,-1]
            elif generalDirection == 'vertical' and 'leg' in self.afModuleType.get():
                worldUpVector = [0,0,1]
            else:
                worldUpVector = [0,1,0]
            """            
            
            # Create root control
            templateNull = self.msgTemplateNull.get()
            handleList = copy.copy(self.templatePosObjectsBuffer.bufferList)
            
            rootSize = (distance.returnBoundingBoxSizeToAverage(self.templHandleList[0])*1.5)
            rootCtrl = ObjectFactory(curves.createControlCurve('cube',rootSize))
            rootCtrl.getNameTagsFromObject(self.ModuleNull.nameLong)
            self.msgTemplateRoot = AttrFactory(self.infoNulls['templatePosObjects'].get(), 'root', 'message', value = rootCtrl.nameLong)
            curves.setCurveColorByName(rootCtrl.nameLong,moduleColors[0])
            
            # move the root
            if self.afModuleType.get() == 'clavicle':
                position.movePointSnap(rootCtrl.nameLong,self.templHandleList[0])
            else:
                position.movePointSnap(rootCtrl.nameLong,self.templHandleList[0])
            # aim the root
            position.aimSnap(rootCtrl.nameShort,self.templHandleList[-1],  
                            dictionary.axisDirectionsByString[ self.optionAimAxis.get() ],
                            dictionary.axisDirectionsByString[ self.optionUpAxis.get() ],
                            dictionary.axisDirectionsByString[ PuppetInstance.optionUpAxis.get() ]) 
            
            rootCtrl.store('cgmType','templateRoot')
            rootCtrl.doName()
            
            #>>> Parent the main objcts
            rootGroup = rootCtrl.doGroup()
            rootGroup = rigging.doParentReturnName(rootGroup,templateNull)
            curve.doParent(templateNull)
            
            for obj in LocatorBuffer.bufferList:
                rigging.doParentReturnName(obj,templateNull)
            mc.delete(LocatorCatcher.nameShort) # delete the locator buffer obj
            
            #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
            #>> Orientation helpers
            #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
            # Make our Orientation Helpers 
            """
            orientHelpersReturn = template.addOrientationHelpers(self)
            masterOrient = orientHelpersReturn[0]
            orientObjects = orientHelpersReturn[1]
            return
            
        
            #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
            #>> Control helpers
            #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
            print orientObjects
            print self.ModuleNull.nameShort
            print (templateNull+'.visControlHelpers')
            controlHelpersReturn = addControlHelpers(orientObjects,self.ModuleNull.nameShort,(templateNull+'.visControlHelpers'))"""
    
            #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
            #>> Input the saved values if there are any
            #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
            # Orientation Helpers 
            """rotBuffer = coreRotationList[-1]
            #actualName = mc.spaceLocator (n= wantedName)
            rotCheck = sum(rotBuffer)
            if rotCheck != 0:
                mc.rotate(rotBuffer[0],rotBuffer[1],rotBuffer[2],masterOrient,os=True)
            
            cnt = 0
            for obj in orientObjects:
                rotBuffer = coreRotationList[cnt]
                rotCheck = sum(rotBuffer)
                if rotCheck != 0:
                    mc.rotate(rotBuffer[0],rotBuffer[1],rotBuffer[2],obj,os=True)
                cnt +=1 
                    
            # Control Helpers 
            controlHelpers = controlHelpersReturn[0]
            cnt = 0
            for obj in controlHelpers:
                posBuffer = controlPositionList[cnt]
                posCheck = sum(posBuffer)
                if posCheck != 0:
                    mc.xform(obj,t=[posBuffer[0],posBuffer[1],posBuffer[2]],ws=True)
                
                rotBuffer = controlRotationList[cnt]
                rotCheck = sum(rotBuffer)
                if rotCheck != 0:
                    mc.rotate(rotBuffer[0],rotBuffer[1],rotBuffer[2],obj,ws=True)
                
                scaleBuffer = controlScaleList[cnt]
                scaleCheck = sum(scaleBuffer)
                if scaleCheck != 0:
                    mc.scale(scaleBuffer[0],scaleBuffer[1],scaleBuffer[2],obj,absolute=True)
                cnt +=1 """
            
            #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
            #>> Final stuff
            #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
            """
            returnList.append(templObjNameList)
            returnList.append(self.templHandleList)
            returnList.append(rootCtrl)"""
            return True	



        # Start objects stuff 
        partName = NameFactory.returnRawGeneratedName(self.ModuleNull.nameShort,ignore=['cgmType','cgmTypeModifier'])
        templateStarterDataInfoNull = self.infoNulls['templateStarterData'].value
        initialObjectsPosData = mc.listAttr(templateStarterDataInfoNull,userDefined=True)
        corePositionList = []
        coreRotationList = []
        corePositionDict = {}
        coreRotationDict = {}        
        for a in initialObjectsPosData:
            buffer = attributes.doGetAttr(templateStarterDataInfoNull,a)                            
            if 'cgm' not in a and type(buffer) is list:
                if 'pos' in a:
                    split = a.split('pos_')
                    corePositionDict[int(split[1])] =  buffer[0]
                    corePositionList.append(buffer[0])
                elif 'rot' in a:
                    split = a.split('rot_')
                    coreRotationDict[int(split[1])] =  buffer[0] 
                    coreRotationList.append(buffer[0])
   
        print corePositionList
        print coreRotationList
        
        # template control objects stuff #
        templateControlObjectsDataNull = self.infoNulls['templateControlObjects'].value
        templateControlObjectsData = mc.listAttr(templateControlObjectsDataNull,userDefined=True)
        controlPositionList = []
        controlRotationList = []
        controlScaleList = []
        controlPositionDict = {}
        controlRotationDict = {}
        controlScaleDict = {}
        
        for a in templateControlObjectsData:
            buffer = attributes.doGetAttr(templateControlObjectsDataNull,a)                            
            if 'cgm' not in a and type(buffer) is list:
                if 'pos' in a:
                    split = a.split('pos_')
                    controlPositionDict[int(split[1])] =  buffer[0] 
                    controlPositionList.append(buffer[0])                    
                elif 'rot' in a:
                    split = a.split('rot_')
                    controlRotationDict[int(split[1])] =  buffer[0] 
                    controlRotationList.append(buffer[0])
                elif 'scale' in a:
                    split = a.split('scale_')
                    controlScaleDict[int(split[1])] =  buffer[0]   
                    controlScaleList.append(buffer[0])
                    
                  
        print controlPositionList
        print controlRotationList
        print controlScaleList
        
        # Names Info #
        coreNamesInfoNull = self.infoNulls['coreNames'].value
        coreNamesBuffer = mc.listAttr(coreNamesInfoNull,userDefined=True)
        coreNames = {}
        for a in coreNamesBuffer:
            if 'cgm' not in a and 'name_' in a:
                split = a.split('name_')
                coreNames[int(split[1])] =  attributes.doGetAttr(coreNamesInfoNull,a) 
                
        print coreNames            
        print ('%s data aquired...'%self.ModuleNull.nameShort)
        
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        #>> make template objects
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
        #makes template objects#
        assert len(corePositionList) == self.optionHandles.get(),"There isn't enough data to template. Needs to be sized"
        
        templateObjects = makeLimbTemplate(self)
        guiFactory.report( 'Template Limb made....')
        
        
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        #>> Parent objects
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
        for cnt,obj in enumerate(self.templHandleList): 
            self.TemplateObject[cnt].doParent(self.msgTemplateNull.get())
    
        guiFactory.report('Template objects parented')
        
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        #>> Transform groups and Handles...handling
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        self.templatePosObjectsBuffer.updateData()
        root = self.msgTemplateRoot.get()
        handles = copy.copy( self.templatePosObjectsBuffer.bufferList )
        stiffIndex = self.optionStiffIndex.get()
        
        """ Don't remember why I did this stiff index thing....
        #>>> Break up the handles into the sets we need 
        if stiffIndex == 0:
            splitHandles = False
            handlesToSplit = handles
            handlesRemaining = [handles[0],handles[-1]]
        elif stiffIndex < 0:
            splitHandles = True
            handlesToSplit = handles[:stiffIndex]
            handlesRemaining = handles[stiffIndex:]
            handlesRemaining.append(handles[0])
        elif stiffIndex > 0:
            splitHandles = True
            handlesToSplit = handles[stiffIndex:]
            handlesRemaining = handles[:stiffIndex]
            handlesRemaining.append(handles[-1]) 
        if len(handlesToSplit)>2:"""
        
        # makes our mid transform groups#
        if len(handles)>2:
            constraintGroups = constraints.doLimbSegmentListParentConstraint(handles)
            print 'Constraint groups created...'
            for group in constraintGroups:
                mc.parent(group,root)
            
        # zero out the first and last#
        for handle in [handles[0],handles[-1]]:
            groupBuffer = (rigging.groupMeObject(handle,maintainParent=True))
            mc.parent(groupBuffer,root)
           
        #>>> Break up the handles into the sets we need 
        if stiffIndex < 0:
            for handle in handles[(stiffIndex+-1):-1]:
                groupBuffer = (rigging.groupMeObject(handle,maintainParent=True))
                mc.parent(groupBuffer,handles[-1])
        elif stiffIndex > 0:
            for handle in handles[1:(stiffIndex+1)]:
                groupBuffer = (rigging.groupMeObject(handle,maintainParent=True))
                mc.parent(groupBuffer,handles[0])
                
        print 'Constraint groups parented...'
        
        #>>> Lock off handles
        self.templatePosObjectsBuffer.updateData()
        for obj in self.templatePosObjectsBuffer.bufferList:
            attributes.doSetLockHideKeyableAttr(obj,True,False,False,['sx','sy','sz','v'])
            
        
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        # Parenting constraining parts
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        """ COME BACK AFTER DONE WITH SEGMENT
        if self.moduleParent:
            if self.afModuleType.get() == 'clavicle':
                self.moduleParent = attributes.returnMessageObject(self.moduleParent,'self.moduleParent')
            parentTemplatePosObjectsInfoNull = modules.returnInfoTypeNull(self.moduleParent,'templatePosObjects')
            parentTemplatePosObjectsInfoData = attributes.returnUserAttrsToDict (parentTemplatePosObjectsInfoNull)
            parentTemplateObjects = []
            for key in parentTemplatePosObjectsInfoData.keys():
                if (mc.attributeQuery (key,node=parentTemplatePosObjectsInfoNull,msg=True)) == True:
                    if search.returnTagInfo((parentTemplatePosObjectsInfoData[key]),'cgmType') != 'templateCurve':
                        parentTemplateObjects.append (parentTemplatePosObjectsInfoData[key])
            closestParentObject = distance.returnClosestObject(rootName,parentTemplateObjects)
            if (search.returnTagInfo(self.ModuleNull.nameShort,'cgmModuleType')) != 'foot':
                constraintGroup = rigging.groupMeObject(rootName,maintainParent=True)
                constraintGroup = NameFactory.doNameObject(constraintGroup)
                mc.pointConstraint(closestParentObject,constraintGroup, maintainOffset=True)
                mc.scaleConstraint(closestParentObject,constraintGroup, maintainOffset=True)
            else:
                constraintGroup = rigging.groupMeObject(closestParentObject,maintainParent=True)
                constraintGroup = NameFactory.doNameObject(constraintGroup)
                mc.parentConstraint(rootName,constraintGroup, maintainOffset=True)
                
        # grab the last clavicle piece if the arm has one and connect it to the arm  #
        if self.moduleParent:
            if (search.returnTagInfo(self.ModuleNull.nameShort,'cgmModuleType')) == 'arm':
                if (search.returnTagInfo(self.moduleParent,'cgmModuleType')) == 'clavicle':
                    print '>>>>>>>>>>>>>>>>>>>>> YOU FOUND ME'
                    parentTemplatePosObjectsInfoNull = modules.returnInfoTypeNull(self.moduleParent,'templatePosObjects')
                    parentTemplatePosObjectsInfoData = attributes.returnUserAttrsToDict (parentTemplatePosObjectsInfoNull)
                    parentTemplateObjects = []
                    for key in parentTemplatePosObjectsInfoData.keys():
                        if (mc.attributeQuery (key,node=parentTemplatePosObjectsInfoNull,msg=True)) == True:
                            if search.returnTagInfo((parentTemplatePosObjectsInfoData[key]),'cgmType') != 'templateCurve':
                                parentTemplateObjects.append (parentTemplatePosObjectsInfoData[key])
                    closestParentObject = distance.returnClosestObject(rootName,parentTemplateObjects)
                    endConstraintGroup = rigging.groupMeObject(closestParentObject,maintainParent=True)
                    endConstraintGroup = NameFactory.doNameObject(endConstraintGroup)
                    mc.pointConstraint(handles[0],endConstraintGroup, maintainOffset=True)
                    mc.scaleConstraint(handles[0],endConstraintGroup, maintainOffset=True)
        """    
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        #>> Final stuff
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
        
        #>>> Set our new module rig process state
        self.afTemplateState.set(1)
        print ('%s done!'%self.ModuleNull.nameShort)
        
        #>>> Tag our objects for easy deletion
        children = mc.listRelatives (self.msgTemplateNull.get(), allDescendents = True,type='transform')
        for obj in children:
            attributes.storeInfo(obj,'cgmOwnedBy',self.msgTemplateNull.get())
            
        #>>> Visibility Connection
        """
Ejemplo n.º 23
0
    def initialize(self):
        """ 
        Verifies the various components a masterNull for a character/asset. If a piece is missing it replaces it.
        
        RETURNS:
        success(bool)
        """
        #Puppet null
        if not attributes.doGetAttr(self.PuppetNull.nameShort, 'cgmName'):
            return False
        if attributes.doGetAttr(self.PuppetNull.nameShort,
                                'cgmType') != 'ignore':
            return False
        if attributes.doGetAttr(self.PuppetNull.nameShort,
                                'cgmModuleType') != 'master':
            return False

        self.msgModulesGroup = AttrFactory(self.PuppetNull, 'modulesGroup')
        if not self.msgModulesGroup.get():
            guiFactory.warning(
                "'%s' looks to be missing. Go back to unreferenced file" %
                self.msgModulesGroup.attr)
            return False
        else:
            self.ModulesGroup = ObjectFactory(self.msgModulesGroup.get())

        self.msgNoTransformGroup = AttrFactory(self.PuppetNull,
                                               'noTransformGroup')
        if not self.msgNoTransformGroup.get():
            guiFactory.warning(
                "'%s' looks to be missing. Go back to unreferenced file" %
                self.msgNoTransformGroup.attr)
            return False
        else:
            self.NoTransformGroup = ObjectFactory(
                self.msgNoTransformGroup.get())

        self.msgGeoGroup = AttrFactory(self.PuppetNull, 'geoGroup')
        if not self.msgGeoGroup.get():
            guiFactory.warning(
                "'%s' looks to be missing. Go back to unreferenced file" %
                self.msgGeoGroup.attr)
            return False
        else:
            self.GeoGroup = ObjectFactory(self.msgGeoGroup.get())

        self.msgPuppetInfo = AttrFactory(self.PuppetNull, 'info')
        if not self.msgPuppetInfo.get():
            guiFactory.warning(
                "'%s' looks to be missing. Go back to unreferenced file" %
                self.msgPuppetInfo.attr)
            return False

        else:
            self.PuppetInfoNull = ObjectFactory(self.msgPuppetInfo.get())
            self.msgModuleInfo = AttrFactory(self.PuppetInfoNull, 'modules')
            if not self.msgModuleInfo.get():
                guiFactory.warning(
                    "'%s' looks to be missing. Go back to unreferenced file" %
                    self.msgModuleInfo.attr)
                return False
            else:
                #Initialize our modules null as a buffer
                self.ModuleInfoNull = ObjectFactory(self.msgModuleInfo.get())
                self.ModulesBuffer = BufferFactory(self.msgModuleInfo.get())

            self.msgGeoInfo = AttrFactory(self.PuppetInfoNull, 'geo')
            if not self.msgGeoInfo.get():
                guiFactory.warning(
                    "'%s' looks to be missing. Go back to unreferenced file" %
                    self.msgGeoInfo.attr)
                return False
            else:
                self.GeoInfoNull = ObjectFactory(self.msgGeoInfo.get())

            self.msgSettingsInfo = AttrFactory(self.PuppetInfoNull, 'settings')
            if not self.msgSettingsInfo.get():
                guiFactory.warning(
                    "'%s' looks to be missing. Go back to unreferenced file" %
                    self.msgSettingsInfo.attr)
                return False
            else:
                self.SettingsInfoNull = ObjectFactory(
                    self.msgSettingsInfo.get(), )

                self.optionPuppetMode = AttrFactory(
                    self.SettingsInfoNull, 'optionPuppetTemplateMode')
                self.optionAimAxis = AttrFactory(self.SettingsInfoNull,
                                                 'axisAim')
                self.optionUpAxis = AttrFactory(self.SettingsInfoNull,
                                                'axisUp')
                self.optionOutAxis = AttrFactory(self.SettingsInfoNull,
                                                 'axisOut')

        return True