def updateTemplate(i_customizationNetwork,**kws):  
    assert i_customizationNetwork.mClass == 'cgmMorpheusMakerNetwork', "Not a customization Network"
    assert i_customizationNetwork.mPuppet.mClass == 'cgmMorpheusPuppet',"Puppet isn't there"
    
    d_customizationData = verify_customizationData(i_customizationNetwork)
    i_Morpheus = i_customizationNetwork.mPuppet
    
    if not d_customizationData:
        return False
    
    mayaMainProgressBar = gui.doStartMayaProgressBar(len(l_modulesToDoOrder))
    
    for moduleKey in l_modulesToDoOrder:
        if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True ) :
            break
        mc.progressBar(mayaMainProgressBar, edit=True, status = "Setting:'%s'..."%(moduleKey), step=1)
        
        i_module = i_Morpheus.getModuleFromDict(d_moduleCheck[moduleKey])
        if not i_module:
            log.warning("Cannot find Module: '%s'"%moduleKey)
            return False
        log.debug("Building: '%s'"%moduleKey)
        i_module.doSize(sizeMode = 'manual',
                        posList = d_customizationData.get(moduleKey))
        i_module.doTemplate(tryTemplateUpdate = True,
                            **kws)        
    gui.doEndMayaProgressBar(mayaMainProgressBar)#Close out this progress bar    
        
def updateTemplate(i_customizationNetwork, **kws):
    assert i_customizationNetwork.mClass == 'cgmMorpheusMakerNetwork', "Not a customization Network"
    assert i_customizationNetwork.mPuppet.mClass == 'cgmMorpheusPuppet', "Puppet isn't there"

    d_customizationData = verify_customizationData(i_customizationNetwork)
    i_Morpheus = i_customizationNetwork.mPuppet

    if not d_customizationData:
        return False

    mayaMainProgressBar = gui.doStartMayaProgressBar(len(l_modulesToDoOrder))

    for moduleKey in l_modulesToDoOrder:
        if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True):
            break
        mc.progressBar(mayaMainProgressBar,
                       edit=True,
                       status="Setting:'%s'..." % (moduleKey),
                       step=1)

        i_module = i_Morpheus.getModuleFromDict(d_moduleCheck[moduleKey])
        if not i_module:
            log.warning("Cannot find Module: '%s'" % moduleKey)
            return False
        log.debug("Building: '%s'" % moduleKey)
        i_module.doSize(sizeMode='manual',
                        posList=d_customizationData.get(moduleKey))
        i_module.doTemplate(tryTemplateUpdate=True, **kws)
    gui.doEndMayaProgressBar(mayaMainProgressBar)  #Close out this progress bar
Пример #3
0
    def bakeTempLocator(self, startTime=None, endTime=None):
        _str_func = 'PostBake.bakeTempLocator'

        if startTime is None:
            startTime = self.startTime
        if endTime is None:
            endTime = self.endTime

        ct = mc.currentTime(q=True)

        self._bakedLoc = cgmMeta.asMeta(LOC.create(name='bakeLoc'))
        self._bakedLoc.rotateOrder = self.obj.rotateOrder

        SNAP.matchTarget_set(self._bakedLoc.mNode, self.obj.mNode)

        _len = endTime - startTime
        _progressBar = cgmUI.doStartMayaProgressBar(_len, "Processing...")

        _obj = VALID.objString(self._bakedLoc.mNode, noneValid=False)
        _target = VALID.objString(
            self.obj.mNode, noneValid=False
        )  #ATTR.get_message(_obj, 'cgmMatchTarget','cgmMatchDat',0)

        ak = mc.autoKeyframe(q=True, state=True)
        mc.autoKeyframe(state=False)
        mc.refresh(su=True)

        completed = True

        for i in range(startTime, endTime + 1):
            mc.currentTime(i)
            SNAP.go(_obj, _target, True, True, pivot='rp')
            mc.setKeyframe(_obj, at=['translate', 'rotate'])

            if _progressBar:
                if mc.progressBar(_progressBar, query=True, isCancelled=True):
                    log.warning('Bake cancelled!')
                    completed = False
                    break

                mc.progressBar(_progressBar,
                               edit=True,
                               status=("{0} On frame {1}".format(_str_func,
                                                                 i)),
                               step=1,
                               maxValue=_len)

        mc.refresh(su=False)
        mc.autoKeyframe(state=ak)

        cgmUI.doEndMayaProgressBar(_progressBar)

        mc.currentTime(ct)

        return completed
