Ejemplo n.º 1
0
def doNameObject(obj,sceneUnique = False):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Names an object, when forceOverride is False, will select conflicting objects

    ARGUMENTS:
    obj(string) - the object we'd like to name
    forceOverride(bool)- whether to rename conflicts or not

    RETURNS:
    newName(string) on success
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    ### input check
    assert mc.objExists(obj) is True, "'%s' doesn't exist" %obj
    name = returnUniqueGeneratedName(obj,sceneUnique = sceneUnique)
    nameFactory = NameFactory(obj)
    
    if nameFactory.amIMe(name):
        guiFactory.warning("'%s' is already named correctly."%nameFactory.nameBase)
        return name
    else:
        objLong = mc.ls(obj,long=True)
        renameBuffer = mc.rename(objLong,name)

        shapes = mc.listRelatives(renameBuffer,shapes=True,fullPath=True)
        if shapes:
            for shape in shapes:
                name = returnUniqueGeneratedName(shape,sceneUnique = sceneUnique)
                mc.rename(shape,name)
    
        return renameBuffer
Ejemplo n.º 2
0
def doNameObject(obj, sceneUnique=False):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Names an object, when forceOverride is False, will select conflicting objects

    ARGUMENTS:
    obj(string) - the object we'd like to name
    forceOverride(bool)- whether to rename conflicts or not

    RETURNS:
    newName(string) on success
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    ### input check
    assert mc.objExists(obj) is True, "'%s' doesn't exist" % obj
    name = returnUniqueGeneratedName(obj, sceneUnique=sceneUnique)
    nameFactory = NameFactory(obj)

    if nameFactory.amIMe(name):
        guiFactory.warning("'%s' is already named correctly." %
                           nameFactory.nameBase)
        return name
    else:
        objLong = mc.ls(obj, long=True)
        renameBuffer = mc.rename(objLong, name)

        shapes = mc.listRelatives(renameBuffer, shapes=True, fullPath=True)
        if shapes:
            for shape in shapes:
                name = returnUniqueGeneratedName(shape,
                                                 sceneUnique=sceneUnique)
                mc.rename(shape, name)

        return renameBuffer
Ejemplo n.º 3
0
def returnFastIterateNumber(obj):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Check through a scene to figure out what iterative number an obj

    ARGUMENTS:
    obj(string)

    RETURNS:
    order(list)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    #>>> input check
    assert mc.objExists(obj) is True, "'%s' doesn't exist" %obj
    
    objToQuery = NameFactory(obj)
    
    return objToQuery.getFastIterator()
Ejemplo n.º 4
0
def returnFastIterateNumber(obj):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Check through a scene to figure out what iterative number an obj

    ARGUMENTS:
    obj(string)

    RETURNS:
    order(list)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    #>>> input check
    assert mc.objExists(obj) is True, "'%s' doesn't exist" % obj

    objToQuery = NameFactory(obj)

    return objToQuery.getFastIterator()
