Esempio n. 1
0
def doUpdateObjectName(self):
	selected = mc.ls(sl=True)
	
	for obj in selected:
		try:
			NameFactoryOld.doUpdateName(obj)
		except:
			guiFactory.warning('Error on naming attempt')
Esempio n. 2
0
def doUpdateObjectName(self):
    selected = mc.ls(sl=True)

    for obj in selected:
        try:
            NameFactoryOld.doUpdateName(obj)
        except:
            guiFactory.warning('Error on naming attempt')
Esempio n. 3
0
def doNameHeirarchy(self, sceneUnique=False, fastIterate=True):
    selected = mc.ls(sl=True)

    if not selected:
        guiFactory.warning('Must have something selected')
        return

    for obj in selected:
        try:
            NameFactoryOld.doRenameHeir(obj, sceneUnique, fastIterate)
        except:
            guiFactory.warning('Error on naming attempt')
Esempio n. 4
0
def doNameHeirarchy(self,sceneUnique=False,fastIterate=True):
	selected = mc.ls(sl=True)
	
	if not selected:
		guiFactory.warning('Must have something selected')
		return
	
	for obj in selected:
		try:
			NameFactoryOld.doRenameHeir(obj,sceneUnique,fastIterate)
		except:
			guiFactory.warning('Error on naming attempt')		