def setState(i_customizationNetwork, state=False, **kws):
    """"
    Returns a defined Morpheus asset
    
    What is a morpheus asset
    """
    assert i_customizationNetwork.mClass == 'cgmMorpheusMakerNetwork', "Not a customization Network"
    assert i_customizationNetwork.mPuppet.mClass == 'cgmMorpheusPuppet', "Puppet isn't there"

    #>>>Kw defaults
    rebuildFrom = kws.get('rebuildFrom') or None
    forceNew = kws.get('forceNew') or False
    tryTemplateUpdate = kws.get('tryTemplateUpdate') or True
    loadTemplatePose = kws.get('loadTemplatePose') or True

    i_Morpheus = i_customizationNetwork.mPuppet
    d_customizationData = verify_customizationData(i_customizationNetwork)

    if not d_customizationData:
        return False

    mayaMainProgressBar = gui.doStartMayaProgressBar(len(l_modulesToDoOrder))

    for moduleKey in l_modulesToDoOrder:
        if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True):
            break
        mc.progressBar(mayaMainProgressBar,
                       edit=True,
                       status="Setting:'%s'..." % (moduleKey),
                       step=1)

        i_module = i_Morpheus.getModuleFromDict(d_moduleCheck[moduleKey])
        if not i_module:
            log.warning("Cannot find Module: '%s'" % moduleKey)
            return False
        log.debug("Building: '%s'" % moduleKey)
        i_module.setState(state,
                          sizeMode='manual',
                          posList=d_customizationData.get(moduleKey),
                          **kws)
        #i_module.doSize('manual', posList = d_customizationData.get(moduleKey))
        #i_module.doTemplate()
    gui.doEndMayaProgressBar(mayaMainProgressBar)  #Close out this progress bar
def setState(i_customizationNetwork,state = False,
             **kws):
    """"
    Returns a defined Morpheus asset
    
    What is a morpheus asset
    """ 
    assert i_customizationNetwork.mClass == 'cgmMorpheusMakerNetwork', "Not a customization Network"
    assert i_customizationNetwork.mPuppet.mClass == 'cgmMorpheusPuppet',"Puppet isn't there"
    
    #>>>Kw defaults
    rebuildFrom = kws.get('rebuildFrom') or None
    forceNew =  kws.get('forceNew') or False
    tryTemplateUpdate = kws.get('tryTemplateUpdate') or True
    loadTemplatePose = kws.get('loadTemplatePose') or True
    
    i_Morpheus = i_customizationNetwork.mPuppet
    d_customizationData = verify_customizationData(i_customizationNetwork)
    
    if not d_customizationData:
        return False
    
    mayaMainProgressBar = gui.doStartMayaProgressBar(len(l_modulesToDoOrder))
    
    for moduleKey in l_modulesToDoOrder:
        if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True ) :
            break
        mc.progressBar(mayaMainProgressBar, edit=True, status = "Setting:'%s'..."%(moduleKey), step=1)
        
        
        i_module = i_Morpheus.getModuleFromDict(d_moduleCheck[moduleKey])
        if not i_module:
            log.warning("Cannot find Module: '%s'"%moduleKey)
            return False
        log.debug("Building: '%s'"%moduleKey)
        i_module.setState(state,
                          sizeMode = 'manual',
                          posList = d_customizationData.get(moduleKey),
                          **kws)
        #i_module.doSize('manual', posList = d_customizationData.get(moduleKey))
        #i_module.doTemplate()
    gui.doEndMayaProgressBar(mayaMainProgressBar)#Close out this progress bar    