Ejemplo n.º 5
0
def returnUniqueGeneratedName(obj, sceneUnique=False, ignore='none'):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Returns a generated name with iteration for heirarchy objects with the same tag info

    ARGUMENTS:
    obj(string) - object
    ignore(string) - default is 'none', only culls out cgmtags that are 
                     generated via returnCGMOrder() function

    RETURNS:
    name(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """

    #>>> Dictionary driven order first build
    def doBuildName():
        nameBuilder = []
        for item in order:
            buffer = updatedNamesDict.get(item)
            # Check for short name
            buffer = search.returnTagInfoShortName(buffer, item)
            if buffer > 0 and buffer != 'ignore':
                nameBuilder.append(buffer)

        return divider.join(nameBuilder)

    rawNamesDict = returnObjectGeneratedNameDict(obj, ignore)
    divider = returnCGMDivider()
    updatedNamesDict = returnObjectGeneratedNameDict(obj, ignore)
    order = returnCGMOrder()

    if 'cgmName' not in updatedNamesDict.keys():
        buffer = mc.ls(obj, shortNames=True)
        attributes.storeInfo(obj, 'cgmName', buffer[0], True)
        updatedNamesDict = returnObjectGeneratedNameDict(obj, ignore)

    coreName = doBuildName()
    """ add the iterator to the name dictionary if our object exists"""
    nameFactory = NameFactory(obj)

    if not sceneUnique:
        iterator = returnFastIterateNumber(obj)
        if iterator > 0:
            updatedNamesDict['cgmIterator'] = str(iterator)
            coreName = doBuildName()
    else:
        iterator = returnIterateNumber(obj)
        if iterator > 0:
            updatedNamesDict['cgmIterator'] = str(iterator)
            coreName = doBuildName()

    return returnCombinedNameFromDict(updatedNamesDict)
Ejemplo n.º 6
0
def returnIterateNumber(obj):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Check through a scene to figure out what iterative number an obj

    ARGUMENTS:
    obj(string)

    RETURNS:
    order(list)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    #>>> input check
    assert mc.objExists(obj) is True, "'%s' doesn't exist" %obj
    
    objToQuery = NameFactory(obj)
    objToQuery.getMatchedParents()
    objToQuery.getMatchedChildren()
    
    # First thing we do is if our object has a parent name object, we process from that object back
    if objToQuery.parentNameCnt:
        parentToQuery = NameFactory(objToQuery.matchedParents[0])
        cnt =  parentToQuery.returnIterator()
        cnt =  cnt + objToQuery.parentNameCnt
        # So we have a top parent
        objNameCandidate = objToQuery.objGeneratedNameDict.copy()
        objNameCandidate['cgmIterator'] = str(cnt)
        bufferName = returnCombinedNameFromDict(objNameCandidate)
        # If it exists in our existing tree, it forces a nameModifier tag
        if mc.objExists(bufferName) and not objToQuery.amIMe(bufferName):
            if bufferName not in objToQuery.matchedChildren and bufferName in parentToQuery.matchedChildren:
                attributes.storeInfo(obj,'cgmNameModifier','branched')
                attributes.storeInfo(obj,'cgmIterator',str(cnt))
                print ("%s has a duplicate in the same heirarchy!" %obj)
        #print ("Count after checking name parent is %i" %cnt)
        return cnt
    #otherwise, we process it by itself
    else:
        cnt = objToQuery.returnIterator()
        return cnt
Ejemplo n.º 7
0
def returnIterateNumber(obj):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Check through a scene to figure out what iterative number an obj

    ARGUMENTS:
    obj(string)

    RETURNS:
    order(list)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    #>>> input check
    assert mc.objExists(obj) is True, "'%s' doesn't exist" % obj

    objToQuery = NameFactory(obj)
    objToQuery.getMatchedParents()
    objToQuery.getMatchedChildren()

    # First thing we do is if our object has a parent name object, we process from that object back
    if objToQuery.parentNameCnt:
        parentToQuery = NameFactory(objToQuery.matchedParents[0])
        cnt = parentToQuery.returnIterator()
        cnt = cnt + objToQuery.parentNameCnt
        # So we have a top parent
        objNameCandidate = objToQuery.objGeneratedNameDict.copy()
        objNameCandidate['cgmIterator'] = str(cnt)
        bufferName = returnCombinedNameFromDict(objNameCandidate)
        # If it exists in our existing tree, it forces a nameModifier tag
        if mc.objExists(bufferName) and not objToQuery.amIMe(bufferName):
            if bufferName not in objToQuery.matchedChildren and bufferName in parentToQuery.matchedChildren:
                attributes.storeInfo(obj, 'cgmNameModifier', 'branched')
                attributes.storeInfo(obj, 'cgmIterator', str(cnt))
                print("%s has a duplicate in the same heirarchy!" % obj)
        #print ("Count after checking name parent is %i" %cnt)
        return cnt
    #otherwise, we process it by itself
    else:
        cnt = objToQuery.returnIterator()
        return cnt
Ejemplo n.º 8
0
def parentObjectToNameObject(object):
    object = NameFactory(object)
    if mc.objExists(object.cgm['cgmName']):
        obj = rigging.doParentReturnName(object.nameLong,object.cgm['cgmName'])