Пример #1
0
def bs_checkAllFileTexturePathIsComingFromEnv():
    """
    @ check all file texture path is coming from environment.
    @ run this function if all path are same.
    Returns:
            bool.
    """
    # get env details and sourceimage directory.
    envRoot = bs_pathGenerator.bs_getEnvDetails()['rootPath']
    assetDept, assetType, assetName, uid = bs_pathGenerator.bs_getAssetDetails(
    )
    sourceImageDir = bs_pathGenerator.bs_getAssetDir(
        astType=assetType, astDept=assetDept,
        astName=assetName)['dept'] + 'sourceimages/'
    sourceImageEnvDir = None
    notEnvPath = list()
    allFileTextures = pm.ls(type='file')
    for each in allFileTextures:
        ftn = each.ftn.get()
        if ftn.find('$') != -1:
            sourceImageEnvDir = '$BSW_PROD_SERVER/' + sourceImageDir.replace(
                envRoot, '')
    if sourceImageEnvDir:
        for each in allFileTextures:
            ftn = each.ftn.get()
            filtSourceImageDir = sourceImageEnvDir
            if not ftn.find(filtSourceImageDir) != -1:
                notEnvPath.append(each)
    if notEnvPath:
        return False
    return sourceImageEnvDir
Пример #2
0
def bs_getAllFileTexturePathIfValid():
    """
    @ query all file texture path and,
    @ return if all are coming from same valid path.
    Returns:
            sourceimages directory (str).
    """
    # get env details and sourceimage directory.
    envRoot = bs_pathGenerator.bs_getEnvDetails()['rootPath']
    assetDept, assetType, assetName, uid = bs_pathGenerator.bs_getAssetDetails(
    )
    sourceImageDir = bs_pathGenerator.bs_getAssetDir(
        astType=assetType, astDept=assetDept,
        astName=assetName)['dept'] + 'sourceimages/'

    allFileTextures = pm.ls(type='file')
    validPath = list()
    invalidPath = list()
    for each in allFileTextures:
        ftn = each.ftn.get()
        filtSourceImageDir = sourceImageDir.replace(envRoot, '')
        if ftn.find(filtSourceImageDir) != -1:
            validPath.append(each)
        else:
            invalidPath.append(each)
    if not invalidPath:
        return sourceImageDir
    bs_qui.bs_displayMessage('error', 'all path not from same path..')
    return False
Пример #3
0
def bspb_sceneName():
    """
    @ query and return scene name from current scene.
    Returns:
            scene name.
    """
    projectName = bs_pathGenerator.bs_getEnvDetails()['projectName'].lower()
    # get shot details.
    epi, seq, shot, stage = bs_pathGenerator.bs_shotDetailsCheckAndReturn()
    return '{0}_{1}_{2}_{3}_{4}'.format(projectName, epi, seq, shot, stage)
Пример #4
0
 def openSourceImageDir(self):
     urp = self.bstm_convertPath_le.text()
     if urp.startswith('$BSW_PROD_SERVER/'):
         resolvedPath = urp.replace(
             '$BSW_PROD_SERVER/',
             bs_pathGenerator.bs_getEnvDetails()['rootPath'])
         bs_os.bs_openDirInExplorer(resolvedPath)
         bs_qui.bs_displayMessage(
             'success', 'sourceimage directory opened in your os explorer.')
         return True
     bs_qui.bs_displayMessage('error', 'directory not found..')
     return False
Пример #5
0
def bs_getItemsFromLwFilterAndReturnPath(allAssetsListWidget):
    """
    @ get all items from list widget and sort it with prefix ('ch_', 'pr_', 'bg_', 'vh_')
    Args:
        allAssetsListWidget (QtGui.QTabWidget): list widget who has a all types of assets sorted by ["ch_", "pr_"] etc.

    Returns:
            all assets paths with environment variable.
    """
    serverPath = bs_pathGenerator.bs_getEnvDetails()['rootPath']
    chars = list()
    props = list()
    sets = list()
    vehicles = list()
    for x in range(allAssetsListWidget.count()):
        assetName = allAssetsListWidget.item(x).text()
        if assetName.startswith('ch_'):
            astDict = bs_pathGenerator.bs_getAssetFileAndVersions(
                'Character', 'Rig', assetName[3:])[0]
            if len(astDict.keys()) != 1:
                continue
            chars.append(astDict[astDict.keys()[0]]['path'])
        elif assetName.startswith('pr_'):
            astDict = bs_pathGenerator.bs_getAssetFileAndVersions(
                'Prop', 'Rig', assetName[3:])[0]
            if len(astDict.keys()) != 1:
                continue
            props.append(astDict[astDict.keys()[0]]['path'])
        elif assetName.startswith('bg_'):
            astDict = bs_pathGenerator.bs_getAssetFileAndVersions(
                'Set', 'Rig', assetName[3:])[0]
            if len(astDict.keys()) != 1:
                continue
            sets.append(astDict[astDict.keys()[0]]['path'])
        elif assetName.startswith('vh_'):
            astDict = bs_pathGenerator.bs_getAssetFileAndVersions(
                'Vehicle', 'Rig', assetName[3:])[0]
            if len(astDict.keys()) != 1:
                continue
            vehicles.append(astDict[astDict.keys()[0]]['path'])
    mainList = chars + props + sets + vehicles
    environPaths = list()
    for each in mainList:
        newPath = each.replace(serverPath, '$BSW_PROD_SERVER/')
        environPaths.append(newPath)
    return environPaths