Пример #6
0
def patch_templateToForm():
    try:
        _str_func = 'patch_templateToForm'
        log.debug(cgmGEN.logString_start(_str_func))
        _l = mc.ls()
        _progressBar = CGMUI.doStartMayaProgressBar(stepMaxValue=len(_l))

        for i, o in enumerate(_l):
            _str = "{0} | {1} ".format(i, o)
            log.debug(cgmGEN.logString_sub(_str_func, _str))
            CGMUI.progressBar_set(_progressBar, step=1, status=_str)
            mObj = cgmMeta.asMeta(o)
            for a in mc.listAttr(o, ud=True) or []:
                log.debug(cgmGEN.logString_msg(_str_func, str(a)))
                if 'template' in a:
                    log.info(
                        cgmGEN.logString_msg(
                            _str_func,
                            "{0} | {1} | template in".format(_str, a)))
                    ATTR.rename(o, a, a.replace('template', 'form'))
                elif 'Template' in a:
                    log.info(
                        cgmGEN.logString_msg(
                            _str_func,
                            "{0} | {1} | Template in".format(_str, a)))
                    ATTR.rename(o, a, a.replace('Template', 'Form'))
                v = ATTR.get(o, a)
                if 'template' == str(v):
                    log.info(
                        cgmGEN.logString_msg(
                            _str_func,
                            "{0} | {1} | template value".format(_str, str(a))))
                    ATTR.set(o, a, 'form')

    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Пример #7
