def getSelectedCubeyRigNameSpaces(): selection = mc.ls(sl=True) or [] nameSpaces = [] for o in selection: nameSpaces.append(search.returnReferencePrefix(o)) return lists.returnListNoDuplicates(nameSpaces)
def getSelectedCubeyRigNameSpaces(): selection = mc.ls(sl=True) or [] nameSpaces = [] for o in selection: nameSpaces.append( search.returnReferencePrefix(o) ) return lists.returnListNoDuplicates(nameSpaces)
def isRef(self): """ Get ref state of the object """ if mc.referenceQuery(self.nameLong, isNodeReferenced=True): self.refState = True self.refPrefix = search.returnReferencePrefix(self.nameShort) return self.refState = False self.refPrefix = None
def isRef(self): """ Basic ref check. Stores to self """ if mc.referenceQuery(self.PuppetNull.nameShort, isNodeReferenced=True): self.refState = True self.refPrefix = search.returnReferencePrefix( self.PuppetNull.nameShort) return self.refState = False self.refPrefix = None
def bakeCombinedBlendShapeNodeToTargetObject(targetObject,sourceObject, blendShapeNode, baseName = False, directions=['left','right']): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Function for baking a series of blendshapes from one object to another when you have a left/right variant ARGUMENTS: targetObject(string) sourceObject(string) blendShapeNode(string) the node to bake from baseName(bool/string) - if it's False, it uses the target Object name, else, it uses what is supplied directions[list] = (['left','right']) RETURNS: Success(bool) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Prep #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ declare variables """ returnList = [] blendShapeNamesBaked = [] blendShapeConnections = [] currentConnections = [] bakedGeo = [] """ size """ sizeBuffer = distance.returnBoundingBoxSize(targetObject) sizeX = sizeBuffer[0] sizeY = sizeBuffer[1] """ base name """ if baseName == False: baseName = '' else: baseName = baseName + '_' """reference check """ refPrefix = search.returnReferencePrefix(sourceObject) if refPrefix != False: referencePrefix = (search.returnReferencePrefix(sourceObject) + ':') else: referencePrefix = '' """ wrap deform object """ wrapBuffer = wrapDeformObject(targetObject,sourceObject,True) targetObjectBaked = wrapBuffer[1] #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Meat of it #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #setAttr ($wrapDeformer[0] + ".autoWeightThreshold") 1; """ cause maya is stupid and doesn't have a python equivalent""" mc.select(targetObjectBaked,r=True) mc.select(sourceObject,tgl=True) mel.eval('AddWrapInfluence') mc.select(cl=True) """ may need to add this in later //reorders deformation order for proper baking of skinned mesh //reorderDeformers "tweak1" "face_skinCluster" $deformerGeo; """ blendShapeNodeChannels = search.returnBlendShapeAttributes(blendShapeNode) blendShapeShortNames = [] """ first loop stores and sets everything to 0 """ for shape in blendShapeNodeChannels: blendShapeBuffer = (blendShapeNode+'.'+shape) blendShapeConnections.append(attributes.returnDriverAttribute(blendShapeBuffer)) """break it """ attributes.doBreakConnection(blendShapeBuffer) attributes.doSetAttr(blendShapeNode,shape,0) """ Find pairs """ blendshapePairs = lists.returnMatchedStrippedEndList(blendShapeNodeChannels,directions) """ first loop stores and sets everything to 0 """ for pair in blendshapePairs: blendShapeBuffer = (blendShapeNode+'.'+pair[0]) splitBuffer = pair[0].split('_') nameBuffer = splitBuffer[:-1] pairBaseName = '_'.join(nameBuffer) if '_' in list(pairBaseName): newSplitBuffer = pair[0].split('_') newNameBuffer = newSplitBuffer[1:] blendShapeShortNames.append('_'.join(newNameBuffer)) else: blendShapeShortNames.append(pairBaseName) t=1 pair = 0 for i in range (len(blendshapePairs)): row = i//5 if t>5: t=1 """ start extracting """ blendShapeNodeChannelsBuffer = blendshapePairs[pair] shape1 = blendShapeNodeChannelsBuffer[0] shape2 = blendShapeNodeChannelsBuffer[1] attributes.doSetAttr(blendShapeNode,shape1,1) attributes.doSetAttr(blendShapeNode,shape2,1) dupBuffer = mc.duplicate(targetObjectBaked) splitBuffer = blendShapeShortNames[pair].split('_') nameBuffer = splitBuffer[:-1] shortName = '_'.join(nameBuffer) dupBuffer = mc.rename (dupBuffer,(baseName+shortName)) mc.xform(dupBuffer,r=True,t=[((sizeX*(t+1.2))*1.5),(sizeY*row*-1.5),0]) bakedGeo.append(dupBuffer) attributes.doSetAttr(blendShapeNode,shape1,0) attributes.doSetAttr(blendShapeNode,shape2,0) pair +=1 t+=1 """ restore connections """ for shape in blendShapeNodeChannels: currentIndex = blendShapeNodeChannels.index(shape) blendShapeBuffer = (blendShapeNode+'.'+shape) """ Restore the connection """ if blendShapeConnections[currentIndex] != False: attributes.doConnectAttr(blendShapeConnections[currentIndex],blendShapeBuffer) """delete the wrap""" mc.delete(wrapBuffer[0]) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Finish out #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ group for geo """ meshGroup = mc.group( em=True) attributes.storeInfo(meshGroup,'cgmName', baseName) attributes.storeInfo(meshGroup,'cgmTypeModifier', 'blendShapeGeo') meshGroup = NameFactory.doNameObject(meshGroup) for geo in bakedGeo: rigging.doParentReturnName(geo,meshGroup) returnList.append(meshGroup) returnList.append(bakedGeo) mc.delete(targetObjectBaked) return returnList