def doUpdateLocator(locatorName,forceBBCenter = False): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Update a locator created with our nifty tool. ARGUMENTS: obj(string) RETURNS: name(string) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ if search.returnObjectType(locatorName) == 'locator': locatorMode = search.returnTagInfo(locatorName,'cgmLocMode') if locatorMode == 'fromObject': obj = search.returnTagInfo(locatorName,'cgmName') if mc.objExists(obj) == True: """get stuff to transfer""" locInfo = returnInfoForLoc(obj,forceBBCenter) doPositionLocator(locatorName,locInfo) return True else: guiFactory.warning ("The stored object doesn't exist") return False else: sourceObjects = search.returnTagInfo(locatorName,'cgmSource') targetObjectsBuffer = sourceObjects.split(',') targetObjects = [] for obj in targetObjectsBuffer: if mc.objExists(obj): targetObjects.append(obj) else: guiFactory.warning ('%s%s' % (obj, " not found, using any that are... ")) if locatorMode == 'selectCenter': locBuffer = locMeCenter(targetObjects,forceBBCenter) position.moveParentSnap(locatorName,locBuffer) mc.delete(locBuffer) if locatorMode == 'closestPoint': locBuffer = locClosest(targetObjects[:-1],targetObjects[-1]) position.moveParentSnap(locatorName,locBuffer) mc.delete(locBuffer) else: return False return locatorName
def doUpdateLocator(locatorName, forceBBCenter=False): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Update a locator created with our nifty tool. ARGUMENTS: obj(string) RETURNS: name(string) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ if search.returnObjectType(locatorName) == 'locator': locatorMode = search.returnTagInfo(locatorName, 'cgmLocMode') if locatorMode == 'fromObject': obj = search.returnTagInfo(locatorName, 'cgmName') if mc.objExists(obj) == True: """get stuff to transfer""" locInfo = returnInfoForLoc(obj, forceBBCenter) doPositionLocator(locatorName, locInfo) return True else: guiFactory.warning("The stored object doesn't exist") return False else: sourceObjects = search.returnTagInfo(locatorName, 'cgmSource') targetObjectsBuffer = sourceObjects.split(',') targetObjects = [] for obj in targetObjectsBuffer: if mc.objExists(obj): targetObjects.append(obj) else: guiFactory.warning( '%s%s' % (obj, " not found, using any that are... ")) if locatorMode == 'selectCenter': locBuffer = locMeCenter(targetObjects, forceBBCenter) position.moveParentSnap(locatorName, locBuffer) mc.delete(locBuffer) if locatorMode == 'closestPoint': locBuffer = locClosest(targetObjects[:-1], targetObjects[-1]) position.moveParentSnap(locatorName, locBuffer) mc.delete(locBuffer) else: return False return locatorName
def returnModuleColors(moduleNull): direction = search.returnTagInfo(moduleNull, 'cgmDirection') print direction if direction == False: return returnSettingsData('colorCenter', True) else: return returnSettingsData(('color' + direction.capitalize()), True)
def returnModuleColors(moduleNull): direction = search.returnTagInfo(moduleNull,'cgmDirection') print direction if direction == False: return returnSettingsData('colorCenter',True) else: return returnSettingsData(('color'+direction.capitalize()),True)
def getMatchObject(self): """ Get match object of the object. """ matchObject = search.returnTagInfo(self.nameLong,'cgmMatchObject') if mc.objExists(matchObject): return matchObject return False
def addModule(self, module, *a, **kw): """ Adds a module to a puppet module(string) """ if module in self.ModulesBuffer.bufferList: return guiFactory.warning("'%s' already connnected to '%s'" % (module, self.nameBase)) elif mc.objExists(module): # If it exists, check type to initialize and add modType = search.returnTagInfo(module, 'moduleType') or False if modType in moduleTypeToFunctionDict.keys(): self.ModulesBuffer.store(module) moduleNullBuffer = rigging.doParentReturnName( module, self.msgModulesGroup.get()) self.Module[self.ModulesBuffer.bufferList.index( module)] = moduleTypeToFunctionDict[modType]( moduleNullBuffer) else: guiFactory.warning( "'%s' is not a module type found in the moduleTypeToFunctionDict. Cannot initialize" ) else: guiFactory.warning( "'%s' is not a module type found in the moduleTypeToFunctionDict. Cannot initialize" % module)
def returnDirectionalInfo(moduleNull): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Returns directional info from a module to a list and False in an entry if no data is there ARGUMENTS: moduleNull(string) RETURNS: direction(list) - ['left','front'], [False,'back'] etc >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ returnList = [] returnList.append(search.returnTagInfo(moduleNull,'cgmDirection')) returnList.append(search.returnTagInfo(moduleNull,'cgmPosition')) return returnList
def returnDirectionalInfo(moduleNull): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Returns directional info from a module to a list and False in an entry if no data is there ARGUMENTS: moduleNull(string) RETURNS: direction(list) - ['left','front'], [False,'back'] etc >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ returnList = [] returnList.append(search.returnTagInfo(moduleNull, 'cgmDirection')) returnList.append(search.returnTagInfo(moduleNull, 'cgmPosition')) return returnList
def returnSegmentedJointList(limbJoints): cullList = copy.copy(limbJoints) """put objects in order of closeness to root""" cullList = distance.returnDistanceSortedList(cullList[0],cullList) #>>> Segment our joint list by names jointSegmentsList = [] while len(cullList) > 0: matchTerm = search.returnTagInfo(cullList[0],'cgmName') objSet = returnMatchedTagsFromObjectList(cullList,'cgmName',matchTerm) jointSegmentsList.append(objSet) for obj in objSet: cullList.remove(obj) return jointSegmentsList
def returnSegmentedJointList(limbJoints): cullList = copy.copy(limbJoints) """put objects in order of closeness to root""" cullList = distance.returnDistanceSortedList(cullList[0], cullList) #>>> Segment our joint list by names jointSegmentsList = [] while len(cullList) > 0: matchTerm = search.returnTagInfo(cullList[0], 'cgmName') objSet = returnMatchedTagsFromObjectList(cullList, 'cgmName', matchTerm) jointSegmentsList.append(objSet) for obj in objSet: cullList.remove(obj) return jointSegmentsList
def getModules(self, *a, **kw): """ Intializes all connected modules of a puppet """ self.Module = {} self.moduleIndexDict = {} self.moduleParents = {} self.ModulesBuffer.updateData() if self.ModulesBuffer.bufferList: for i, m in enumerate(self.ModulesBuffer.bufferList): modType = search.returnTagInfo(m, 'moduleType') or False if modType in moduleTypeToFunctionDict.keys(): self.Module[i] = moduleTypeToFunctionDict[modType](m, *a, **kw) self.Module[i].ModuleNull.doParent( self.ModulesGroup.nameLong) self.moduleIndexDict[m] = i else: guiFactory.warning( "'%s' is not a module type found in the moduleTypeToFunctionDict. Cannot initialize" % modType)
def changeModuleCGMTag(self, moduleName, tag, newInfo, *a, **kw): """ Function to change a cgm tag on a module and push a rename through that moudule's instance moduleName(string) tag(string) which tag to use. For a list ### from cgm.lib.classes import NameFactory NameFactory.cgmNameTags ### newInfo(*a,**kw) - info to pass into the attributes.storeInfo() function """ if moduleName in self.ModulesBuffer.bufferList: #Clear our instanced module index = self.ModulesBuffer.bufferList.index(moduleName) modType = search.returnTagInfo( self.Module[index].ModuleNull.nameShort, 'moduleType') or False if index is not False: if modType in moduleTypeToFunctionDict.keys(): if self.Module[index].changeCGMTag(tag, newInfo, *a, **kw): self.Module[index] = moduleTypeToFunctionDict[modType]( self.Module[index].ModuleNull.nameShort) self.ModulesBuffer.updateData() else: guiFactory.warning( "'%s' is not a module type found in the moduleTypeToFunctionDict. Cannot initialize" % modType) return False else: guiFactory.warning("%s is not a valid index. Cannot continue" % index) return False else: guiFactory.warning( "'%s' doesn't seem to be a connected module. Cannot change tag" % moduleName) return False
def orientSegment(limbJoints, posTemplateObjects, orientation): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Basic limb skeletonizer ARGUMENTS: limbJoints(list) templeateObjects(list) orientation(string) - ['xyz','yzx','zxy','xzy','yxz','zyx'] RETURNS: limbJoints(list) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ """ orientation vectors""" orientationVectors = search.returnAimUpOutVectorsFromOrientation( orientation) wantedAimVector = orientationVectors[0] wantedUpVector = orientationVectors[1] """put objects in order of closeness to root""" limbJoints = distance.returnDistanceSortedList(limbJoints[0], limbJoints) #>>> Segment our joint list by names jointSegmentsList = [] cullList = [] """ gonna be culling items from the list so need to rebuild it, just doing a list1 = list2 somehow keeps the relationship....odd """ for obj in limbJoints: cullList.append(obj) while len(cullList) > 0: matchTerm = search.returnTagInfo(cullList[0], 'cgmName') objSet = search.returnMatchedTagsFromObjectList( cullList, 'cgmName', matchTerm) jointSegmentsList.append(objSet) for obj in objSet: cullList.remove(obj) #>>> get our orientation helpers helperObjects = [] for obj in posTemplateObjects: templateObj = attributes.returnMessageObject(obj, 'cgmName') helperObjects.append( attributes.returnMessageObject(templateObj, 'orientHelper')) #>>> un parenting the chain for joint in limbJoints[1:]: mc.parent(joint, world=True) #>>>per segment stuff cnt = 0 for segment in jointSegmentsList: if len(segment) > 1: """ creat our up object from from the helper object """ helperObjectCurvesShapes = mc.listRelatives(helperObjects[cnt], shapes=True) upLoc = locators.locMeCvFromCvIndex(helperObjectCurvesShapes[0], 30) print upLoc """ make a pair list""" pairList = lists.parseListToPairs(segment) for pair in pairList: """ set up constraints """ constraintBuffer = mc.aimConstraint(pair[1], pair[0], maintainOffset=False, weight=1, aimVector=wantedAimVector, upVector=wantedUpVector, worldUpVector=[0, 1, 0], worldUpObject=upLoc, worldUpType='object') mc.delete(constraintBuffer[0]) for obj in segment[-1:]: constraintBuffer = mc.orientConstraint(segment[-2], obj, maintainOffset=False, weight=1) mc.delete(constraintBuffer[0]) """ increment and delete the up loc """ cnt += 1 mc.delete(upLoc) else: helperObjectCurvesShapes = mc.listRelatives(helperObjects[cnt], shapes=True) upLoc = locators.locMeCvFromCvIndex(helperObjectCurvesShapes[0], 30) """ make an aim object """ aimLoc = locators.locMeObject(helperObjects[cnt]) aimLocGroup = rigging.groupMeObject(aimLoc) mc.move(10, 0, 0, aimLoc, localSpace=True) constraintBuffer = mc.aimConstraint(aimLoc, segment[0], maintainOffset=False, weight=1, aimVector=wantedAimVector, upVector=wantedUpVector, worldUpVector=[0, 1, 0], worldUpObject=upLoc, worldUpType='object') mc.delete(constraintBuffer[0]) mc.delete(aimLocGroup) mc.delete(upLoc) cnt += 1 #>>>reconnect the joints pairList = lists.parseListToPairs(limbJoints) for pair in pairList: mc.parent(pair[1], pair[0]) """ Freeze the rotations """ mc.makeIdentity(limbJoints[0], apply=True, r=True) return limbJoints
def returnOrderedChildrenModules(moduleNull): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Returns children parts organized by part type and direction ARGUMENTS: moduleNull(string) RETURNS: returnDict(dict) - {type:{direction:['1','2' >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ modules = returnSceneModules() #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Info gathering #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> moduleParents = {} for module in modules: moduleParents[module] = attributes.returnMessageObject( module, 'moduleParent') print moduleParents #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Parsing out Children #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> childrenModules = [] """ first we're gonna find all modules that have our module as it's parent""" for key in moduleParents.keys(): if moduleParents.get(key) == moduleNull: childrenModules.append(key) print childrenModules #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Further parsing #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> moduleTypes = {} typesPresent = [] """ first get the types and a simplified types present list """ for module in childrenModules: isType = search.returnTagInfo(module, 'cgmModuleType') typesPresent.append(isType) moduleTypes[module] = isType typesPresent = lists.returnListNoDuplicates(typesPresent) """ get the data together for return """ moduleDirectionalInfo = {} directionsPresent = [] for module in childrenModules: isDirection = returnDirectionalInfoToString(module) directionsPresent.append(isDirection) moduleDirectionalInfo[module] = isDirection directionsPresent = lists.returnListNoDuplicates(directionsPresent) returnDict = {} for t in typesPresent: tagBuffer = {} for d in directionsPresent: dBuffer = [] for module in childrenModules: if moduleTypes.get(module) == t: if moduleDirectionalInfo.get(module) == d: dBuffer.append(module) if len(dBuffer) > 0: tagBuffer[d] = dBuffer returnDict[t] = tagBuffer if len(returnDict) > 0: return returnDict else: return False
nameTools.returnCombinedNameFromDict(d) #>>> Modules #======================================================= #>>>> OLD i_obj = cgmMeta.cgmObject(mc.spaceLocator()[0]) i_obj = cgmMeta.cgmNode(obj) i_obj = cgmMeta.cgmNode(mc.ls(sl=True)[0]) i_obj.doName(nameChildren=True) i_obj.doName(True, nameChildren=True) for j in mc.ls(sl=True): cgmMeta.cgmObject(j).doName() obj = mc.ls(sl=True)[0] NameF.returnObjectGeneratedNameDict(obj) NameF.doRenameHeir(obj, True) search.returnTagInfo(obj, 'cgmName') #>>> NEW NewName = cgmMeta.NameFactory cgm.core._reload() log.info(issubclass(type(i_obj), cgmMeta.cgmNode)) NewName.go('spine_1_3_jnt').getMatchedChildren() NewName.go('spine_1_3_jnt').getBaseIterator() obj = mc.ls(sl=True)[0] obj = cgmMeta.cgmNode(mc.ls(sl=True)[0]) obj.__justCreatedState__ NewName(mc.ls(sl=True)[0]).getBaseIterator() NewName(mc.ls(sl=True)[0]).getIterator() NewName(mc.ls(sl=True)[0]).getFastIterator()
def returnObjectGeneratedNameDict(obj,ignore=[False]): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Returns a generated dictionary of name info ARGUMENTS: obj(string) - object ignore(string) - default is 'none', only culls out cgmtags that are generated via returnCGMOrder() function RETURNS: namesDict(string) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ _str_funcName = "returnObjectGeneratedNameDict" log.debug(">>> %s >>> "%(_str_funcName) + "="*75) #_str_funcName = "returnObjectGeneratedNameDict(%s,ignore = %s)"%(obj,ignore) if type(ignore) is not list:ignore = [ignore] typesDictionary = dictionary.initializeDictionary(typesDictionaryFile) namesDictionary = dictionary.initializeDictionary(namesDictionaryFile) settingsDictionary = dictionary.initializeDictionary(settingsDictionaryFile) namesDict={} divider = returnCGMDivider() order = returnCGMOrder() nameBuilder = [] #>>> Get our cgmVar_iables userAttrs = attributes.returnUserAttributes(obj) cgmAttrs = lists.returnMatchList(userAttrs,order) #>>> Tag ignoring if ignore: for i in ignore: if i in order: order.remove(i) #>>> Geting our data for tag in order: tagInfo = search.findRawTagInfo(obj,tag) if tagInfo is not False: namesDict[tag] = (tagInfo) _iterator = search.findRawTagInfo(obj,'cgmIterator') if _iterator is not False: log.debug("Iterator found") namesDict['cgmIterator'] = (_iterator) # remove tags up stream that we don't want if they don't exist on the actual object""" if not mc.objExists(obj+'.cgmTypeModifier'): if namesDict.get('cgmTypeModifier') != None: namesDict.pop('cgmTypeModifier') log.debug("%s >>> initial nameDict: %s "%(_str_funcName,namesDict)) #>>> checks if the names exist as objects or it's a shape node ChildNameObj = False nameObj = search.returnTagInfo(obj,'cgmName') typeTag = search.returnTagInfo(obj,'cgmType') isType = search.returnObjectType(obj) childrenObjects = search.returnChildrenObjects(obj) """first see if it's a group """ if isType == 'group' and typeTag == False: log.debug("%s >>> group and no typeTag..."%(_str_funcName)) """ if it's a transform group """ groupNamesDict = {} if not nameObj: groupNamesDict['cgmName'] = childrenObjects[0] else: groupNamesDict['cgmName'] = nameObj groupNamesDict['cgmType'] = typesDictionary.get('transform') if namesDict.get('cgmTypeModifier') != None: groupNamesDict['cgmTypeModifier'] = namesDict.get('cgmTypeModifier') return groupNamesDict """ see if there's a name tag""" elif nameObj != None or isType == 'shape': #If we have a name object or shape log.debug("%s >>> nameObj not None or isType is 'shape'..."%(_str_funcName)) if mc.objExists(nameObj) and mc.attributeQuery ('cgmName',node=obj,msg=True): log.debug("%s >>> nameObj exists: '%s'..."%(_str_funcName,nameObj)) #Basic child object with cgmName tag childNamesDict = {} childNamesDict['cgmName'] = namesDict.get('cgmName') childNamesDict['cgmType'] = namesDict.get('cgmType') if namesDict.get('cgmTypeModifier') != None: childNamesDict['cgmTypeModifier'] = namesDict.get('cgmTypeModifier') if namesDict.get('cgmIterator') != None: childNamesDict['cgmIterator'] = namesDict.get('cgmIterator') return childNamesDict elif isType == 'shape' or 'Constraint' in isType: """if so, it's a child name object""" log.debug("%s >>> child name object..."%(_str_funcName)) childNamesDict = {} childNamesDict['cgmName'] = search.returnParentObject(obj,False) childNamesDict['cgmType'] = namesDict.get('cgmType') return childNamesDict elif typeTag == 'infoNull': log.debug("%s >>> special case..."%(_str_funcName)) moduleObj = search.returnMatchedTagObjectUp(obj,'cgmType','module') masterObj = search.returnMatchedTagObjectUp(obj,'cgmType','master') if moduleObj != False: moduleName = returnUniqueGeneratedName(moduleObj,ignore='cgmType') childNamesDict = {} childNamesDict['cgmName'] = (moduleName+'_'+nameObj) childNamesDict['cgmType'] = namesDict.get('cgmType') return childNamesDict elif masterObj != False: masterName = returnUniqueGeneratedName(masterObj,ignore='cgmType') childNamesDict = {} childNamesDict['cgmName'] = (masterName+'_'+nameObj) childNamesDict['cgmType'] = namesDict.get('cgmType') return childNamesDict else: return namesDict else: log.debug("%s >>> No special case found. %s"%(_str_funcName,namesDict)) return namesDict else: return namesDict
def returnOrderedChildrenModules(moduleNull): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Returns children parts organized by part type and direction ARGUMENTS: moduleNull(string) RETURNS: returnDict(dict) - {type:{direction:['1','2' >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ modules = returnSceneModules() #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Info gathering #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> moduleParents ={} for module in modules: moduleParents[module] = attributes.returnMessageObject(module,'moduleParent') print moduleParents #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Parsing out Children #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> childrenModules = [] """ first we're gonna find all modules that have our module as it's parent""" for key in moduleParents.keys(): if moduleParents.get(key) == moduleNull: childrenModules.append(key) print childrenModules #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Further parsing #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> moduleTypes = {} typesPresent = [] """ first get the types and a simplified types present list """ for module in childrenModules: isType = search.returnTagInfo(module,'cgmModuleType') typesPresent.append(isType) moduleTypes[module] = isType typesPresent = lists.returnListNoDuplicates(typesPresent) """ get the data together for return """ moduleDirectionalInfo = {} directionsPresent = [] for module in childrenModules: isDirection = returnDirectionalInfoToString(module) directionsPresent.append(isDirection) moduleDirectionalInfo[module] = isDirection directionsPresent = lists.returnListNoDuplicates(directionsPresent) returnDict = {} for t in typesPresent: tagBuffer = {} for d in directionsPresent: dBuffer = [] for module in childrenModules: if moduleTypes.get(module) == t: if moduleDirectionalInfo.get(module) == d: dBuffer.append(module) if len(dBuffer) > 0: tagBuffer[d] = dBuffer returnDict[t] = tagBuffer if len(returnDict) > 0: return returnDict else: return False
def returnObjectGeneratedNameDict(obj,ignore='none'): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Returns a generated dictionary of name info ARGUMENTS: obj(string) - object ignore(string) - default is 'none', only culls out cgmtags that are generated via returnCGMOrder() function RETURNS: namesDict(string) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ typesDictionary = dictionary.initializeDictionary(typesDictionaryFile) namesDictionary = dictionary.initializeDictionary(namesDictionaryFile) settingsDictionary = dictionary.initializeDictionary(settingsDictionaryFile) namesDict={} divider = returnCGMDivider() order = returnCGMOrder() nameBuilder = [] #>>> Get our cgmVar_iables userAttrs = attributes.returnUserAttributes(obj) cgmAttrs = lists.returnMatchList(userAttrs,order) #>>> Tag ignoring if ignore != 'none': if ignore in order: order.remove(ignore) #>>> Geting our data for tag in order: tagInfo = search.findRawTagInfo(obj,tag) if tagInfo is not False: namesDict[tag] = (tagInfo) """ remove tags up stream that we don't want if they don't exist on the actual object""" if mc.objExists(obj+'.cgmTypeModifier') != True: if namesDict.get('cgmTypeModifier') != None: namesDict.pop('cgmTypeModifier') #>>> checks if the names exist as objects or it's a shape node ChildNameObj = False nameObj = search.returnTagInfo(obj,'cgmName') typeTag = search.returnTagInfo(obj,'cgmType') isType = search.returnObjectType(obj) childrenObjects = search.returnChildrenObjects(obj) """first see if it's a group """ if childrenObjects > 0 and isType == 'transform' and typeTag == False: """ if it's a transform group """ groupNamesDict = {} if not nameObj: groupNamesDict['cgmName'] = childrenObjects[0] else: groupNamesDict['cgmName'] = nameObj groupNamesDict['cgmType'] = typesDictionary.get('transform') if namesDict.get('cgmDirection') != None: groupNamesDict['cgmDirection'] = namesDict.get('cgmDirection') if namesDict.get('cgmDirectionModifier') != None: groupNamesDict['cgmDirectionModifier'] = namesDict.get('cgmDirectionModifier') if namesDict.get('cgmTypeModifier') != None: groupNamesDict['cgmTypeModifier'] = namesDict.get('cgmTypeModifier') return groupNamesDict """ see if there's a name tag""" elif nameObj != None or isType == 'shape': """if there is, does it exist """ if mc.objExists(nameObj) == True: """basic child object with cgmName tag """ childNamesDict = {} childNamesDict['cgmName'] = namesDict.get('cgmName') childNamesDict['cgmType'] = namesDict.get('cgmType') if namesDict.get('cgmDirection') != None: childNamesDict['cgmDirection'] = namesDict.get('cgmDirection') if namesDict.get('cgmNameModifier') != None: childNamesDict['cgmNameModifier'] = namesDict.get('cgmNameModifier') if namesDict.get('cgmDirectionModifier') != None: childNamesDict['cgmDirectionModifier'] = namesDict.get('cgmDirectionModifier') if namesDict.get('cgmTypeModifier') != None: childNamesDict['cgmTypeModifier'] = namesDict.get('cgmTypeModifier') return childNamesDict elif isType == 'shape' or 'Constraint' in isType: """if so, it's a child name object""" childNamesDict = {} childNamesDict['cgmName'] = search.returnParentObject(obj,False) childNamesDict['cgmType'] = namesDict.get('cgmType') return childNamesDict elif typeTag == 'infoNull': """if so, it's a special case""" moduleObj = search.returnMatchedTagObjectUp(obj,'cgmType','module') masterObj = search.returnMatchedTagObjectUp(obj,'cgmType','master') if moduleObj != False: moduleName = returnUniqueGeneratedName(moduleObj,ignore='cgmType') childNamesDict = {} childNamesDict['cgmName'] = (moduleName+'_'+nameObj) childNamesDict['cgmType'] = namesDict.get('cgmType') return childNamesDict elif masterObj != False: masterName = returnUniqueGeneratedName(masterObj,ignore='cgmType') childNamesDict = {} childNamesDict['cgmName'] = (masterName+'_'+nameObj) childNamesDict['cgmType'] = namesDict.get('cgmType') return childNamesDict else: return namesDict else: return namesDict else: return namesDict
def rigSpine(moduleNull): #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>>Get our info #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> partName = NameFactory.returnUniqueGeneratedName(moduleNull, ignore='cgmType') """ template null """ templateNull = modules.returnTemplateNull(moduleNull) templateNullData = attributes.returnUserAttrsToDict(templateNull) jointOrientation = modules.returnSettingsData('jointOrientation') templateRoot = modules.returnInfoNullObjects(moduleNull, 'templatePosObjects', types='templateRoot') """ AutonameStuff """ divider = NameFactory.returnCGMDivider() """ control helper objects """ controlTemplateObjects = modules.returnInfoNullObjects( moduleNull, 'templateControlObjects', types='all') controlTemplateObjects = distance.returnDistanceSortedList( templateRoot, controlTemplateObjects) print 'controlTemplateObjects...' print controlTemplateObjects """size list of template control objects """ controlTemplateObjectsSizes = [] for obj in controlTemplateObjects: controlTemplateObjectsSizes.append( distance.returnAbsoluteSizeCurve(obj)) print 'sizes...' print controlTemplateObjectsSizes """ Skin Joints """ skinJoints = modules.returnInfoNullObjects(moduleNull, 'skinJoints', types='all') skinJoints = distance.returnDistanceSortedList(templateRoot, skinJoints) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Make Controls #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ control options """ fk = templateNullData.get('fk') ik = templateNullData.get('ik') stretch = templateNullData.get('stretch') bend = templateNullData.get('bend') """controls to make """ controlsToMake = [] controlsToMake.append('cog') if fk == True: controlsToMake.append('segmentControls') controlsToMake.append('hips') if ik == True: controlsToMake.append('vectorHandles') controlsToMake.append('spineIKHandle') controlsDict = modules.limbControlMaker(moduleNull, controlsToMake) print controlsDict #>>> Organize em segmentControls = controlsDict.get('segmentControls') spineIKHandle = controlsDict.get('spineIKHandle') cog = controlsDict.get('cog') hips = controlsDict.get('hips') vectorHandles = controlsDict.get('vectorHandles') for handle in vectorHandles[-1:]: mc.delete(handle) vectorHandles.remove(handle) #>>> Parent em rigging.parentListToHeirarchy(segmentControls) mc.parent(spineIKHandle, segmentControls[-1]) mc.parent(segmentControls[0], cog) mc.parent(hips, cog) for obj in segmentControls: rigging.zeroTransformMeObject(obj) mc.makeIdentity(obj, apply=True, translate=True) for obj in vectorHandles: mc.makeIdentity(obj, apply=True, translate=True) """ hips anchor locator """ locBuffer = locators.locMeObject(hips) attributes.storeInfo(locBuffer, 'cgmName', hips) attributes.storeInfo(locBuffer, 'cgmTypeModifier', 'anchor') hipsAnchor = NameFactory.doNameObject(locBuffer) mc.setAttr((hipsAnchor + '.rotateOrder'), 5) pointConstraintBuffer = mc.pointConstraint(hips, hipsAnchor, maintainOffset=False, weight=1) orientConstraintBuffer = mc.orientConstraint(hips, hipsAnchor, maintainOffset=False, skip=['x', 'y'], weight=1) """ hips anchor group constraint """ groupBuffer = rigging.groupMeObject(hipsAnchor) attributes.storeInfo(groupBuffer, 'cgmName', hipsAnchor) attributes.storeInfo(groupBuffer, 'cgmTypeModifier', 'orient') hipsAnchorOrGroup = NameFactory.doNameObject(groupBuffer) orientConstraintBuffer = mc.orientConstraint(segmentControls[0], hipsAnchorOrGroup, maintainOffset=False, weight=1) """ end anchor locator """ locBuffer = locators.locMeObject(segmentControls[-1]) attributes.storeInfo(locBuffer, 'cgmName', segmentControls[-1]) attributes.storeInfo(locBuffer, 'cgmTypeModifier', 'anchor') endAnchor = NameFactory.doNameObject(locBuffer) mc.setAttr((endAnchor + '.rotateOrder'), 5) mc.parent(endAnchor, spineIKHandle) #>>> set up follow chains constraintChain = [] constraintChain.append(hipsAnchor) constraintChain = constraintChain + vectorHandles constraintChain.append(endAnchor) constraintChainReturn = constraints.doSegmentAimPointConstraint( constraintChain) print constraintChainReturn vectorHandlesZeroGroups = [] for obj in vectorHandles: vectorHandlesZeroGroups.append(rigging.zeroTransformMeObject(obj)) """ parent the last group to our IK handle """ #mc.parent(vectorHandlesZeroGroups[-1],spineIKHandle) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Joint Chains #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ surface chain """ dupJointsBuffer = mc.duplicate(skinJoints[:-1], po=True, rc=True) surfaceJoints = [] for joint in dupJointsBuffer: attributes.storeInfo(joint, 'cgmType', 'surfaceJoint') surfaceJoints.append(NameFactory.doNameObject(joint)) """ firm start """ startJointsBuffer = mc.duplicate(skinJoints[0], po=True, rc=True) startJoints = [] for joint in startJointsBuffer: attributes.storeInfo(joint, 'cgmType', 'deformationJoint') startJoints.append(NameFactory.doNameObject(joint)) """ firm end """ endJointsBuffer = mc.duplicate(skinJoints[-2:], po=True, rc=True) endJoints = [] for joint in endJointsBuffer: attributes.storeInfo(joint, 'cgmType', 'deformationJoint') endJoints.append(NameFactory.doNameObject(joint)) mc.parent(endJoints[0], world=True) #>>> Influence chain """ get the root joints from our main chain searching by "cgmName" tags...maybe not the best way Maybe should change to search to closest joints """ influenceJointsBuffer = [] for obj in surfaceJoints: if (search.returnTagInfo(obj, 'cgmName')) != False: influenceJointsBuffer.append(obj) """ make our influence joints """ influenceJoints = [] for joint in influenceJointsBuffer: buffer = mc.duplicate(joint, po=True) closestObject = distance.returnClosestObject(buffer[0], surfaceJoints) attributes.storeInfo(buffer[0], 'cgmName', closestObject) attributes.storeInfo(buffer[0], 'cgmType', 'influenceJoint') rigging.doParentToWorld(buffer[0]) influenceJoints.append(NameFactory.doNameObject(buffer[0])) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Put our deformation joints in the rig #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ############### need better way of doing this for iterative mc.parent(endJoints[0], spineIKHandle) mc.parent(startJoints[0], hips) mc.parent(influenceJoints[0], hipsAnchor) mc.parent(influenceJoints[1], vectorHandles[0]) mc.parent(influenceJoints[2], spineIKHandle) #mc.parent(influenceJoints[3],spineIKHandle) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Control Surface #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ create """ orientationBuffer = list(jointOrientation) outChannel = orientationBuffer[2] upChannel = (orientationBuffer[1] + 'up') print upChannel surfaceBuffer = joints.loftSurfaceFromJointList(surfaceJoints, outChannel) controlSurface = surfaceBuffer[0] attributes.copyUserAttrs(moduleNull, controlSurface, attrsToCopy=['cgmName']) attributes.storeInfo(controlSurface, 'cgmType', 'controlSurface', True) controlSurface = NameFactory.doNameObject(controlSurface) """ connect joints to surface""" surfaceConnectReturn = joints.attachJointChainToSurface( surfaceJoints, controlSurface, jointOrientation, upChannel, 'animCrv') print surfaceConnectReturn """ surface influence joints skinning""" surfaceSkinCluster = mc.skinCluster(influenceJoints, controlSurface, tsb=True, n=(controlSurface + '_skinCluster'), maximumInfluences=3, normalizeWeights=1, dropoffRate=1) #surfaceSkinCluster = mc.skinCluster (influenceJoints,controlSurface,tsb=True, n=(controlSurface+'_skinCluster'),maximumInfluences = 3, normalizeWeights = 1, dropoffRate=1,smoothWeights=.5,obeyMaxInfluences=True, weight = 1) controlSurfaceSkinCluster = surfaceSkinCluster[0] """ smooth skin weights """ skinning.simpleControlSurfaceSmoothWeights(controlSurface) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>>> Connect skin joints to surface joints #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> deformationJoints = [] deformationJoints.append(startJoints[0]) deformationJoints = deformationJoints + surfaceJoints[1:-2] deformationJoints = deformationJoints + endJoints for joint in skinJoints: attachJoint = distance.returnClosestObject(joint, deformationJoints) pntConstBuffer = mc.pointConstraint(attachJoint, joint, maintainOffset=False, weight=1) orConstBuffer = mc.orientConstraint(attachJoint, joint, maintainOffset=False, weight=1) #mc.connectAttr((attachJoint+'.t'),(joint+'.t')) #mc.connectAttr((attachJoint+'.r'),(joint+'.r')) mc.connectAttr((attachJoint + '.s'), (joint + '.s')) pntConstBuffer = mc.pointConstraint(attachJoint, joint, maintainOffset=False, weight=1) orConstBuffer = mc.orientConstraint(attachJoint, joint, maintainOffset=False, weight=1)
def returnObjectGeneratedNameDict(obj, ignore=[False]): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Returns a generated dictionary of name info ARGUMENTS: obj(string) - object ignore(string) - default is 'none', only culls out cgmtags that are generated via returnCGMOrder() function RETURNS: namesDict(string) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ typesDictionary = dictionary.initializeDictionary(typesDictionaryFile) namesDictionary = dictionary.initializeDictionary(namesDictionaryFile) settingsDictionary = dictionary.initializeDictionary( settingsDictionaryFile) namesDict = {} divider = returnCGMDivider() order = returnCGMOrder() nameBuilder = [] #>>> Get our cgmVar_iables userAttrs = attributes.returnUserAttributes(obj) cgmAttrs = lists.returnMatchList(userAttrs, order) #>>> Tag ignoring if ignore: for i in ignore: if i in order: order.remove(i) #>>> Geting our data for tag in order: tagInfo = search.findRawTagInfo(obj, tag) if tagInfo is not False: namesDict[tag] = (tagInfo) """ remove tags up stream that we don't want if they don't exist on the actual object""" if mc.objExists(obj + '.cgmTypeModifier') != True: if namesDict.get('cgmTypeModifier') != None: namesDict.pop('cgmTypeModifier') #>>> checks if the names exist as objects or it's a shape node ChildNameObj = False nameObj = search.returnTagInfo(obj, 'cgmName') typeTag = search.returnTagInfo(obj, 'cgmType') isType = search.returnObjectType(obj) childrenObjects = search.returnChildrenObjects(obj) """first see if it's a group """ if childrenObjects > 0 and isType == 'transform' and typeTag == False: """ if it's a transform group """ groupNamesDict = {} if not nameObj: groupNamesDict['cgmName'] = childrenObjects[0] else: groupNamesDict['cgmName'] = nameObj groupNamesDict['cgmType'] = typesDictionary.get('transform') if namesDict.get('cgmDirection') != None: groupNamesDict['cgmDirection'] = namesDict.get('cgmDirection') if namesDict.get('cgmDirectionModifier') != None: groupNamesDict['cgmDirectionModifier'] = namesDict.get( 'cgmDirectionModifier') if namesDict.get('cgmTypeModifier') != None: groupNamesDict['cgmTypeModifier'] = namesDict.get( 'cgmTypeModifier') return groupNamesDict """ see if there's a name tag""" elif nameObj != None or isType == 'shape': """if there is, does it exist """ if mc.objExists(nameObj) == True: """basic child object with cgmName tag """ childNamesDict = {} childNamesDict['cgmName'] = namesDict.get('cgmName') childNamesDict['cgmType'] = namesDict.get('cgmType') if namesDict.get('cgmDirection') != None: childNamesDict['cgmDirection'] = namesDict.get('cgmDirection') if namesDict.get('cgmNameModifier') != None: childNamesDict['cgmNameModifier'] = namesDict.get( 'cgmNameModifier') if namesDict.get('cgmDirectionModifier') != None: childNamesDict['cgmDirectionModifier'] = namesDict.get( 'cgmDirectionModifier') if namesDict.get('cgmTypeModifier') != None: childNamesDict['cgmTypeModifier'] = namesDict.get( 'cgmTypeModifier') return childNamesDict elif isType == 'shape' or 'Constraint' in isType: """if so, it's a child name object""" childNamesDict = {} childNamesDict['cgmName'] = search.returnParentObject(obj, False) childNamesDict['cgmType'] = namesDict.get('cgmType') return childNamesDict elif typeTag == 'infoNull': """if so, it's a special case""" moduleObj = search.returnMatchedTagObjectUp( obj, 'cgmType', 'module') masterObj = search.returnMatchedTagObjectUp( obj, 'cgmType', 'master') if moduleObj != False: moduleName = returnUniqueGeneratedName(moduleObj, ignore='cgmType') childNamesDict = {} childNamesDict['cgmName'] = (moduleName + '_' + nameObj) childNamesDict['cgmType'] = namesDict.get('cgmType') return childNamesDict elif masterObj != False: masterName = returnUniqueGeneratedName(masterObj, ignore='cgmType') childNamesDict = {} childNamesDict['cgmName'] = (masterName + '_' + nameObj) childNamesDict['cgmType'] = namesDict.get('cgmType') return childNamesDict else: return namesDict else: return namesDict else: return namesDict
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