0
    def doMove(self,**kws):
	if kws:log.debug("Snap.doMove>>> kws: %s"%kws)
	if len(self.l_targets) == 1:
	    #>>> Check our target	    
	    i_target = cgmMeta.cgmNode( self.l_targets[0] )
	    log.debug("i_target: %s"%i_target)
	    targetType = i_target.getMayaType()	    

	    if self.b_snapComponents:
		components = self.i_obj.getComponents()
		if not components:raise StandardError,"This objects has no components to snap: '%s'"%self.i_obj.getShortName()
		#>>>Progress bar
		mayaMainProgressBar = gui.doStartMayaProgressBar(len(components))		
		for c in components:
		    if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True ) :
			break
		    mc.progressBar(mayaMainProgressBar, edit=True, status = ("Wrapping '%s'"%c), step=1)
		    
		    if targetType in ['mesh','nurbsSurface','nurbsCurve']:
			pos = distance.returnWorldSpacePosition(c)
			targetLoc = mc.spaceLocator()
			mc.move (pos[0],pos[1],pos[2], targetLoc[0])

			closestLoc = locators.locClosest([targetLoc[0]],i_target.mNode)
			if self._posOffset:
			    self.doOrientObjToSurface(i_target.mNode,closestLoc)
			    mc.move (self._posOffset[0],self._posOffset[1],self._posOffset[2], [closestLoc], r=True, rpr = True, os = True, wd = True)								
			position.movePointSnap(c,closestLoc)
			mc.delete([targetLoc[0],closestLoc])
			
		gui.doEndMayaProgressBar(mayaMainProgressBar)#Close out this progress bar    
		
	    else:
		pos = False
		if self.b_snaptoSurface:#>>> If our target is surface we can use
		    if targetType in ['mesh','nurbsCurve','nurbsSurface']:
			i_locObj = self.i_obj.doLoc()#Get our position loc
			i_locTarget = cgmMeta.cgmObject( locators.locClosest([i_locObj.mNode],i_target.mNode) )#Loc closest
			#i_locObj.rename('objLoc')
			#i_locTarget.rename('targetLoc')
			if self._posOffset:
			    try:
				self.doOrientObjToSurface(i_target.mNode,i_locTarget.mNode)
				mc.move (self._posOffset[0],self._posOffset[1],self._posOffset[2], [i_locTarget.mNode], r=True, rpr = True, os = True, wd = True)								
			    except StandardError,error:
				log.warn("self._posOffset failure!")
				log.error(error)
			
			pos = i_locTarget.getPosition(True)
			i_locObj.delete()
			i_locTarget.delete()
		elif self.b_midSurfacePos:
		    log.debug("Snap.move>>> midSurfacePos mode!")
		    if targetType not in ['mesh','nurbsCurve','nurbsSurface']:
			log.warning("Can't do midSurfacPos on targetType: '%s'"%targetType)
			return False
		    #Get the axis info
		    axisToCheck = kws.pop('axisToCheck',False)
		    if not axisToCheck:
			axisToCheck = []		    
			up = dictionary.returnVectorToString(self._upVector) or False
			if not up:
			    raise StandardError,"SnapFactory>>> must have up vector for midSurfaceSnap: %s"%self._upVector
			for a in ['x','y','z']:
			    if a != up[0]:
				axisToCheck.append(a)
			if not axisToCheck:
			    raise StandardError,"SnapFactory>>> couldn't find any axis to do"
		    #i_locObj = self.i_obj.doLoc()#Get our position loc		
		    #log.debug(axisToCheck)
		    pos = RayCast.findMeshMidPointFromObject(i_target.mNode, self.i_obj.mNode, axisToCheck=axisToCheck,**kws)
		    #i_locObj.delete()
		    
		else:
		    pos = i_target.getPosition(True)	    
		if pos:
		    if self.i_obj.isComponent():
			if self.b_softSelection:#Only need to do this if soft select is on
			    mc.softSelect(softSelectEnabled = True)
			    mc.select(self.i_obj.getComponent())
			    mc.move (pos[0],pos[1],pos[2],rpr=True)
			    mc.select(cl=True)
			else:
			    mc.move (pos[0],pos[1],pos[2], self.i_obj.getComponent())	    		    
		    else:
			mc.move (pos[0],pos[1],pos[2], self.i_obj.mNode, rpr=True)	    