Пример #6
0
def bs_getReference():
    """
    @ get all references from the scene and check if it came from valid directory.
    @ and filter it with asset type like (char, prop, set, vehicle.)
    Returns:
            dict.
            # return dictionary format.
            mainDict = {
            'char':{refNode: {'node':'', 'path':'', 'name':''}, refNode1: {'node':'', 'path':'', 'name':''}},
            'prop':{refNode: {'node':'', 'path':'', 'name':''}, refNode1: {'node':'', 'path':'', 'name':''}},
            'set':{refNode: {'node':'', 'path':'', 'name':''}, refNode1: {'node':'', 'path':'', 'name':''}},
            'vehicle':{refNode: {'node':'', 'path':'', 'name':''}, refNode1: {'node':'', 'path':'', 'name':''}},
                        }
    """
    allRef = pm.getReferences()
    # Declare dictionary.
    mainDict = dict()
    charDict = dict()
    propDict = dict()
    setDict = dict()
    vehicleDict = dict()
    for each in allRef.keys():
        eachRef = pm.getReferences()[each]
        projectFolder = bs_pathGenerator.bs_getEnvDetails()['projectFolder']
        basePath = '$BSW_PROD_SERVER/' + projectFolder + '/01_pre/'
        if str(eachRef.unresolvedPath()).startswith(basePath):
            astDict = dict()
            astDict['node'] = eachRef.refNode.name()
            astDict['path'] = str(eachRef.path)
            astDict['name'] = str(eachRef.path.name)
            if str(eachRef.path.name).split('_')[1] == 'ch':
                charDict[eachRef.refNode.name()] = astDict
            elif str(eachRef.path.name).split('_')[1] == 'pr':
                propDict[eachRef.refNode.name()] = astDict
            elif str(eachRef.path.name).split('_')[1] == 'bg':
                setDict[eachRef.refNode.name()] = astDict
            elif str(eachRef.path.name).split('_')[1] == 'vh':
                vehicleDict[eachRef.refNode.name()] = astDict
    mainDict['char'] = charDict
    mainDict['prop'] = propDict
    mainDict['set'] = setDict
    mainDict['vehicle'] = vehicleDict
    return mainDict
Пример #7
0
 def referenceElements(self):
     # get environments.
     serverPath = bs_pathGenerator.bs_getEnvDetails()['rootPath']
     # query current set.
     dept, assetType, assetName, uid = bs_pathGenerator.bs_getAssetDetails()
     if dept == 'Not Exist' or assetType == 'Not Exist' or assetName == 'Not Exist':
         bs_qui.bs_displayMessage('error', 'No Set Found in Scene.....')
         return False
     elements = list()
     for x in range(self.bssm_selectedItems_LW.count()):
         elements.append(self.bssm_selectedItems_LW.item(x).text())
     # reference and parent all selected setElements.
     for each in elements:
         mainFile, verFiles = bs_pathGenerator.bs_getAssetFileAndVersions(
             'SetElement', 'Rig', each)
         if len(mainFile.keys()) == 1:
             filePath = mainFile[mainFile.keys()[0]]['path']
             filePath = filePath.replace(serverPath, '$BSW_PROD_SERVER/')
             ns = bs_reference.bs_createReference(filePath,
                                                  prefixStyle='fileName')
             pm.parent(ns.namespace + ':rig_grp', 'setElements_grp')
     self.refresh()
Пример #8
0
def runInitialStartup():
    """
    @ run this function on maya start.
    Returns:
            None.
    """
    pm.select(cl=True)
    # make groups.
    topGrp = pm.PyNode('geo')
    modelGrp = pm.PyNode('test_grp')
    # get asset data from temp directory using json.
    jsonFilePath = tempfile.gettempdir() + '\\zSetAssetData.json'
    with open(os.path.join(tempfile.gettempdir(), jsonFilePath)) as fd:
        astData = json.load(fd)
    # set Values.
    pm.setAttr(topGrp + '.assetName', astData['name'])
    pm.setAttr(topGrp + '.assetName', l=True)
    pm.setAttr(topGrp + '.assetGrade', astData['grade'])
    pm.setAttr(topGrp + '.assetGrade', l=True)
    pm.setAttr(topGrp + '.assetUID', astData['uid'])
    pm.setAttr(topGrp + '.assetUID', l=True)
    modelGrp.rename(astData['name'])
    # get back to gpu folder.
    gpuPath = str()
    for each in astData['path'].split('.')[0].split('/')[:-1]:
        gpuPath += each + '/'
    if not os.path.isdir(gpuPath):
        os.makedirs(gpuPath)
        print 'path created.'
    # change gpu cache path.
    cacheFilePath = astData['path'].replace('.ma', '.abc')
    cacheNode = pm.PyNode('gpuCache')
    serverPath = bs_pathGenerator.bs_getEnvDetails()['rootPath']
    cacheFilePath = cacheFilePath.replace(serverPath, '$BSW_PROD_SERVER/')
    cacheNode.cacheFileName.set(cacheFilePath)
    # save as file.
    pm.saveAs(astData['path'])
    return topGrp