Esempio n. 5
0
def createPoseBuffer(name, poseList):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Returns the colors used on the shapes of a curve as a list in order
    of volume used

    ARGUMENTS:
    curve(string
    
    RETURNS:
    Success(bool)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    returnList = []

    poseBuffer = mc.group(em=True)
    attributes.storeInfo(poseBuffer, 'cgmName', name)
    attributes.storeInfo(poseBuffer, 'cgmType', 'poseBuffer')
    poseBuffer = NameFactory.doNameObject(poseBuffer)
    returnList.append(poseBuffer)

    returnList.append(
        attributes.addFloatAttrsToObj(poseBuffer, poseList, dv=0,
                                      keyable=True))

    attributes.doSetLockHideKeyableAttr(poseBuffer, True, False, False)

    return returnList
Esempio n. 6
0
def createPoseBuffer(name, poseList):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Returns the colors used on the shapes of a curve as a list in order
    of volume used

    ARGUMENTS:
    curve(string
    
    RETURNS:
    Success(bool)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    returnList = []

    poseBuffer = mc.group(em=True)
    attributes.storeInfo(poseBuffer, "cgmName", name)
    attributes.storeInfo(poseBuffer, "cgmType", "poseBuffer")
    poseBuffer = NameFactoryOld.doNameObject(poseBuffer)
    returnList.append(poseBuffer)

    returnList.append(attributes.addFloatAttrsToObj(poseBuffer, poseList, dv=0, keyable=True))

    attributes.doSetLockHideKeyableAttr(poseBuffer, True, False, False)

    return returnList
Esempio n. 7
0
def returnTemplateObjects(moduleNull, types='templateObject'):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Returns the template null of a module
    
    ARGUMENTS:
    moduleNull(string)
    
    RETURNS:
    templateNull(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    templateNull = returnTemplateNull(moduleNull)
    templateNullData = attributes.returnUserAttrsToDict(templateNull)
    templateObjects = []
    coreNamesArray = []
    divider = NameFactory.returnCGMDivider()

    for key in templateNullData.keys():
        if (mc.attributeQuery(key, node=templateNull, msg=True)) == True:
            templateObjects.append(templateNullData[key])
        coreNamesArray.append(key)

    if types == 'all':
        return templateObjects
    else:
        returnBuffer = []
        for obj in templateObjects:
            bufferList = obj.split(divider)
            if (typesDictionary.get(types)) in bufferList:
                returnBuffer.append(obj)
        return returnBuffer
Esempio n. 8
0
def uiUpdateAutoNamePreview(self):
    autoNameObject = mc.textField(self.AutoNameObjectField, q=True, text=True)
    if autoNameObject:
        newName = NameFactory.returnUniqueGeneratedName(autoNameObject, True)
        self.GeneratedNameField(e=True, label=("Preview : '" + newName + "'"))
    else:
        self.GeneratedNameField(e=True, label=('Name will preview here...'))
Esempio n. 9
0
def uiReturnFastName(self):
    selected = mc.ls(sl=True)
    from cgm.lib.classes import NameFactory as NameFactoryOld
    reload(NameFactoryOld)

    for obj in selected:
        print(NameFactoryOld.returnObjectGeneratedNameDict(obj))
Esempio n. 10
0
def uiReturnSceneUniqueName(self):
    selected = mc.ls(sl=True)
    from cgm.lib.classes import NameFactory as NameFactoryOld
    reload(NameFactoryOld)

    for obj in selected:
        print(NameFactoryOld.returnUniqueGeneratedName(obj, True))
Esempio n. 11
0
def uiReturnIterator(self):
	selected = mc.ls(sl=True)
	from cgm.lib.classes import NameFactory as NameFactoryOld
	reload(NameFactoryOld)
	
	for obj in selected:
		print (NameFactoryOld.returnIterateNumber(obj))
Esempio n. 12
0
def uiReturnIterator(self):
    selected = mc.ls(sl=True)
    from cgm.lib.classes import NameFactory as NameFactoryOld
    reload(NameFactoryOld)

    for obj in selected:
        print(NameFactoryOld.returnIterateNumber(obj))
Esempio n. 13
0
def uiUpdateAutoNamePreview(self):
	autoNameObject = mc.textField(self.AutoNameObjectField,q=True,text = True)
	if autoNameObject:
		newName = NameFactoryOld.returnUniqueGeneratedName(autoNameObject,True)
		self.GeneratedNameField(e = True,label = ("Preview : '" + newName + "'"))
	else:
		self.GeneratedNameField(e = True,label = ('Name will preview here...'))
Esempio n. 14
0
def uiNameLoadedAutoNameObject(self):
    autoNameObject = mc.textField(self.AutoNameObjectField, q=True, text=True)
    if autoNameObject:
        newName = NameFactoryOld.doNameObject(autoNameObject, True)
        mc.textField(self.AutoNameObjectField, e=True, text=newName)
    else:
        guiFactory.warning('No current autoname object loaded!')
Esempio n. 15
0
def uiNameLoadedAutoNameObject(self):
	autoNameObject = mc.textField(self.AutoNameObjectField,q=True,text = True)
	if autoNameObject:
		newName = NameFactoryOld.doNameObject(autoNameObject,True)
		mc.textField(self.AutoNameObjectField,e = True,text = newName)
	else:
		guiFactory.warning('No current autoname object loaded!')
Esempio n. 16
0
def locMeCenter(objList,forceBBCenter = False):
	"""
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	DESCRIPTION:
	Pass  an object into it and get a named locator with stored info for updating it

	ARGUMENTS:
	obj(string)

	RETURNS:
	name(string)
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	"""
	# make it
	nameBuffer = mc.spaceLocator()

	#store info
	attributes.storeInfo(nameBuffer[0],'cgmSource',(','.join(objList)),False)
	attributes.storeInfo(nameBuffer[0],'cgmLocMode','selectCenter',False)
	attributes.storeInfo(nameBuffer[0],'cgmName',(str('_to_'.join(objList))),False)
	attributes.storeInfo(nameBuffer[0],'cgmTypeModifier','midPoint',False)

	posList = []

	for obj in objList:
		if mc.objExists(obj) == True:
			objInfo = returnInfoForLoc(obj,forceBBCenter)
			posList.append(objInfo['position'])

	objTrans = distance.returnAveragePointPosition(posList)

	mc.move (objTrans[0],objTrans[1],objTrans[2], nameBuffer[0])

	return ( NameFactory.doNameObject(nameBuffer[0]) )
Esempio n. 17
0
def uiReturnSceneUniqueName(self):
	selected = mc.ls(sl=True)
	from cgm.lib.classes import NameFactory as NameFactoryOld
	reload(NameFactoryOld)
	
	for obj in selected:
		print (NameFactoryOld.returnUniqueGeneratedName(obj,True))
Esempio n. 18
0
def uiReturnFastName(self):
	selected = mc.ls(sl=True)
	from cgm.lib.classes import NameFactory as NameFactoryOld
	reload(NameFactoryOld)
	
	for obj in selected:
		print (NameFactoryOld.returnObjectGeneratedNameDict(obj))
Esempio n. 19
0
def returnTemplateObjects(moduleNull,types='templateObject'):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Returns the template null of a module
    
    ARGUMENTS:
    moduleNull(string)
    
    RETURNS:
    templateNull(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    templateNull = returnTemplateNull(moduleNull)
    templateNullData = attributes.returnUserAttrsToDict (templateNull)
    templateObjects = []
    coreNamesArray = []  
    divider = NameFactory.returnCGMDivider()

    for key in templateNullData.keys():
        if (mc.attributeQuery (key,node=templateNull,msg=True)) == True:
            templateObjects.append(templateNullData[key])
        coreNamesArray.append (key)
        
    if types == 'all':
        return templateObjects
    else:
        returnBuffer = []
        for obj in templateObjects:
            bufferList = obj.split(divider)
            if (typesDictionary.get(types)) in bufferList:
                returnBuffer.append(obj)
        return returnBuffer
Esempio n. 20
0
def uiNameObject(self, sceneUnique):
    selected = mc.ls(sl=True, flatten=True, long=True)
    newNames = []

    if not selected:
        guiFactory.warning('Must have something selected')
        return

    elif len(selected) > 1:
        tmpGroup = mc.group(em=True)
        cnt = 1

        for o in selected:
            attributes.storeInfo(tmpGroup, ('name' + str(cnt)), o)
            cnt += 1
        toNameAttrs = attributes.returnUserAttributes(tmpGroup)

        mayaMainProgressBar = guiFactory.doStartMayaProgressBar(
            len(toNameAttrs), 'Naming...')
        for attr in toNameAttrs:
            if mc.progressBar(mayaMainProgressBar,
                              query=True,
                              isCancelled=True):
                break

            objectToName = (attributes.returnMessageObject(tmpGroup, attr))
            mc.progressBar(mayaMainProgressBar,
                           edit=True,
                           status=("Naming '%s'" % objectToName),
                           step=1)

            try:
                buffer = NameFactoryOld.doNameObject(objectToName, sceneUnique)
            except:
                guiFactory.warning("'%s' failed" % objectToName)

            if buffer:
                newNames.append(buffer)

        guiFactory.doEndMayaProgressBar(mayaMainProgressBar)
        mc.delete(tmpGroup)

    else:
        NameFactoryOld.doNameObject(selected[0], sceneUnique)

    if newNames:
        print("The following were named: %s" % ','.join(newNames))
Esempio n. 21
0
def uiNameLoadedAutoNameObjectChildren(self):
	autoNameObject = mc.textField(self.AutoNameObjectField,q=True,text = True)
	if autoNameObject:
		newNameList = NameFactoryOld.doRenameHeir(autoNameObject,True)
		mc.textField(self.AutoNameObjectField,e = True,text = newNameList[0])

	else:
		guiFactory.warning('No current autoname object loaded!')
Esempio n. 22
0
def uiGetObjectInfo(self):
    selected = mc.ls(sl=True, long=True)
    from cgm.lib.classes import NameFactory as NameFactoryOld
    reload(NameFactoryOld)

    for obj in selected:
        obj = NameFactoryOld.NameFactory(obj)
        obj.reportInfo()
Esempio n. 23
0
def uiNameLoadedAutoNameObjectChildren(self):
    autoNameObject = mc.textField(self.AutoNameObjectField, q=True, text=True)
    if autoNameObject:
        newNameList = NameFactoryOld.doRenameHeir(autoNameObject, True)
        mc.textField(self.AutoNameObjectField, e=True, text=newNameList[0])

    else:
        guiFactory.warning('No current autoname object loaded!')
Esempio n. 24
0
def point(*a, **kw):
    buffer = mc.pointConstraint(*a, **kw)
    if buffer:
        returnList = []
        for c in buffer:
            returnList.append(NameFactory.doNameObject(c))
        return returnList
    else:
        return False
Esempio n. 25
0
def orient(*a, **kw):
    buffer = mc.orientConstraint(*a, **kw)
    if buffer:
        returnList = []
        for c in buffer:
            returnList.append(NameFactory.doNameObject(c))
        return returnList
    else:
        return False
Esempio n. 26
0
def uiNameObject(self,sceneUnique):
	selected = mc.ls(sl=True,flatten=True,long=True)
	newNames = []
	
	if not selected:
		guiFactory.warning('Must have something selected')
		return
		
	elif len(selected) > 1:
		tmpGroup = mc.group(em=True)
		cnt = 1
		
		for o in selected:
			attributes.storeInfo(tmpGroup,('name'+str(cnt)),o)
			cnt += 1
		toNameAttrs = attributes.returnUserAttributes(tmpGroup)
		
		mayaMainProgressBar = guiFactory.doStartMayaProgressBar(len(toNameAttrs),'Naming...')
		for attr in toNameAttrs:
			if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True ) :
				break

			objectToName = (attributes.returnMessageObject(tmpGroup,attr))
			mc.progressBar(mayaMainProgressBar, edit=True, status = ("Naming '%s'"%objectToName), step=1)

			try:
				buffer =  NameFactoryOld.doNameObject( objectToName,sceneUnique )
			except:
				guiFactory.warning("'%s' failed"%objectToName)


			if buffer:
				newNames.append(buffer)
				
		guiFactory.doEndMayaProgressBar(mayaMainProgressBar)
		mc.delete(tmpGroup)
		
		
	else:
		NameFactoryOld.doNameObject(selected[0],sceneUnique)
	
	if newNames:
		print ("The following were named: %s" %','.join(newNames))
Esempio n. 27
0
def groupMeObject(obj,parent=True,maintainParent=False):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Pass  an object into it and return group placed at the pivots -
    matching translation, rotation and rotation order and grouping
    it under the grp

    ARGUMENTS:
    obj(string)
    parent(bool) - Whether to parent the object to the group

    RETURNS:
    groupName(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    if maintainParent == True:
        oldParent = mc.listRelatives(obj,parent=True,fullPath = True)
        if oldParent:oldParent = oldParent[0]
    returnBuffer = []
    rotationOrderDictionary = {'xyz':0,'yzx':1 ,'zxy':2 ,'xzy':3 ,'yxz':4,'zyx':5,'none':6}
    """return stuff to transfer"""
    objTrans = mc.xform (obj, q=True, ws=True, rp=True)
    objRot = mc.xform (obj, q=True, ws=True, ro=True)

    objRoo = mc.xform (obj, q=True, roo=True )
    """return rotation order"""
    correctRo = rotationOrderDictionary[objRoo]
    groupBuffer = mc.group (w=True, empty=True)
    mc.setAttr ((groupBuffer+'.rotateOrder'), correctRo)
    mc.move (objTrans[0],objTrans[1],objTrans[2], [groupBuffer])
    mc.rotate (objRot[0], objRot[1], objRot[2], [groupBuffer], ws=True)
    mc.xform (groupBuffer, cp=True)
    
    if maintainParent == True and oldParent:
        #for attr in ['tx','ty','tz','rx','ry','rz','sx','sy','sz']:
        groupBuffer = doParentReturnName(groupBuffer,oldParent)
    if parent:
        _wasLocked = []  
        for attr in ['tx','ty','tz','rx','ry','rz','sx','sy','sz']:
            attrBuffer = '%s.%s'%(obj,attr)
            if mc.getAttr(attrBuffer,lock=True):
                _wasLocked.append(attr)
                mc.setAttr(attrBuffer,lock=False)                
            #attributes.doSetAttr(obj,attr,0)          
        obj = doParentReturnName(obj,groupBuffer)        
        #for attr in ['tx','ty','tz','rx','ry','rz']:
            #if attributes.doGetAttr(obj,attr):
                #attributes.doSetAttr(obj,attr,0)    
        if _wasLocked:
            for attr in _wasLocked:
                attrBuffer = '%s.%s'%(obj,attr)
                mc.setAttr(attrBuffer,lock=True)                
                
    return NameFactoryOld.doNameObject(groupBuffer,True)
Esempio n. 28
0
    def doName(self,sceneUnique=False,nameChildren=False):
        """
        Function for naming a maya instanced object using the cgm.NameFactory class.

        Keyword arguments:
        sceneUnique(bool) -- Whether to run a full scene dictionary check or the faster just objExists check (default False)

        """       
        if self.refState:
            return guiFactory.warning("'%s' is referenced. Cannot change name"%self.nameShort)

        if nameChildren:
            buffer = NameFactory.doRenameHeir(self.nameLong,sceneUnique)
            if buffer:
                self.update(buffer[0])

        else:
            buffer = NameFactory.doNameObject(self.nameLong,sceneUnique)
            if buffer:
                self.update(buffer)   	    
Esempio n. 29
0
    def doName(self, sceneUnique=False):
        """
        Function for naming a maya instanced object using the cgm.NameFactory class.
        
        Keyword arguments:
        sceneUnique(bool) -- Whether to run a full scene dictionary check or the faster just objExists check (default False)
        
        """
        assert not self.refState, "Cannot change the name of a referenced set"
        assert not self.mayaSetState, "Cannot change name of a maya default set"

        buffer = NameFactory.doNameObject(self.nameLong, sceneUnique)
        self.storeNameStrings(buffer)
        return buffer
Esempio n. 30
0
    def doName(self,sceneUnique=False):
        """
        Function for naming a maya instanced object using the cgm.NameFactory class.
        
        Keyword arguments:
        sceneUnique(bool) -- Whether to run a full scene dictionary check or the faster just objExists check (default False)
        
        """   
	assert not self.refState, "Cannot change the name of a referenced set"
	assert not self.mayaSetState, "Cannot change name of a maya default set"
	
        buffer = NameFactory.doNameObject(self.nameLong,sceneUnique)
        self.storeNameStrings(buffer)
        return buffer
Esempio n. 31
0
    def create(self, setType):
        """ Creates a set object honoring our quick select set options """
        set = mc.sets(em=True)

        attributes.storeInfo(set, 'cgmName', self.baseName)
        if setType:
            self.setType = setType
            if setType in setTypes.keys():
                doType = setTypes.get(setType)
            else:
                doType = setType
            attributes.storeInfo(set, 'cgmType', setType)

        set = NameFactory.doNameObject(set, True)
        self.storeNameStrings(set)

        if self.qssState:
            self.isQss(self.qssState)
Esempio n. 32
0
 def create(self,setType):
     """ Creates a set object honoring our quick select set options """ 
     set = mc.sets(em=True)
         
     attributes.storeInfo(set,'cgmName',self.baseName)
     if setType:
         self.setType = setType
         if setType in setTypes.keys():
             doType = setTypes.get(setType)
         else:
             doType = setType
         attributes.storeInfo(set,'cgmType',setType)
         
     set = NameFactory.doNameObject(set,True)
     self.storeNameStrings(set)
     
     if self.qssState:
         self.isQss(self.qssState)        
Esempio n. 33
0
def createInfoNull(infoType):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Creates an infoNull
    
    ARGUMENTS:
    infoType(string)
    
    RETURNS:
    infoNull(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    createBuffer = mc.group(empty=True)
    attributes.storeInfo(createBuffer, 'cgmName', infoType)
    attributes.storeInfo(createBuffer, 'cgmType', 'infoNull')
    mc.xform(createBuffer, os=True, piv=(0, 0, 0))
    infoNull = NameFactory.doNameObject(createBuffer, True)
    return infoNull
Esempio n. 34
0
def createInfoNull(infoType):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Creates an infoNull
    
    ARGUMENTS:
    infoType(string)
    
    RETURNS:
    infoNull(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    createBuffer = mc.group (empty=True)
    attributes.storeInfo(createBuffer,'cgmName',infoType)
    attributes.storeInfo(createBuffer,'cgmType','infoNull')
    mc.xform (createBuffer, os=True, piv= (0,0,0)) 
    infoNull = NameFactory.doNameObject(createBuffer,True)
    return infoNull
Esempio n. 35
0
def basicEyeJointSurfaceSetup(jointList, jointRoot, surface):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Script to rename a joint chain list
    
    ARGUMENTS:
    jointList(list) - list of joints in order
    startJointName(string) - what you want the root named
    interiorJointRootName(string) - what you want the iterative name to be
    
    RETURNS:
    newJoints(list)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    baseDistance = distance.returnAverageDistanceBetweenObjectsAndRoot (jointList,jointRoot)
    controls = []
    groups = []
    
    for joint in jointList:
        """ make the control """        
        jointControl = curves.createControlCurve('circle',1)
        scaleFactor = baseDistance*.25
        mc.setAttr((jointControl+'.sx'),scaleFactor)
        mc.setAttr((jointControl+'.sy'),scaleFactor)
        mc.setAttr((jointControl+'.sz'),scaleFactor)
        position.movePointSnap(jointControl,joint)
        position.aimSnap(jointControl,jointRoot,[0,0,-1])
        mc.xform(jointControl,t=[0,0,baseDistance*.4],os=True, r=True)
        mc.makeIdentity(jointControl, apply = True, s=True)
        
        
        """ naming it """
        attributes.storeInfo(jointControl,'cgmName',joint,True)
        attributes.storeInfo(jointControl,'cgmType','controlAnim')
        jointControl = NameFactoryOld.doNameObject(jointControl)
        controls.append(jointControl)
        
        groups.append( rigging.zeroTransformMeObject(jointControl) )
        
    for control in controls:
        indexCount = controls.index(control)
        attachAimedObjectToSurface (jointList[indexCount], surface, control, 'constrain')
Esempio n. 36
0
def basicEyeJointSurfaceSetup(jointList, jointRoot, surface):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Script to rename a joint chain list
    
    ARGUMENTS:
    jointList(list) - list of joints in order
    startJointName(string) - what you want the root named
    interiorJointRootName(string) - what you want the iterative name to be
    
    RETURNS:
    newJoints(list)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    baseDistance = distance.returnAverageDistanceBetweenObjectsAndRoot(
        jointList, jointRoot)
    controls = []
    groups = []

    for joint in jointList:
        """ make the control """
        jointControl = curves.createControlCurve('circle', 1)
        scaleFactor = baseDistance * .25
        mc.setAttr((jointControl + '.sx'), scaleFactor)
        mc.setAttr((jointControl + '.sy'), scaleFactor)
        mc.setAttr((jointControl + '.sz'), scaleFactor)
        position.movePointSnap(jointControl, joint)
        position.aimSnap(jointControl, jointRoot, [0, 0, -1])
        mc.xform(jointControl, t=[0, 0, baseDistance * .4], os=True, r=True)
        mc.makeIdentity(jointControl, apply=True, s=True)
        """ naming it """
        attributes.storeInfo(jointControl, 'cgmName', joint, True)
        attributes.storeInfo(jointControl, 'cgmType', 'controlAnim')
        jointControl = NameFactory.doNameObject(jointControl)
        controls.append(jointControl)

        groups.append(rigging.zeroTransformMeObject(jointControl))

    for control in controls:
        indexCount = controls.index(control)
        attachAimedObjectToSurface(jointList[indexCount], surface, control,
                                   'constrain')
Esempio n. 37
0
 def getNameTagsFromObject(self,target,ignore=[False]):
     """
     Get name tags from a target object (connected)
     
     Keywords
     ignore(list) - tags to ignore
     
     Returns
     success(bool)
     """
     targetCGM = NameFactory.returnObjectGeneratedNameDict(target,ignore = ignore)
     didSomething = False
     
     for tag in targetCGM.keys():
         if tag not in ignore and targetCGM[tag] is not None or False:
             attributes.doCopyAttr(target,tag,
                                   self.nameLong,connectTargetToSource=True)
             didSomething = True
     return didSomething
Esempio n. 38
0
 def getGeneratedCoreNames(self):
     """ 
     Generate core names for a module and return them
     
     RETURNS:
     generatedNames(list)
     """
     guiFactory.report("Generating core names via ModuleFactory - '%s'"%self.ModuleNull.nameBase)
     
     ### check the settings first ###
     partType = self.afModuleType.value
     settingsCoreNames = modules.returncgmTemplateCoreNames(partType)
     handles = self.optionHandles.value
     partName = NameFactory.returnRawGeneratedName(self.ModuleNull.nameShort,ignore=['cgmType','cgmTypeModifier'])
     
     ### if there are no names settings, genearate them from name of the limb module###
     generatedNames = []
     if settingsCoreNames == False:   
         cnt = 1
         for handle in range(handles):
             generatedNames.append('%s%s%i' % (partName,'_',cnt))
             cnt+=1
     
     elif (len(corePositionList)) > (len(settingsCoreNames)):
         ### Otherwise we need to make sure that there are enough core names for handles ###       
         cntNeeded = (len(corePositionList) - len(settingsCoreNames) +1)
         nonSplitEnd = settingsCoreNames[len(settingsCoreNames)-2:]
         toIterate = settingsCoreNames[1]
         iterated = []
         for i in range(cntNeeded):
             iterated.append('%s%s%i' % (toIterate,'_',(i+1)))
         generatedNames.append(settingsCoreNames[0])
         for name in iterated:
             generatedNames.append(name)
         for name in nonSplitEnd:
             generatedNames.append(name) 
             
     else:
         generatedNames = settingsCoreNames
         
     return generatedNames
Esempio n. 39
0
def createLocFromObject(obj):
	"""
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	DESCRIPTION:
	Pass  an object into it and get a named locator with stored info for updating it

	ARGUMENTS:
	obj(string)

	RETURNS:
	name(string)
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	"""
	# make it
	nameBuffer = mc.spaceLocator()
	buffer = mc.ls(obj,shortNames=True)        	
	#store info
	attributes.storeInfo(nameBuffer[0],'cgmName',buffer[0],False)
	attributes.storeInfo(nameBuffer[0],'cgmLocMode','fromObject',False)

	return ( NameFactory.doNameObject(nameBuffer[0]) )
Esempio n. 40
0
def createLocFromObject(obj):
    """
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	DESCRIPTION:
	Pass  an object into it and get a named locator with stored info for updating it

	ARGUMENTS:
	obj(string)

	RETURNS:
	name(string)
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	"""
    # make it
    nameBuffer = mc.spaceLocator()

    #store info
    attributes.storeInfo(nameBuffer[0], 'cgmName', obj, False)
    attributes.storeInfo(nameBuffer[0], 'cgmLocMode', 'fromObject', False)

    return (NameFactory.doNameObject(nameBuffer[0]))
Esempio n. 41
0
def groupMeObject(obj,parent=True,maintainParent=False):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Pass  an object into it and return group placed at the pivots -
    matching translation, rotation and rotation order and grouping
    it under the grp

    ARGUMENTS:
    obj(string)
    parent(bool) - Whether to parent the object to the group

    RETURNS:
    groupName(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    if maintainParent == True:
        oldParent = mc.listRelatives(obj,parent=True)
        if oldParent:oldParent = oldParent[0]
    returnBuffer = []
    rotationOrderDictionary = {'xyz':0,'yzx':1 ,'zxy':2 ,'xzy':3 ,'yxz':4,'zyx':5,'none':6}
    """return stuff to transfer"""
    objTrans = mc.xform (obj, q=True, ws=True, sp=True)
    objRot = mc.xform (obj, q=True, ws=True, ro=True)

    objRoo = mc.xform (obj, q=True, roo=True )
    """return rotation order"""
    correctRo = rotationOrderDictionary[objRoo]
    groupBuffer = mc.group (w=True, empty=True)
    mc.setAttr ((groupBuffer+'.rotateOrder'), correctRo)
    mc.move (objTrans[0],objTrans[1],objTrans[2], [groupBuffer])
    mc.rotate (objRot[0], objRot[1], objRot[2], [groupBuffer], ws=True)
    mc.xform (groupBuffer, cp=True)
    
    if maintainParent == True and oldParent:
        groupBuffer = doParentReturnName(groupBuffer,oldParent)
    if parent == True:
        obj = doParentReturnName(obj,groupBuffer)        
    
    return NameFactory.doNameObject(groupBuffer,True)
Esempio n. 42
0
def locMeCenter(objList, forceBBCenter=False):
    """
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	DESCRIPTION:
	Pass  an object into it and get a named locator with stored info for updating it

	ARGUMENTS:
	obj(string)

	RETURNS:
	name(string)
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	"""
    # make it
    nameBuffer = mc.spaceLocator()

    #store info
    attributes.storeInfo(nameBuffer[0], 'cgmSource', (','.join(objList)),
                         False)
    attributes.storeInfo(nameBuffer[0], 'cgmLocMode', 'selectCenter', False)
    attributes.storeInfo(nameBuffer[0], 'cgmName', (str('_to_'.join(objList))),
                         False)
    attributes.storeInfo(nameBuffer[0], 'cgmTypeModifier', 'midPoint', False)

    posList = []

    for obj in objList:
        if mc.objExists(obj) == True:
            objInfo = returnInfoForLoc(obj, forceBBCenter)
            posList.append(objInfo['position'])

    objTrans = distance.returnAveragePointPosition(posList)

    mc.move(objTrans[0], objTrans[1], objTrans[2], nameBuffer[0])

    return (NameFactory.doNameObject(nameBuffer[0]))
Esempio n. 43
0
def createMasterNull(characterName='nothingNothing'):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Creates a masterNull for a character/asset
    
    ARGUMENTS:
    characterName(string)
    
    RETURNS:
    masterNull(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    if characterName == 'nothingNothing':
        randomOptions = ['David','Josh','NameMe','Homer','Georgie']
        characterName = random.choice(randomOptions)
    
    #Create main null
    masterNullBuffer = mc.group (empty=True)
    attributes.storeInfo(masterNullBuffer,'cgmName',characterName)   
    attributes.storeInfo(masterNullBuffer,'cgmType','ignore')
    attributes.storeInfo(masterNullBuffer,'cgmModuleType','master')
    masterNull = NameFactory.doNameObject(masterNullBuffer)
    
    #Create modules container null
    modulesGroupBuffer = mc.group (empty=True)
    attributes.storeInfo(modulesGroupBuffer,'cgmName','modules')   
    attributes.storeInfo(modulesGroupBuffer,'cgmType','group')
    modulesGroup = NameFactory.doNameObject(modulesGroupBuffer)
    modulesGroup = rigging.doParentReturnName(modulesGroup,masterNull)
    attributes.storeObjectToMessage (modulesGroup, masterNull, 'modulesGroup')
    
    #Create modules container null
    meshGroupBuffer = mc.group (empty=True)
    attributes.storeInfo(meshGroupBuffer,'cgmName','geo')   
    attributes.storeInfo(modulesGroupBuffer,'cgmType','group')
    meshGroup = NameFactory.doNameObject(modulesGroupBuffer)
    meshGroup = rigging.doParentReturnName(meshGroup,masterNull)
    attributes.storeObjectToMessage (meshGroup, masterNull, 'geoGroup')
    
    #Create master info null
    masterInfoNull = createInfoNull('master')
    attributes.storeObjectToMessage (masterInfoNull, masterNull, 'info')
    masterInfoNull = rigging.doParentReturnName(masterInfoNull,masterNull)
    
    #Create modules info null
    modulesInfoNull = createInfoNull('modules')
    attributes.storeObjectToMessage (modulesInfoNull, masterInfoNull, 'modules')
    modulesInfoNull = rigging.doParentReturnName(modulesInfoNull,masterInfoNull)
    
    #Create mesh info null
    meshInfoNull = createInfoNull('geo')
    attributes.storeObjectToMessage (meshInfoNull, masterInfoNull, 'geo')
    modulesInfoNull = rigging.doParentReturnName(meshInfoNull,masterInfoNull)
    
    #Create global settings info null
    settingsInfoNull = createInfoNull('settings')
    attributes.storeObjectToMessage (settingsInfoNull, masterInfoNull, 'settings')
    settingsInfoNull = rigging.doParentReturnName(settingsInfoNull,masterInfoNull)
    defaultFont = returnSettingsData('defaultTextFont')
    attributes.storeInfo(settingsInfoNull,'font',defaultFont)

    return masterNull
Esempio n. 44
0
def saveTemplateToModule(moduleNull):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
	* Save the new positional information from the template objects
	* Collect all names of objects for a delete list
	* If anything in the module doesn't belong there, un parent it, report it
		* like a template object parented to another obect

    ARGUMENTS:
    moduleNull(string)
    
    RETURNS:
    limbJoints(list)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """  
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Variables
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Get our base info
    """ module null data """
    moduleNullData = attributes.returnUserAttrsToDict(moduleNull)
        
    """ part name """
    partName = NameFactory.returnUniqueGeneratedName(moduleNull, ignore = 'cgmType')
    partType = moduleNullData.get('cgmModuleType')
    direction = moduleNullData.get('cgmDirection')
    
    """ template null """
    templateNull = moduleNullData.get('templateNull')
    templateNullData = attributes.returnUserAttrsToDict(templateNull)
    
    """ template object nulls """
    templatePosObjectsInfoNull = returnInfoTypeNull(moduleNull,'templatePosObjects')
    templatePosObjectsInfoData = attributes.returnUserAttrsToDict (templatePosObjectsInfoNull)
    templateControlObjectsNull = returnInfoTypeNull(moduleNull,'templateControlObjects')
    templateControlObjectsData = attributes.returnUserAttrsToDict (templateControlObjectsNull)

    
    """ rig null """
    rigNull = moduleNullData.get('rigNull')
    
    """ Start objects stuff """
    templateStarterDataInfoNull = returnInfoTypeNull(moduleNull,'templateStarterData')
    templateControlObjectsDataNull = returnInfoTypeNull(moduleNull,'templateControlObjectsData')

    """ AutonameStuff """
    divider = NameFactory.returnCGMDivider()    
    moduleRootBuffer =  returnInfoNullObjects(moduleNull,'templatePosObjects',types='templateRoot')
    moduleRoot = moduleRootBuffer[0]
    templateObjects = []
    coreNamesArray = [] 
    #>>>TemplateInfo
    for key in templatePosObjectsInfoData.keys():
        if (mc.attributeQuery (key,node=templatePosObjectsInfoNull,msg=True)) == True:
            templateObjects.append (templatePosObjectsInfoData[key])
        coreNamesArray.append (key)
    
    posTemplateObjects = []
    """ Get the positional template objects"""
    for obj in templateObjects:
        bufferList = obj.split(divider)
        if (typesDictionary.get('templateObject')) in bufferList:
            posTemplateObjects.append(obj)
    """ get our control template objects """
    controlTemplateObjects=[]
    for key in templateControlObjectsData.keys():
        if (mc.attributeQuery (key,node=templateControlObjectsNull,msg=True)) == True:
            controlTemplateObjects.append (templateControlObjectsData[key])

    """put objects in order of closeness to root"""
    posTemplateObjects = distance.returnDistanceSortedList(moduleRoot,posTemplateObjects)
    controlTemplateObjects = distance.returnDistanceSortedList(moduleRoot,controlTemplateObjects)
    curve = (templatePosObjectsInfoData['curve'])
    
    #>>> get our orientation helpers
    helperObjects = []
    for obj in posTemplateObjects:
        helperObjects.append(attributes.returnMessageObject(obj,'orientHelper'))
        
    masterOrient = (attributes.returnMessageObject(moduleRoot,'orientHelper'))
    
    print ('%s%s'% (moduleNull,' data acquired...'))
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Save Data
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Get the data
    """ pos objects """
    storageData = []
    for obj in posTemplateObjects:
        storageData.append(mc.xform (obj, q=True, ws=True, sp=True))
    
    """ orientation helpers """
    for obj in helperObjects:
        storageData.append(mc.xform (obj,  q=True, os=True, ro=True))
        
    storageData.append(mc.xform (masterOrient, q=True, os=True, ro=True))
    print storageData
    """ template control objects data"""
    tempateControlObjectsStorageData = []
    for obj in controlTemplateObjects:
        print obj
        tempateControlObjectsStorageData.append(mc.xform (obj, q=True, ws=True, t=True))
        tempateControlObjectsStorageData.append(mc.xform (obj,  q=True, os=True, ro=True))
        rootScale = (mc.xform (moduleRoot, q=True, relative = True, scale=True))
        objScaleBuffer = (mc.xform (obj, q=True, relative = True, scale=True))
        objScale = []
        cnt = 0
        for scale in objScaleBuffer:
            objScale.append(scale*rootScale[cnt])
            cnt+=1
        tempateControlObjectsStorageData.append(objScale)
    print tempateControlObjectsStorageData

    #>>> Store the data to the initial objects pos
    """ Get the attributes to store to"""
    initialObjectsTemplateDataBuffer = attributes.returnUserAttrsToList(templateStarterDataInfoNull)
    initialObjectsPosData = lists.removeMatchedIndexEntries(initialObjectsTemplateDataBuffer,'cgm')

    """ store it"""
    cnt=0
    for set in initialObjectsPosData:
        attrBuffer = set[0]
        xBuffer = (templateStarterDataInfoNull+'.'+attrBuffer+'X')
        yBuffer = (templateStarterDataInfoNull+'.'+attrBuffer+'Y')
        zBuffer = (templateStarterDataInfoNull+'.'+attrBuffer+'Z')
        dataSet = storageData[cnt]
        mc.setAttr (xBuffer, dataSet[0])
        mc.setAttr (yBuffer, dataSet[1])
        mc.setAttr (zBuffer, dataSet[2])
        cnt+=1
        
    #>>> Store the data to the initial objects pos
    """ Get the attributes to store to"""
    templateControlObjectsDataNullBuffer = attributes.returnUserAttrsToList(templateControlObjectsDataNull)
    templateControlObjectsData = lists.removeMatchedIndexEntries(templateControlObjectsDataNullBuffer,'cgm')
    
    """ store it"""
    cnt=0
    for set in templateControlObjectsData:
        attrBuffer = set[0]
        xBuffer = (templateControlObjectsDataNull+'.'+attrBuffer+'X')
        yBuffer = (templateControlObjectsDataNull+'.'+attrBuffer+'Y')
        zBuffer = (templateControlObjectsDataNull+'.'+attrBuffer+'Z')
        dataSet = tempateControlObjectsStorageData[cnt]
        mc.setAttr (xBuffer, dataSet[0])
        mc.setAttr (yBuffer, dataSet[1])
        mc.setAttr (zBuffer, dataSet[2])
        cnt+=1 
        
    #>>>>>>need to add locking>>>>>>>>>>>>>>>>>>>>>>>>>>>>    
    print ('%s%s'% (moduleNull,' template object positional/rotational/scale data stored...'))
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Save skin joints to skin joints null
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Delete stuff
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """ Gather our objects"""
    toDeleteList = search.returnObjectsOwnedByModuleNull(templateNull)
    print toDeleteList
    
    for obj in toDeleteList:
        if mc.objExists(obj) == True:
            print ('%s%s'% (obj,' deleted...'))
            mc.delete(obj)

    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Change Tag
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    mc.setAttr ((moduleNull+'.templateState'), 0)
    mc.setAttr ((moduleNull+'.skeletonState'), 1)
    
    #add locking
    
    print ('%s%s'% (moduleNull,' done'))
    return 'done'
import maya.cmds as mc

import Red9.core.Red9_Meta as r9Meta
reload(r9Meta)
from cgm.lib.classes import NameFactory as nameF
reload(nameF)
nameF.doNameObject()
from cgm.core.rigger import MorpheusFactory as morphyF
from cgm.core.rigger import ModuleFactory as mFactory
from cgm.core.rigger import TemplateFactory as tFactory
from cgm.core.rigger import JointFactory as jFactory

from cgm.core import cgm_PuppetMeta as cgmPM

reload(morphyF)
reload(mFactory)
reload(tFactory)
reload(jFactory)

import logging
logging.basicConfig()
log = logging.getLogger(__name__)
log.setLevel(logging.INFO)

obj = mc.ls(sl=True)[0] or False
obj = ''
objList = []

import cgm.core
cgm.core._reload()
#>>> Morpheus
Esempio n. 46
0
def uiLoadAutoNameObject(self):
	selected = []
	bufferList = []
	selected = (mc.ls (sl=True,flatten=True,shortNames=True))
	
	fieldToKeyDict = {'cgmName':self.NameTagField,
                      'cgmType':self.ObjectTypeTagField,
                      'cgmNameModifier':self.NameModifierTagField,
                      'cgmTypeModifier':self.ObjectTypeModifierTagField,
                      'cgmDirectionModifier':self.DirectionModifierTagField,
                      'cgmDirection':self.DirectionTagField,
                      'cgmPosition':self.PositionTagField,
	                  'cgmIterator':self.IteratorTagField}
	
	if selected:
		if len(selected) >= 2:
			guiFactory.warning('Only one object can be loaded')
		else:
			# Put the object in the field
			guiFactory.doLoadSingleObjectToTextField(self.AutoNameObjectField,'cgmVar_AutoNameObject')

			#Get the tag info for the object
			tagsDict = NameFactoryOld.returnObjectGeneratedNameDict(selected[0])
			userAttrs = attributes.returnUserAttributes(selected[0])
			cgmAttrs = NameFactoryOld.returnCGMOrder()
			usedAttrs = lists.returnMatchList(userAttrs,cgmAttrs)
			tagAttrs = tagsDict.keys()
			#Enable the tag fields
			for key in fieldToKeyDict.keys():
				mc.textField(fieldToKeyDict.get(key),edit=True,enable=True,
				             text = '',
				              bgc = dictionary.returnStateColor('normal'))
			
			for key in tagsDict.keys():
				currentField = fieldToKeyDict.get(key)

				
				buildSelectPopUp = {}
				buildLoadPopUp = {}
				#purge popup
				popUpBuffer =  currentField(q=True, popupMenuArray = True)
				if popUpBuffer:
					for item in popUpBuffer:
						mc.deleteUI (item)
				
				mc.textField(currentField,edit=True,text = tagsDict.get(key),
				             bgc = dictionary.returnStateColor('keyed'))
				
				# Set special color cases, if it's guessed or gotten upstream....
				if usedAttrs:
					if key not in usedAttrs:
						mc.textField(currentField,edit = True, bgc = dictionary.returnStateColor('reserved'))
					# if it's connected	
					elif (mc.connectionInfo ((selected[0]+'.'+key),isDestination=True)):
						driverObject = attributes.returnDriverObject(selected[0]+'.'+key)
						driverAttr = attributes.returnDriverAttribute(selected[0]+'.'+key)
						mc.textField(currentField,edit = True,
						             text = (driverAttr),
						             bgc = dictionary.returnStateColor('connected'))
						buildSelectPopUp['Select driver object'] = (driverObject)
						buildLoadPopUp['Load driver object'] = (driverObject)


				else:
					#Got it from a parent
					parentNameObjectRaw = search.returnTagUp(selected[0],key)
					if parentNameObjectRaw:
						if '|' in parentNameObjectRaw[1]:
							parentNameBuffer = parentNameObjectRaw[1].split('|')
							parentNameObject = parentNameBuffer[-1]
						else:
							parentNameObject = parentNameObjectRaw[1]
						mc.textField(currentField,edit = True,
					                 enable=True,
					                 text = parentNameObject,
					                 bgc = dictionary.returnStateColor('semiLocked'))
						buildSelectPopUp['Select parent name object'] = (parentNameObjectRaw[1])
						buildLoadPopUp['Load parent name object'] = (parentNameObjectRaw[1])
					else:
						mc.textField(currentField,edit = True,
					                 bgc = dictionary.returnStateColor('reserved'))
							
				if buildSelectPopUp or buildLoadPopUp:
					buffer = MelPopupMenu(currentField,button = 3)
				if buildSelectPopUp:		
					for key in buildSelectPopUp.keys():
						MelMenuItem(buffer ,
							        label = key,
							        c = ('%s%s%s' %("mc.select('",buildSelectPopUp.get(key),"')")))
				if buildLoadPopUp:		
					for key in buildLoadPopUp.keys():
						MelMenuItem(buffer ,
					                label = key,
					                c = lambda *a:uiLoadParentNameObject(self,buildLoadPopUp.get(key)))
						
						
			# if it's connected
			uiUpdateAutoNamePreview(self)
			
	else:
		#clear the field
		guiFactory.doLoadSingleObjectToTextField(self.AutoNameObjectField,'cgmVar_AutoNameObject')
		# update the fields
		for key in fieldToKeyDict.keys():
			mc.textField(fieldToKeyDict.get(key),edit=True,enable=False,
		                 text = '',
			             bgc = dictionary.returnStateColor('normal'))
			
		# Fix previewer
		uiUpdateAutoNamePreview(self)
Esempio n. 47
0
def locClosest(objectList,targetObject):
	"""
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	DESCRIPTION:
	Creates a locator on the surface of the last object in a selection set closest
	to each remaining object in the selection

	ARGUMENTS:
	objectList

	RETURNS:
	locatorList(list)
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	"""
	bufferList = []

	lastObjectType = search.returnObjectType(targetObject)
	
	#Get our source objects locators as sometimes the pivot has no correlation to the objects pivot - like a cv
	fromObjects = []
	for item in objectList:
		fromObjects.append(locMeObject(item))
	

	if lastObjectType == 'mesh':
		if mayaVersion >=2011:
			for item in fromObjects:
				bufferList.append( locMeClosestPointOnMesh(item, targetObject) )
		else:
			guiFactory.warning('Apologies, but in maya 2010 and below this only supports nurbsSurface target objects')
			return False
	elif lastObjectType == 'nurbsSurface':
		for item in fromObjects:
			bufferList.append( locMeClosestUVOnSurface(item, targetObject) )
	elif lastObjectType == 'nurbsCurve':
		if mayaVersion >=2011:
			for item in fromObjects:
				bufferList.append( locMeClosestPointOnCurve(item, targetObject) )
		else:
			guiFactory.warning('Apologies, but in maya 2010 and below this only supports nurbsSurface target objects')
			return False

	else:
		guiFactory.warning('Your target object must be a mesh, nurbsSurface, or nurbsCurve')
		return False

	for loc in fromObjects:
		mc.delete(loc)
		
	for loc in bufferList:
		cnt = bufferList.index(loc)
		storeList = []
		storeList = objectList
		storeList.append(targetObject)
		attributes.storeInfo(loc,'cgmName',('%s_to_%s'%(objectList[0],objectList[-1])),False)		
		attributes.storeInfo(loc,'cgmSource',(','.join(storeList)),False)
		attributes.storeInfo(loc,'cgmLocMode','closestPoint',False)
		attributes.storeInfo(loc,'cgmTypeModifier','closestPoint',False)
		bufferList[cnt] = NameFactory.doNameObject(loc)


	return bufferList[0]
Esempio n. 48
0
def attachAimedObjectToSurface(obj, surface, aimObject, parent=True):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Script to rename a joint chain list
    
    ARGUMENTS:
    jointList(list) - list of joints in order
    startJointName(string) - what you want the root named
    interiorJointRootName(string) - what you want the iterative name to be
    
    RETURNS:
    newJoints(list)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    """ Make a transform group """
    surfaceLoc = locators.locMeClosestUVOnSurface(obj, surface)
    surfaceFollowGroup = rigging.groupMeObject(surfaceLoc, False)
    transformGroup = rigging.groupMeObject(obj, False)

    surfaceFollowGroup = mc.rename(surfaceFollowGroup,
                                   (obj + '_surfaceFollowGroup'))
    attributes.storeInfo(surfaceFollowGroup, 'object', obj)

    transformGroup = mc.rename(transformGroup,
                               (obj + '_surfaceFollowTransformGroup'))
    attributes.storeInfo(transformGroup, 'object', obj)

    controlSurface = mc.listRelatives(surface, shapes=True)
    """ make the node """
    closestPointNode = mc.createNode('closestPointOnSurface',
                                     name=(obj + '_closestPointInfoNode'))
    """ to account for target objects in heirarchies """
    attributes.doConnectAttr((surfaceLoc + '.translate'),
                             (closestPointNode + '.inPosition'))
    attributes.doConnectAttr((controlSurface[0] + '.worldSpace'),
                             (closestPointNode + '.inputSurface'))

    pointOnSurfaceNode = mc.createNode('pointOnSurfaceInfo',
                                       name=(obj + '_posInfoNode'))
    """ Connect the info node to the surface """
    attributes.doConnectAttr((controlSurface[0] + '.worldSpace'),
                             (pointOnSurfaceNode + '.inputSurface'))
    """ Contect the pos group to the info node"""
    attributes.doConnectAttr((pointOnSurfaceNode + '.position'),
                             (surfaceFollowGroup + '.translate'))
    attributes.doConnectAttr((closestPointNode + '.parameterU'),
                             (pointOnSurfaceNode + '.parameterU'))
    attributes.doConnectAttr((closestPointNode + '.parameterV'),
                             (pointOnSurfaceNode + '.parameterV'))
    """ if we wanna aim """
    if aimObject != False:
        """ make some locs """
        upLoc = locators.locMeObject(surface)
        aimLoc = locators.locMeObject(aimObject)
        attributes.storeInfo(upLoc, 'cgmName', obj)
        attributes.storeInfo(upLoc, 'cgmTypeModifier', 'up')
        upLoc = NameFactory.doNameObject(upLoc)

        attributes.storeInfo(aimLoc, 'cgmName', aimObject)
        attributes.storeInfo(aimLoc, 'cgmTypeModifier', 'aim')
        aimLoc = NameFactory.doNameObject(aimLoc)

        attributes.storeInfo(surfaceFollowGroup, 'locatorUp', upLoc)
        attributes.storeInfo(surfaceFollowGroup, 'aimLoc', aimLoc)
        #mc.parent(upLoc,aimObject)

        boundingBoxSize = distance.returnBoundingBoxSize(surface)
        distance = max(boundingBoxSize) * 2

        mc.xform(upLoc, t=[0, distance, 0], ws=True, r=True)

        attributes.doConnectAttr((aimLoc + '.translate'),
                                 (closestPointNode + '.inPosition'))
        """ constrain the aim loc to the aim object """
        pointConstraintBuffer = mc.pointConstraint(aimObject,
                                                   aimLoc,
                                                   maintainOffset=True,
                                                   weight=1)
        """ aim it """
        aimConstraintBuffer = mc.aimConstraint(aimLoc,
                                               surfaceFollowGroup,
                                               maintainOffset=True,
                                               weight=1,
                                               aimVector=[0, 0, 1],
                                               upVector=[0, 1, 0],
                                               worldUpObject=upLoc,
                                               worldUpType='object')
        """ aim the controller back at the obj"""
        aimConstraintBuffer = mc.aimConstraint(obj,
                                               aimLoc,
                                               maintainOffset=True,
                                               weight=1,
                                               aimVector=[0, 0, -1],
                                               upVector=[0, 1, 0],
                                               worldUpObject=upLoc,
                                               worldUpType='object')

        mc.parent(upLoc, aimObject)
    else:
        mc.delete(closestPointNode)

    transformGroup = rigging.doParentReturnName(transformGroup,
                                                surfaceFollowGroup)
    """finally parent it"""
    if parent == True:
        mc.parent(obj, transformGroup)

    if parent == 'constrain':
        mc.parentConstraint(transformGroup, obj, maintainOffset=True)

    mc.delete(surfaceLoc)
    return [transformGroup, surfaceFollowGroup]
Esempio n. 49
0
def zeroTransformMeObject(obj, scaleZero=False):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Makes sure an object is zeroed out, parents the zero group back to the original objects parent

    ARGUMENTS:
    obj(string)

    RETURNS:
    groupName(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    parent = mc.listRelatives(obj, parent=True, fullPath=True)

    group = groupMeObject(obj, True, True)
    group2 = ''
    attributes.storeInfo(group, 'cgmTypeModifier', 'zero')

    objScale = []
    objScale.append(mc.getAttr(obj + '.sx'))
    objScale.append(mc.getAttr(obj + '.sy'))
    objScale.append(mc.getAttr(obj + '.sz'))

    #Check if we got zero translates
    zeroCheck = mc.xform(obj, q=True, os=True, rp=True)
    if zeroCheck:
        if scaleZero:
            mc.makeIdentity(obj, apply=True, t=0, r=0, s=1)
        group2 = groupMeObject(obj, True, True)
        zeroCheck = mc.xform(obj, q=True, os=True, rp=True)

        zeroCheck = cgmMath.multiplyLists([objScale, zeroCheck])
        mc.xform(group2,
                 t=(-zeroCheck[0], -zeroCheck[1], -zeroCheck[2]),
                 os=True)
        attributes.storeInfo(group, 'cgmTypeModifier', 'zeroParent')
        attributes.storeInfo(group2, 'cgmTypeModifier', 'zero')
        group2 = NameFactoryOld.doNameObject(group2)

        for attr in 'tx', 'ty', 'tz':
            attributes.doSetAttr(obj, attr, 0)

    #Check for zero rotates
    rotateCheck = mc.xform(obj, q=True, os=True, ro=True)
    if rotateCheck:
        if not group2:
            group2 = groupMeObject(obj, True, True)
            attributes.storeInfo(group, 'cgmTypeModifier', 'zeroParent')
            attributes.storeInfo(group2, 'cgmTypeModifier', 'zero')
            NameFactoryOld.doNameObject(group2)

        mc.xform(group2,
                 ro=(rotateCheck[0], rotateCheck[1], rotateCheck[2]),
                 os=True)
        for attr in 'rx', 'ry', 'rz':
            attributes.doSetAttr(obj, attr, 0)
    """
    objScale = []
    objScale.append(mc.getAttr(obj+'.sx'))
    objScale.append(mc.getAttr(obj+'.sy'))
    objScale.append(mc.getAttr(obj+'.sz'))
    grpScale = []
    grpScale.append(mc.getAttr(group+'.sx'))
    grpScale.append(mc.getAttr(group+'.sy'))
    grpScale.append(mc.getAttr(group+'.sz'))
    multScale = cgmMath.multiplyLists([objScale,grpScale])
    
    mc.scale(multScale[0], multScale[1], multScale[2],[group])
    for attr in 'sx','sy','sz':
        attributes.doSetAttr(obj,attr,1)
    """
    return NameFactoryOld.doNameObject(group)
Esempio n. 50
0
    def createSizeTemplateControl(self):
        """ 
        >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   
        DESCRIPTION:
        Generates a sizeTemplateObject. It's been deleted, it recreates it. Guess the size based off of there
        being a mesh there. If there is no mesh, it sets sets an intial size of a 
        [155,170,29] unit character.
        
        ARGUMENTS:
        self.PuppetNull.nameShort(string)
        
        RETURNS:
        returnList(list) = [startCrv(string),EndCrv(list)]
        >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        """
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        # Get info
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        startColors = modules.returnSettingsData('colorStart')
        endColors = modules.returnSettingsData('colorEnd')

        font = mc.getAttr((self.msgSettingsInfo.get() + '.font'))
        """ checks for there being anything in our geo group """
        if not self.geo:
            return guiFactory.warning(
                'Need some geo defined to make this tool worthwhile')
            boundingBoxSize = modules.returnSettingsDataAsFloat(
                'meshlessSizeTemplate')
        else:
            boundingBoxSize = distance.returnBoundingBoxSize(
                self.msgGeoGroup.get())
            boundingBox = mc.exactWorldBoundingBox(self.msgGeoGroup.get())
        """determine orienation """
        maxSize = max(boundingBoxSize)
        matchIndex = boundingBoxSize.index(maxSize)
        """Find the pivot of the bounding box """
        pivotPosition = distance.returnCenterPivotPosition(
            self.msgGeoGroup.get())

        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        # Get our positions
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        if self.optionPuppetMode.get() == 0:
            #If bio...
            if matchIndex == 1 or matchIndex == 0:
                #Vertical
                posBuffers = [[0, .5, 0], [0, .75, 0]]
                width = (boundingBoxSize[0] / 2)
                height = (boundingBoxSize[1])
                depth = boundingBoxSize[2]

                for cnt, pos in enumerate(posBuffers):
                    posBuffer = posBuffers[cnt]
                    posBuffer[0] = 0
                    posBuffer[1] = (posBuffer[1] * height)
                    posBuffer[2] = 0

            elif matchIndex == 2:
                #Horizontal
                posBuffers = [[0, 0, -.33], [0, 0, .66]]
                width = boundingBoxSize[1]
                height = boundingBoxSize[2] / 2
                depth = (boundingBoxSize[0])

                for cnt, pos in enumerate(posBuffers):
                    posBuffer = posBuffers[cnt]
                    posBuffer[0] = 0
                    posBuffer[1] = boundingBoxSize[1] * .75
                    posBuffer[2] = (posBuffer[2] * height)

        else:
            #Otherwise
            if matchIndex == 1 or matchIndex == 0:
                #Vertical
                width = (boundingBoxSize[0] / 2)
                height = (boundingBoxSize[1])
                depth = boundingBoxSize[2]
                posBuffers = [[0, boundingBox[1], 0], [0, boundingBox[4], 0]]

            elif matchIndex == 2:
                #Horizontal
                width = boundingBoxSize[0]
                height = boundingBoxSize[2] / 2
                depth = (boundingBoxSize[1])
                startHeight = max([boundingBox[4], boundingBox[1]]) - depth / 2
                print startHeight
                posBuffers = [[0, startHeight, boundingBox[2]],
                              [0, startHeight, boundingBox[5]]]
        # Simple reverse of start pos buffers if the object is pointing negative
        if self.optionAimAxis < 2:
            posBuffers.reverse()

        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        # Making the controls
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        """ make our control object """
        startCurves = []
        startCurve = curves.createControlCurve('circle', depth * .8)
        mc.xform(startCurve, t=posBuffers[0], ws=True)
        attributes.doSetAttr(startCurve, 'rotateOrder', 5)
        curves.setCurveColorByName(startCurve, startColors[1])
        startCurves.append(startCurve)

        startText = curves.createTextCurve('start',
                                           size=depth * .75,
                                           font=font)
        mc.xform(startText, t=posBuffers[0], ws=True)
        curves.setCurveColorByName(startText, startColors[0])
        startCurves.append(startText)

        endCurves = []
        endCurve = curves.createControlCurve('circle', depth * .8)
        mc.xform(endCurve, t=posBuffers[1], ws=True)
        curves.setCurveColorByName(endCurve, endColors[1])
        attributes.doSetAttr(endCurve, 'rotateOrder', 5)
        endCurves.append(endCurve)

        endText = curves.createTextCurve('end', size=depth * .6, font=font)
        mc.xform(endText, t=posBuffers[1], ws=True)
        curves.setCurveColorByName(endText, endColors[0])
        endCurves.append(endText)
        """ aiming """
        position.aimSnap(startCurve, endCurve, [0, 0, 1], [0, 1, 0])
        position.aimSnap(startText, endCurve, [0, 0, 1], [0, 1, 0])

        position.aimSnap(endCurve, startCurve, [0, 0, -1], [0, 1, 0])
        position.aimSnap(endText, startCurve, [0, 0, -1], [0, 1, 0])

        sizeCurveControlStart = curves.combineCurves(startCurves)
        sizeCurveControlEnd = curves.combineCurves(endCurves)
        """ store our info to name our objects"""
        attributes.storeInfo(sizeCurveControlStart, 'cgmName',
                             (self.PuppetNull.nameShort + '.cgmName'))
        attributes.storeInfo(sizeCurveControlStart, 'cgmDirection', 'start')
        attributes.storeInfo(sizeCurveControlStart, 'cgmType',
                             'templateSizeObject')
        sizeCurveControlStart = NameFactory.doNameObject(sizeCurveControlStart)
        mc.makeIdentity(sizeCurveControlStart,
                        apply=True,
                        t=True,
                        s=True,
                        r=True)

        attributes.storeInfo(sizeCurveControlEnd, 'cgmName',
                             (self.PuppetNull.nameShort + '.cgmName'))
        attributes.storeInfo(sizeCurveControlEnd, 'cgmDirection', 'end')
        attributes.storeInfo(sizeCurveControlEnd, 'cgmType',
                             'templateSizeObject')
        sizeCurveControlEnd = NameFactory.doNameObject(sizeCurveControlEnd)

        endGroup = rigging.groupMeObject(sizeCurveControlEnd)
        mc.makeIdentity(sizeCurveControlEnd,
                        apply=True,
                        t=True,
                        s=True,
                        r=True)

        mc.parentConstraint(sizeCurveControlStart,
                            endGroup,
                            maintainOffset=True)
        """ make control group """
        controlGroup = rigging.groupMeObject(sizeCurveControlStart)
        attributes.storeInfo(controlGroup, 'cgmName',
                             (self.PuppetNull.nameShort + '.cgmName'))
        attributes.storeInfo(controlGroup, 'cgmType',
                             'templateSizeObjectGroup')
        controlGroup = NameFactory.doNameObject(controlGroup)

        endGroup = rigging.doParentReturnName(endGroup, controlGroup)
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        # Getting data ready
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        attributes.storeInfo(controlGroup, 'controlStart',
                             sizeCurveControlStart)
        attributes.storeInfo(controlGroup, 'controlEnd', sizeCurveControlEnd)
        attributes.storeInfo(self.PuppetNull.nameShort, 'templateSizeObject',
                             controlGroup)

        self.templateSizeObjects['root'] = controlGroup
        self.templateSizeObjects['start'] = sizeCurveControlStart
        self.templateSizeObjects['end'] = sizeCurveControlEnd

        returnList = []
        returnList.append(sizeCurveControlStart)
        returnList.append(sizeCurveControlEnd)
        return returnList
Esempio n. 51
0
def attachAimedObjectToSurface (obj, surface, aimObject, parent = True):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Script to rename a joint chain list
    
    ARGUMENTS:
    jointList(list) - list of joints in order
    startJointName(string) - what you want the root named
    interiorJointRootName(string) - what you want the iterative name to be
    
    RETURNS:
    newJoints(list)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    
    """ Make a transform group """
    surfaceLoc = locators.locMeClosestUVOnSurface(obj,surface)
    surfaceFollowGroup = rigging.groupMeObject(surfaceLoc,False)
    transformGroup = rigging.groupMeObject(obj,False)
    
    surfaceFollowGroup = mc.rename(surfaceFollowGroup,(obj+'_surfaceFollowGroup'))
    attributes.storeInfo(surfaceFollowGroup,'object',obj)  
    
    transformGroup = mc.rename(transformGroup,(obj+'_surfaceFollowTransformGroup'))
    attributes.storeInfo(transformGroup,'object',obj) 
    
    
    controlSurface = mc.listRelatives(surface,shapes=True)
    
    """ make the node """
    closestPointNode = mc.createNode ('closestPointOnSurface',name= (obj+'_closestPointInfoNode'))
    """ to account for target objects in heirarchies """
    attributes.doConnectAttr((surfaceLoc+'.translate'),(closestPointNode+'.inPosition'))
    attributes.doConnectAttr((controlSurface[0]+'.worldSpace'),(closestPointNode+'.inputSurface'))
    
    pointOnSurfaceNode = mc.createNode ('pointOnSurfaceInfo',name= (obj+'_posInfoNode'))
    """ Connect the info node to the surface """                  
    attributes.doConnectAttr  ((controlSurface[0]+'.worldSpace'),(pointOnSurfaceNode+'.inputSurface'))
    """ Contect the pos group to the info node"""
    attributes.doConnectAttr ((pointOnSurfaceNode+'.position'),(surfaceFollowGroup+'.translate'))
    attributes.doConnectAttr ((closestPointNode+'.parameterU'),(pointOnSurfaceNode+'.parameterU'))
    attributes.doConnectAttr  ((closestPointNode+'.parameterV'),(pointOnSurfaceNode+'.parameterV'))

    """ if we wanna aim """
    if aimObject != False: 
        """ make some locs """
        upLoc = locators.locMeObject(surface)
        aimLoc = locators.locMeObject(aimObject)
        attributes.storeInfo(upLoc,'cgmName',obj)
        attributes.storeInfo(upLoc,'cgmTypeModifier','up')
        upLoc = NameFactoryOld.doNameObject(upLoc)
        
        attributes.storeInfo(aimLoc,'cgmName',aimObject)
        attributes.storeInfo(aimLoc,'cgmTypeModifier','aim')
        aimLoc = NameFactoryOld.doNameObject(aimLoc)

        attributes.storeInfo(surfaceFollowGroup,'locatorUp',upLoc)
        attributes.storeInfo(surfaceFollowGroup,'aimLoc',aimLoc)
        #mc.parent(upLoc,aimObject)
        
        boundingBoxSize = distance.returnBoundingBoxSize(surface)
        distance = max(boundingBoxSize)*2
        
        mc.xform(upLoc,t = [0,distance,0],ws=True,r=True)
        
        attributes.doConnectAttr((aimLoc+'.translate'),(closestPointNode+'.inPosition'))

        """ constrain the aim loc to the aim object """
        pointConstraintBuffer = mc.pointConstraint(aimObject,aimLoc,maintainOffset = True, weight = 1)
        
        """ aim it """
        aimConstraintBuffer = mc.aimConstraint(aimLoc,surfaceFollowGroup,maintainOffset = True, weight = 1, aimVector = [0,0,1], upVector = [0,1,0], worldUpObject = upLoc, worldUpType = 'object' )

        """ aim the controller back at the obj"""
        aimConstraintBuffer = mc.aimConstraint(obj,aimLoc,maintainOffset = True, weight = 1, aimVector = [0,0,-1], upVector = [0,1,0], worldUpObject = upLoc, worldUpType = 'object' )
        
        mc.parent(upLoc,aimObject)
    else:
        mc.delete(closestPointNode)
    
    transformGroup = rigging.doParentReturnName(transformGroup,surfaceFollowGroup)
    """finally parent it"""    
    if parent == True:
        mc.parent(obj,transformGroup)
        
    if parent == 'constrain':
        mc.parentConstraint(transformGroup,obj,maintainOffset = True)
    
    mc.delete(surfaceLoc)
    return [transformGroup,surfaceFollowGroup]
Esempio n. 52
0
def createMasterNull(characterName='nothingNothing'):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Creates a masterNull for a character/asset
    
    ARGUMENTS:
    characterName(string)
    
    RETURNS:
    masterNull(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    if characterName == 'nothingNothing':
        randomOptions = ['David', 'Josh', 'NameMe', 'Homer', 'Georgie']
        characterName = random.choice(randomOptions)

    #Create main null
    masterNullBuffer = mc.group(empty=True)
    attributes.storeInfo(masterNullBuffer, 'cgmName', characterName)
    attributes.storeInfo(masterNullBuffer, 'cgmType', 'ignore')
    attributes.storeInfo(masterNullBuffer, 'cgmModuleType', 'master')
    masterNull = NameFactory.doNameObject(masterNullBuffer)

    #Create modules container null
    modulesGroupBuffer = mc.group(empty=True)
    attributes.storeInfo(modulesGroupBuffer, 'cgmName', 'modules')
    attributes.storeInfo(modulesGroupBuffer, 'cgmType', 'group')
    modulesGroup = NameFactory.doNameObject(modulesGroupBuffer)
    modulesGroup = rigging.doParentReturnName(modulesGroup, masterNull)
    attributes.storeObjectToMessage(modulesGroup, masterNull, 'modulesGroup')

    #Create modules container null
    meshGroupBuffer = mc.group(empty=True)
    attributes.storeInfo(meshGroupBuffer, 'cgmName', 'geo')
    attributes.storeInfo(modulesGroupBuffer, 'cgmType', 'group')
    meshGroup = NameFactory.doNameObject(modulesGroupBuffer)
    meshGroup = rigging.doParentReturnName(meshGroup, masterNull)
    attributes.storeObjectToMessage(meshGroup, masterNull, 'geoGroup')

    #Create master info null
    masterInfoNull = createInfoNull('master')
    attributes.storeObjectToMessage(masterInfoNull, masterNull, 'info')
    masterInfoNull = rigging.doParentReturnName(masterInfoNull, masterNull)

    #Create modules info null
    modulesInfoNull = createInfoNull('modules')
    attributes.storeObjectToMessage(modulesInfoNull, masterInfoNull, 'modules')
    modulesInfoNull = rigging.doParentReturnName(modulesInfoNull,
                                                 masterInfoNull)

    #Create mesh info null
    meshInfoNull = createInfoNull('geo')
    attributes.storeObjectToMessage(meshInfoNull, masterInfoNull, 'geo')
    modulesInfoNull = rigging.doParentReturnName(meshInfoNull, masterInfoNull)

    #Create global settings info null
    settingsInfoNull = createInfoNull('settings')
    attributes.storeObjectToMessage(settingsInfoNull, masterInfoNull,
                                    'settings')
    settingsInfoNull = rigging.doParentReturnName(settingsInfoNull,
                                                  masterInfoNull)
    defaultFont = returnSettingsData('defaultTextFont')
    attributes.storeInfo(settingsInfoNull, 'font', defaultFont)

    return masterNull
Esempio n. 53
0
def saveTemplateToModule(moduleNull):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
	* Save the new positional information from the template objects
	* Collect all names of objects for a delete list
	* If anything in the module doesn't belong there, un parent it, report it
		* like a template object parented to another obect

    ARGUMENTS:
    moduleNull(string)
    
    RETURNS:
    limbJoints(list)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Variables
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Get our base info
    """ module null data """
    moduleNullData = attributes.returnUserAttrsToDict(moduleNull)
    """ part name """
    partName = NameFactory.returnUniqueGeneratedName(moduleNull,
                                                     ignore='cgmType')
    partType = moduleNullData.get('cgmModuleType')
    direction = moduleNullData.get('cgmDirection')
    """ template null """
    templateNull = moduleNullData.get('templateNull')
    templateNullData = attributes.returnUserAttrsToDict(templateNull)
    """ template object nulls """
    templatePosObjectsInfoNull = returnInfoTypeNull(moduleNull,
                                                    'templatePosObjects')
    templatePosObjectsInfoData = attributes.returnUserAttrsToDict(
        templatePosObjectsInfoNull)
    templateControlObjectsNull = returnInfoTypeNull(moduleNull,
                                                    'templateControlObjects')
    templateControlObjectsData = attributes.returnUserAttrsToDict(
        templateControlObjectsNull)
    """ rig null """
    rigNull = moduleNullData.get('rigNull')
    """ Start objects stuff """
    templateStarterDataInfoNull = returnInfoTypeNull(moduleNull,
                                                     'templateStarterData')
    templateControlObjectsDataNull = returnInfoTypeNull(
        moduleNull, 'templateControlObjectsData')
    """ AutonameStuff """
    divider = NameFactory.returnCGMDivider()
    moduleRootBuffer = returnInfoNullObjects(moduleNull,
                                             'templatePosObjects',
                                             types='templateRoot')
    moduleRoot = moduleRootBuffer[0]
    templateObjects = []
    coreNamesArray = []
    #>>>TemplateInfo
    for key in templatePosObjectsInfoData.keys():
        if (mc.attributeQuery(key, node=templatePosObjectsInfoNull,
                              msg=True)) == True:
            templateObjects.append(templatePosObjectsInfoData[key])
        coreNamesArray.append(key)

    posTemplateObjects = []
    """ Get the positional template objects"""
    for obj in templateObjects:
        bufferList = obj.split(divider)
        if (typesDictionary.get('templateObject')) in bufferList:
            posTemplateObjects.append(obj)
    """ get our control template objects """
    controlTemplateObjects = []
    for key in templateControlObjectsData.keys():
        if (mc.attributeQuery(key, node=templateControlObjectsNull,
                              msg=True)) == True:
            controlTemplateObjects.append(templateControlObjectsData[key])
    """put objects in order of closeness to root"""
    posTemplateObjects = distance.returnDistanceSortedList(
        moduleRoot, posTemplateObjects)
    controlTemplateObjects = distance.returnDistanceSortedList(
        moduleRoot, controlTemplateObjects)
    curve = (templatePosObjectsInfoData['curve'])

    #>>> get our orientation helpers
    helperObjects = []
    for obj in posTemplateObjects:
        helperObjects.append(
            attributes.returnMessageObject(obj, 'orientHelper'))

    masterOrient = (attributes.returnMessageObject(moduleRoot, 'orientHelper'))

    print('%s%s' % (moduleNull, ' data acquired...'))
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Save Data
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Get the data
    """ pos objects """
    storageData = []
    for obj in posTemplateObjects:
        storageData.append(mc.xform(obj, q=True, ws=True, sp=True))
    """ orientation helpers """
    for obj in helperObjects:
        storageData.append(mc.xform(obj, q=True, os=True, ro=True))

    storageData.append(mc.xform(masterOrient, q=True, os=True, ro=True))
    print storageData
    """ template control objects data"""
    tempateControlObjectsStorageData = []
    for obj in controlTemplateObjects:
        print obj
        tempateControlObjectsStorageData.append(
            mc.xform(obj, q=True, ws=True, t=True))
        tempateControlObjectsStorageData.append(
            mc.xform(obj, q=True, os=True, ro=True))
        rootScale = (mc.xform(moduleRoot, q=True, relative=True, scale=True))
        objScaleBuffer = (mc.xform(obj, q=True, relative=True, scale=True))
        objScale = []
        cnt = 0
        for scale in objScaleBuffer:
            objScale.append(scale * rootScale[cnt])
            cnt += 1
        tempateControlObjectsStorageData.append(objScale)
    print tempateControlObjectsStorageData

    #>>> Store the data to the initial objects pos
    """ Get the attributes to store to"""
    initialObjectsTemplateDataBuffer = attributes.returnUserAttrsToList(
        templateStarterDataInfoNull)
    initialObjectsPosData = lists.removeMatchedIndexEntries(
        initialObjectsTemplateDataBuffer, 'cgm')
    """ store it"""
    cnt = 0
    for set in initialObjectsPosData:
        attrBuffer = set[0]
        xBuffer = (templateStarterDataInfoNull + '.' + attrBuffer + 'X')
        yBuffer = (templateStarterDataInfoNull + '.' + attrBuffer + 'Y')
        zBuffer = (templateStarterDataInfoNull + '.' + attrBuffer + 'Z')
        dataSet = storageData[cnt]
        mc.setAttr(xBuffer, dataSet[0])
        mc.setAttr(yBuffer, dataSet[1])
        mc.setAttr(zBuffer, dataSet[2])
        cnt += 1

    #>>> Store the data to the initial objects pos
    """ Get the attributes to store to"""
    templateControlObjectsDataNullBuffer = attributes.returnUserAttrsToList(
        templateControlObjectsDataNull)
    templateControlObjectsData = lists.removeMatchedIndexEntries(
        templateControlObjectsDataNullBuffer, 'cgm')
    """ store it"""
    cnt = 0
    for set in templateControlObjectsData:
        attrBuffer = set[0]
        xBuffer = (templateControlObjectsDataNull + '.' + attrBuffer + 'X')
        yBuffer = (templateControlObjectsDataNull + '.' + attrBuffer + 'Y')
        zBuffer = (templateControlObjectsDataNull + '.' + attrBuffer + 'Z')
        dataSet = tempateControlObjectsStorageData[cnt]
        mc.setAttr(xBuffer, dataSet[0])
        mc.setAttr(yBuffer, dataSet[1])
        mc.setAttr(zBuffer, dataSet[2])
        cnt += 1

    #>>>>>>need to add locking>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    print('%s%s' %
          (moduleNull,
           ' template object positional/rotational/scale data stored...'))
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Save skin joints to skin joints null
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Delete stuff
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """ Gather our objects"""
    toDeleteList = search.returnObjectsOwnedByModuleNull(templateNull)
    print toDeleteList

    for obj in toDeleteList:
        if mc.objExists(obj) == True:
            print('%s%s' % (obj, ' deleted...'))
            mc.delete(obj)

    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Change Tag
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    mc.setAttr((moduleNull + '.templateState'), 0)
    mc.setAttr((moduleNull + '.skeletonState'), 1)

    #add locking

    print('%s%s' % (moduleNull, ' done'))
    return 'done'
Esempio n. 54
0
def doPointAimConstraintObjectGroup(targets,object,mode=0): 
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    ACKNOWLEDGEMENT:
    Idea for this stype of constraint setup is from http://td-matt.blogspot.com/2011/01/spine-control-rig.html
    
    DESCRIPTION:
    Groups an object and constrains that group to the other objects
    
    ARGUMENTS:
    targets(list) - should be in format of from to back with the last one being the aim object
    object(string)
    mode(int) - 0 - equal influence
                1 - distance spread
    
    RETURNS:
    group(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    returnList = []
    """ figure out which is the aim direction  """
    aimVector = logic.returnLocalAimDirection(object,targets[-1])
    upVector = logic.returnLocalUp(aimVector)
    
    """ create locators """
    locs = []
    toMake = ['point','aim','up']
    for type in toMake:
        locBuffer = locators.locMeObject(object)
        attributes.storeInfo(locBuffer,'cgmName',object)
        attributes.storeInfo(locBuffer,'cgmTypeModifier',type)
        locs.append(NameFactory.doNameObject(locBuffer))
    
    pointLoc = locs[0]
    aimLoc = locs[1]
    upLoc = locs[2]

    """ move the locators """
    mc.xform(aimLoc,t=aimVector,r=True,os=True)
    mc.xform(upLoc,t=upVector,r=True,os=True)
    
    """group constraint"""
    objGroup = rigging.groupMeObject(object,True,True)
    attributes.storeInfo(objGroup,'cgmName',object)
    attributes.storeInfo(objGroup,'cgmTypeModifier','follow')
    objGroup = NameFactory.doNameObject(objGroup)
    
    pointConstraintBuffer = mc.pointConstraint (pointLoc,objGroup, maintainOffset=False)
    aimConstraintBuffer = mc.aimConstraint(aimLoc,objGroup,maintainOffset = False, weight = 1, aimVector = aimVector, upVector = upVector, worldUpObject = upLoc, worldUpType = 'object' )

    """loc constraints"""
    locConstraints = []
    for loc in locs:
        parentConstraintBuffer = mc.parentConstraint (targets,loc, maintainOffset=True)
        locConstraints.append(parentConstraintBuffer[0])
    
    if mode == 1:
        distances = []
        for target in targets:
            distances.append(distance.returnDistanceBetweenObjects(target,objGroup))
        normalizedDistances = cgmMath.normList(distances)
        for constraint in locConstraints:
            targetWeights = mc.parentConstraint(constraint,q=True, weightAliasList=True)      
            cnt=1
            for value in normalizedDistances:
                mc.setAttr(('%s%s%s' % (constraint,'.',targetWeights[cnt])),value )
                cnt-=1

    returnList.append(objGroup)
    returnList.append(locs)
    return returnList
Esempio n. 55
0
 def create(self):
     """ Creates a cgm buffer object """        
     buffer = mc.group(em=True)
     attributes.storeInfo(buffer,'cgmName',self.baseName)
     buffer = NameFactory.doNameObject(buffer,True)
     self.storeNameStrings(buffer)
Esempio n. 56
0
def zeroTransformMeObject(obj,scaleZero=False):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Makes sure an object is zeroed out, parents the zero group back to the original objects parent

    ARGUMENTS:
    obj(string)

    RETURNS:
    groupName(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    parent = mc.listRelatives(obj,parent=True,fullPath = True)

    group = groupMeObject(obj,True,True)
    group2 = ''
    attributes.storeInfo(group,'cgmTypeModifier','zero')
    
    
    objScale = []
    objScale.append(mc.getAttr(obj+'.sx'))
    objScale.append(mc.getAttr(obj+'.sy'))
    objScale.append(mc.getAttr(obj+'.sz'))
    
    #Check if we got zero translates
    zeroCheck = mc.xform (obj, q=True, os=True, rp=True)
    if zeroCheck:
        if scaleZero:
            mc.makeIdentity(obj,apply=True,t=0,r=0,s=1)              
        group2 = groupMeObject(obj,True,True)
        zeroCheck = mc.xform (obj, q=True, os=True, rp=True)
        
        zeroCheck = cgmMath.multiplyLists([objScale,zeroCheck])
        mc.xform (group2,t=(-zeroCheck[0],-zeroCheck[1],-zeroCheck[2]), os=True)
        attributes.storeInfo(group,'cgmTypeModifier','zeroParent')
        attributes.storeInfo(group2,'cgmTypeModifier','zero')
        group2 = NameFactoryOld.doNameObject(group2) 
    
        for attr in 'tx','ty','tz':
            attributes.doSetAttr(obj, attr, 0)
    
    #Check for zero rotates
    rotateCheck = mc.xform(obj, q=True, os=True, ro=True)
    if rotateCheck:
        if not group2:
            group2 = groupMeObject(obj,True,True)
            attributes.storeInfo(group,'cgmTypeModifier','zeroParent')
            attributes.storeInfo(group2,'cgmTypeModifier','zero')
            NameFactoryOld.doNameObject(group2) 
        
        mc.xform (group2,ro=(rotateCheck[0],rotateCheck[1],rotateCheck[2]), os=True)
        for attr in 'rx','ry','rz':
            attributes.doSetAttr(obj, attr, 0)        
    
    """
    objScale = []
    objScale.append(mc.getAttr(obj+'.sx'))
    objScale.append(mc.getAttr(obj+'.sy'))
    objScale.append(mc.getAttr(obj+'.sz'))
    grpScale = []
    grpScale.append(mc.getAttr(group+'.sx'))
    grpScale.append(mc.getAttr(group+'.sy'))
    grpScale.append(mc.getAttr(group+'.sz'))
    multScale = cgmMath.multiplyLists([objScale,grpScale])
    
    mc.scale(multScale[0], multScale[1], multScale[2],[group])
    for attr in 'sx','sy','sz':
        attributes.doSetAttr(obj,attr,1)
    """
    return NameFactoryOld.doNameObject(group)
Esempio n. 57
0
def groupMeObject(obj, parent=True, maintainParent=False):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Pass  an object into it and return group placed at the pivots -
    matching translation, rotation and rotation order and grouping
    it under the grp

    ARGUMENTS:
    obj(string)
    parent(bool) - Whether to parent the object to the group

    RETURNS:
    groupName(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    if maintainParent == True:
        oldParent = mc.listRelatives(obj, parent=True, fullPath=True)
        if oldParent: oldParent = oldParent[0]
    returnBuffer = []
    rotationOrderDictionary = {
        'xyz': 0,
        'yzx': 1,
        'zxy': 2,
        'xzy': 3,
        'yxz': 4,
        'zyx': 5,
        'none': 6
    }

    #_matrix = mc.xform (obj, q=True, m =True)
    #groupBuffer = mc.group (w=True, empty=True)
    #mc.xform(groupBuffer, m = _matrix)
    #mc.xform(groupBuffer,ra=[0,0,0],p=True)
    #mc.xform(groupBuffer, roo = 'xyz', p=True)#...always do pushing values in xyz
    #objRot = mc.xform(groupBuffer, q=True, os = True, ro=True)
    #objRa = mc.xform(groupBuffer, q=True, os = True, ra=True)
    #mc.xform(groupBuffer, os = True, ra=[v + objRot[i] for i,v in enumerate(objRa)])
    #mc.xform(groupBuffer,os=True, ro = [0,0,0])#...clear

    #mc.xform(groupBuffer, roo = mc.xform (obj, q=True, roo=True ), p=True)#...match rotateOrder

    #return stuff to transfer
    objTrans = mc.xform(obj, q=True, ws=True, rp=True)
    objRot = mc.xform(obj, q=True, ws=True, ro=True)
    objRotAxis = mc.xform(obj, q=True, ws=True, ra=True)

    #return rotation order
    groupBuffer = mc.group(w=True, empty=True)
    #mc.setAttr ((groupBuffer+'.rotateOrder'), correctRo)
    mc.xform(groupBuffer, roo=mc.xform(obj, q=True,
                                       roo=True))  #...match rotateOrder
    mc.move(objTrans[0], objTrans[1], objTrans[2], [groupBuffer])
    #for i,a in enumerate(['X','Y','Z']):
    #attributes.doSetAttr(groupBuffer, 'rotateAxis{0}'.format(a), objRotAxis[i])
    #mc.rotate(objRot[0], objRot[1], objRot[2], [groupBuffer], ws=True)
    mc.xform(groupBuffer, ws=True, ro=objRot, p=False)
    mc.xform(groupBuffer, ws=True, ra=objRotAxis, p=False)

    #mc.xform (groupBuffer, cp=True)

    if maintainParent == True and oldParent:
        #for attr in ['tx','ty','tz','rx','ry','rz','sx','sy','sz']:
        groupBuffer = doParentReturnName(groupBuffer, oldParent)
    if parent:
        _wasLocked = []
        for attr in ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']:
            attrBuffer = '%s.%s' % (obj, attr)
            if mc.getAttr(attrBuffer, lock=True):
                _wasLocked.append(attr)
                mc.setAttr(attrBuffer, lock=False)
            #attributes.doSetAttr(obj,attr,0)
        obj = doParentReturnName(obj, groupBuffer)
        #for attr in ['tx','ty','tz','rx','ry','rz']:
        #if attributes.doGetAttr(obj,attr):
        #attributes.doSetAttr(obj,attr,0)
        if _wasLocked:
            for attr in _wasLocked:
                attrBuffer = '%s.%s' % (obj, attr)
                mc.setAttr(attrBuffer, lock=True)

    return NameFactoryOld.doNameObject(groupBuffer, True)