Пример #8
0
    def doMove(self, **kws):
        if kws: log.debug("Snap.doMove>>> kws: %s" % kws)
        if len(self.l_targets) == 1:
            #>>> Check our target
            i_target = cgmMeta.cgmNode(self.l_targets[0])
            log.debug("i_target: %s" % i_target)
            targetType = i_target.getMayaType()

            if self.b_snapComponents:
                components = self.i_obj.getComponents()
                if not components:
                    raise StandardError, "This objects has no components to snap: '%s'" % self.i_obj.getShortName(
                    )
                #>>>Progress bar
                mayaMainProgressBar = gui.doStartMayaProgressBar(
                    len(components))
                for c in components:
                    if mc.progressBar(mayaMainProgressBar,
                                      query=True,
                                      isCancelled=True):
                        break
                    mc.progressBar(mayaMainProgressBar,
                                   edit=True,
                                   status=("Wrapping '%s'" % c),
                                   step=1)

                    if targetType in ['mesh', 'nurbsSurface', 'nurbsCurve']:
                        pos = distance.returnWorldSpacePosition(c)
                        targetLoc = mc.spaceLocator()
                        mc.move(pos[0], pos[1], pos[2], targetLoc[0])

                        closestLoc = locators.locClosest([targetLoc[0]],
                                                         i_target.mNode)
                        if self._posOffset:
                            self.doOrientObjToSurface(i_target.mNode,
                                                      closestLoc)
                            mc.move(self._posOffset[0],
                                    self._posOffset[1],
                                    self._posOffset[2], [closestLoc],
                                    r=True,
                                    rpr=True,
                                    os=True,
                                    wd=True)
                        position.movePointSnap(c, closestLoc)
                        mc.delete([targetLoc[0], closestLoc])

                gui.doEndMayaProgressBar(
                    mayaMainProgressBar)  #Close out this progress bar

            else:
                pos = False
                if self.b_snaptoSurface:  #>>> If our target is surface we can use
                    if targetType in ['mesh', 'nurbsCurve', 'nurbsSurface']:
                        i_locObj = self.i_obj.doLoc()  #Get our position loc
                        i_locTarget = cgmMeta.cgmObject(
                            locators.locClosest([i_locObj.mNode],
                                                i_target.mNode))  #Loc closest
                        #i_locObj.rename('objLoc')
                        #i_locTarget.rename('targetLoc')
                        if self._posOffset:
                            try:
                                self.doOrientObjToSurface(
                                    i_target.mNode, i_locTarget.mNode)
                                mc.move(self._posOffset[0],
                                        self._posOffset[1],
                                        self._posOffset[2],
                                        [i_locTarget.mNode],
                                        r=True,
                                        rpr=True,
                                        os=True,
                                        wd=True)
                            except StandardError, error:
                                log.warn("self._posOffset failure!")
                                log.error(error)

                        pos = i_locTarget.getPosition(True)
                        i_locObj.delete()
                        i_locTarget.delete()
                elif self.b_midSurfacePos:
                    log.debug("Snap.move>>> midSurfacePos mode!")
                    if targetType not in [
                            'mesh', 'nurbsCurve', 'nurbsSurface'
                    ]:
                        log.warning(
                            "Can't do midSurfacPos on targetType: '%s'" %
                            targetType)
                        return False
                    #Get the axis info
                    axisToCheck = kws.pop('axisToCheck', False)
                    if not axisToCheck:
                        axisToCheck = []
                        up = dictionary.returnVectorToString(
                            self._upVector) or False
                        if not up:
                            raise StandardError, "SnapFactory>>> must have up vector for midSurfaceSnap: %s" % self._upVector
                        for a in ['x', 'y', 'z']:
                            if a != up[0]:
                                axisToCheck.append(a)
                        if not axisToCheck:
                            raise StandardError, "SnapFactory>>> couldn't find any axis to do"
                    #i_locObj = self.i_obj.doLoc()#Get our position loc
                    #log.debug(axisToCheck)
                    pos = RayCast.findMeshMidPointFromObject(
                        i_target.mNode,
                        self.i_obj.mNode,
                        axisToCheck=axisToCheck,
                        **kws)
                    #i_locObj.delete()

                else:
                    pos = i_target.getPosition(True)
                if pos:
                    if self.i_obj.isComponent():
                        if self.b_softSelection:  #Only need to do this if soft select is on
                            mc.softSelect(softSelectEnabled=True)
                            mc.select(self.i_obj.getComponent())
                            mc.move(pos[0], pos[1], pos[2], rpr=True)
                            mc.select(cl=True)
                        else:
                            mc.move(pos[0], pos[1], pos[2],
                                    self.i_obj.getComponent())
                    else:
                        mc.move(pos[0],
                                pos[1],
                                pos[2],
                                self.i_obj.mNode,
                                rpr=True)
Пример #9
0
    def bake(self, startTime=None, endTime=None):
        _str_func = 'PostBake.bake'

        self._cancelBake = False

        self.startTime = int(mc.playbackOptions(
            q=True, min=True)) if startTime is None else startTime
        self.endTime = int(mc.playbackOptions(
            q=True, max=True)) if endTime is None else endTime

        previousStart = mc.playbackOptions(q=True, min=True)
        previousEnd = mc.playbackOptions(q=True, max=True)
        previousCurrent = mc.currentTime(q=True)

        log.info('Baking from {0} to {1}'.format(self.startTime, self.endTime))

        mc.currentTime(self.startTime)

        self.preBake()

        self.setAim(aimFwd=self.aimFwd, aimUp=self.aimUp)

        fps = mel.eval('currentTimeUnitToFPS')

        fixedDeltaTime = 1.0 / fps

        self.velocity = MATH.Vector3.zero()

        ak = mc.autoKeyframe(q=True, state=True)
        mc.autoKeyframe(state=False)
        mc.refresh(su=not self.showBake)

        _len = self.endTime - self.startTime
        _progressBar = cgmUI.doStartMayaProgressBar(_len, "Processing...")

        completed = True

        if self._cancelBake:
            mc.refresh(su=False)
            mc.autoKeyframe(state=ak)
            return

        for i in range(self.startTime, self.endTime + 1):
            mc.currentTime(i)

            try:
                self.update(fixedDeltaTime)
            except Exception, err:
                mc.refresh(su=False)
                mc.autoKeyframe(state=ak)
                log.warning('Error on update | {0}'.format(err))
                cgmGEN.cgmException(Exception, err)
                return

            mc.setKeyframe(self.obj.mNode, at=self.keyableAttrs)
            self.velocity = MATH.Vector3.Lerp(
                self.velocity,
                VALID.euclidVector3Arg(self.obj.p_position) -
                self.previousPosition,
                min(fixedDeltaTime * self.velocityDamp, 1.0))
            self.previousPosition = VALID.euclidVector3Arg(self.obj.p_position)

            if _progressBar:
                if mc.progressBar(_progressBar, query=True, isCancelled=True):
                    log.warning('Bake cancelled!')
                    completed = False
                    break

                mc.progressBar(_progressBar,
                               edit=True,
                               status=("{0} On frame {1}".format(_str_func,
                                                                 i)),
                               step=1,
                               maxValue=_len)
def verifyMorpheusNodeStructure(i_Morpheus):
    """"
    Returns a defined Morpheus asset
    
    What is a morpheus asset
    """
    assert i_Morpheus.mClass == 'cgmMorpheusPuppet',"Not a cgmMorpheusPuppet"
    
    def returnModuleMatch(moduleKey):
        for i_m in i_Morpheus.moduleChildren:
            matchBuffer = 0
            for key in d_moduleCheck[moduleKey].keys():
                log.debug("attr: %s"%key)
                log.debug("value: '%s"%i_m.__dict__[key])
                log.debug("checkTo: '%s'"%d_moduleCheck[moduleKey].get(key))
                if i_m.hasAttr(key) and i_m.__dict__[key] == d_moduleCheck[moduleKey].get(key):
                    matchBuffer +=1
            if matchBuffer == len(d_moduleCheck[moduleKey].keys()):
                log.debug("Found Morpheus Module: '%s'"%moduleKey)
                return i_m
        return False
 
    d_moduleInstances = {}
    
    # Create the modules
    #=====================================================================
    mayaMainProgressBar = gui.doStartMayaProgressBar(len(l_modulesToDoOrder))
    
    for moduleKey in l_modulesToDoOrder:
        if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True ) :
            break
        mc.progressBar(mayaMainProgressBar, edit=True, status = "On segment '%s'..."%(moduleKey), step=1)
        
        if moduleKey not in d_moduleParents.keys():#Make sure we have a parent
            log.info("Missing parent info for: '%s'"%moduleKey)
            return False
        if moduleKey not in d_moduleCheck.keys():#Make sure we have a parent
            log.info("Missing check info for: '%s'"%moduleKey)
            return False  

        if moduleKey in d_moduleTemplateSettings.keys():#Make sure we have settings
            d_settingsDict = d_moduleTemplateSettings[moduleKey]
        elif d_moduleCheck[moduleKey]['moduleType'] in d_moduleTemplateSettings.keys():
            d_settingsDict = d_moduleTemplateSettings[ d_moduleCheck[moduleKey]['moduleType'] ]            
        else:
            log.info("Missing limb info for: '%s'"%moduleKey)
            return False

        log.debug("Have all setup info. Checking structure...")
        if moduleKey in d_moduleInstances.keys():#if it's already stored, use it
            i_module = d_moduleInstances[moduleKey]
        else:
            i_module = i_Morpheus.getModuleFromDict(d_moduleCheck[moduleKey])#Look for it
            d_moduleInstances[moduleKey] = i_module#Store it if found
        if not i_module:
            log.info("Need to create: '%s'"%moduleKey)
            kw_direction = False
            kw_name = False
            if 'cgmDirection' in d_moduleCheck[moduleKey].keys():
                kw_direction = d_moduleCheck[moduleKey].get('cgmDirection')
            if 'cgmName' in d_moduleCheck[moduleKey].keys():
                kw_name = d_moduleCheck[moduleKey].get('cgmName')            
            i_module = i_Morpheus.addModule(mClass = 'cgmLimb',mType = d_moduleCheck[moduleKey]['moduleType'],name = kw_name, direction = kw_direction)
            d_moduleInstances[moduleKey] = i_module#Store it
            
        if i_module:i_module.__verify__()
            
        #>>> Settings
        for key in d_settingsDict.keys():
            i_templateNull = i_module.templateNull
            if i_templateNull.hasAttr(key):
                log.debug("attr: '%s'"%key)  
                log.debug("setting: '%s'"%d_settingsDict.get(key))                  
                try:i_templateNull.__setattr__(key,d_settingsDict.get(key)) 
                except:log.warning("attr failed: %s"%key)
        #>>>Parent stuff        
        if d_moduleParents.get(moduleKey):#If we should be looking for a module parent
            if d_moduleParents.get(moduleKey) in d_moduleInstances.keys():
                i_moduleParent = False
                if i_module.getMessage('moduleParent') and i_module.getMessage('moduleParent') == [d_moduleInstances[d_moduleParents[moduleKey]].mNode]:
                    i_moduleParent = None
                else:
                    i_moduleParent = d_moduleInstances[d_moduleParents.get(moduleKey)]
            else:
                i_moduleParent = i_Morpheus.getModuleFromDict(d_moduleCheck.get(d_moduleParents.get(moduleKey)))
            
            if i_moduleParent is None:
                log.info("moduleParent already connected: '%s'"%d_moduleParents.get(moduleKey))                
            elif i_moduleParent:
                i_module.doSetParentModule(i_moduleParent.mNode)
            else:
                log.info("moduleParent not found from key: '%s'"%d_moduleParents.get(moduleKey))
        
    # For each module
    #=====================================================================
    gui.doEndMayaProgressBar(mayaMainProgressBar)#Close out this progress bar    
    #i_limb.getGeneratedCoreNames()    
    return i_Morpheus
def verifyMorpheusNodeStructure(i_Morpheus):
    """"
    Returns a defined Morpheus asset
    
    What is a morpheus asset
    """
    assert i_Morpheus.mClass == 'cgmMorpheusPuppet', "Not a cgmMorpheusPuppet"

    def returnModuleMatch(moduleKey):
        for i_m in i_Morpheus.moduleChildren:
            matchBuffer = 0
            for key in d_moduleCheck[moduleKey].keys():
                log.debug("attr: %s" % key)
                log.debug("value: '%s" % i_m.__dict__[key])
                log.debug("checkTo: '%s'" % d_moduleCheck[moduleKey].get(key))
                if i_m.hasAttr(key) and i_m.__dict__[key] == d_moduleCheck[
                        moduleKey].get(key):
                    matchBuffer += 1
            if matchBuffer == len(d_moduleCheck[moduleKey].keys()):
                log.debug("Found Morpheus Module: '%s'" % moduleKey)
                return i_m
        return False

    d_moduleInstances = {}

    # Create the modules
    #=====================================================================
    mayaMainProgressBar = gui.doStartMayaProgressBar(len(l_modulesToDoOrder))

    for moduleKey in l_modulesToDoOrder:
        if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True):
            break
        mc.progressBar(mayaMainProgressBar,
                       edit=True,
                       status="On segment '%s'..." % (moduleKey),
                       step=1)

        if moduleKey not in d_moduleParents.keys(
        ):  #Make sure we have a parent
            log.info("Missing parent info for: '%s'" % moduleKey)
            return False
        if moduleKey not in d_moduleCheck.keys():  #Make sure we have a parent
            log.info("Missing check info for: '%s'" % moduleKey)
            return False

        if moduleKey in d_moduleTemplateSettings.keys(
        ):  #Make sure we have settings
            d_settingsDict = d_moduleTemplateSettings[moduleKey]
        elif d_moduleCheck[moduleKey][
                'moduleType'] in d_moduleTemplateSettings.keys():
            d_settingsDict = d_moduleTemplateSettings[d_moduleCheck[moduleKey]
                                                      ['moduleType']]
        else:
            log.info("Missing limb info for: '%s'" % moduleKey)
            return False

        log.debug("Have all setup info. Checking structure...")
        if moduleKey in d_moduleInstances.keys(
        ):  #if it's already stored, use it
            i_module = d_moduleInstances[moduleKey]
        else:
            i_module = i_Morpheus.getModuleFromDict(
                d_moduleCheck[moduleKey])  #Look for it
            d_moduleInstances[moduleKey] = i_module  #Store it if found
        if not i_module:
            log.info("Need to create: '%s'" % moduleKey)
            kw_direction = False
            kw_name = False
            if 'cgmDirection' in d_moduleCheck[moduleKey].keys():
                kw_direction = d_moduleCheck[moduleKey].get('cgmDirection')
            if 'cgmName' in d_moduleCheck[moduleKey].keys():
                kw_name = d_moduleCheck[moduleKey].get('cgmName')
            i_module = i_Morpheus.addModule(
                mClass='cgmLimb',
                mType=d_moduleCheck[moduleKey]['moduleType'],
                name=kw_name,
                direction=kw_direction)
            d_moduleInstances[moduleKey] = i_module  #Store it

        if i_module: i_module.__verify__()

        #>>> Settings
        for key in d_settingsDict.keys():
            i_templateNull = i_module.templateNull
            if i_templateNull.hasAttr(key):
                log.debug("attr: '%s'" % key)
                log.debug("setting: '%s'" % d_settingsDict.get(key))
                try:
                    i_templateNull.__setattr__(key, d_settingsDict.get(key))
                except:
                    log.warning("attr failed: %s" % key)
        #>>>Parent stuff
        if d_moduleParents.get(
                moduleKey):  #If we should be looking for a module parent
            if d_moduleParents.get(moduleKey) in d_moduleInstances.keys():
                i_moduleParent = False
                if i_module.getMessage('moduleParent') and i_module.getMessage(
                        'moduleParent') == [
                            d_moduleInstances[d_moduleParents[moduleKey]].mNode
                        ]:
                    i_moduleParent = None
                else:
                    i_moduleParent = d_moduleInstances[d_moduleParents.get(
                        moduleKey)]
            else:
                i_moduleParent = i_Morpheus.getModuleFromDict(
                    d_moduleCheck.get(d_moduleParents.get(moduleKey)))

            if i_moduleParent is None:
                log.info("moduleParent already connected: '%s'" %
                         d_moduleParents.get(moduleKey))
            elif i_moduleParent:
                i_module.doSetParentModule(i_moduleParent.mNode)
            else:
                log.info("moduleParent not found from key: '%s'" %
                         d_moduleParents.get(moduleKey))

    # For each module
    #=====================================================================
    gui.doEndMayaProgressBar(mayaMainProgressBar)  #Close out this progress bar
    #i_limb.getGeneratedCoreNames()
    return i_Morpheus