Example #1
0
    def getCachePublishPath(self, make=False):
        item = self.getItem()
        path = item.getPath(dirLocation='cacheLocation', ext='')
        cachePath = os.path.join(*path)

        if make:
            if not os.path.exists(cachePath):
                os.makedirs(cachePath)

        ver = 'v%03d_' % self.cacheVer
        cacheName = database.templateName(self.getDataDict()) + '_' + self.ns
        cacheFileName = ver + cacheName + '.abc'

        return os.path.join(cachePath, cacheFileName)
Example #2
0
    def getCachePublishPath(self, make=False):
        """
        Return the path where to publish the alembic cache for this camera
        If make it true, create the folder if needed

        :param make: boolean
        :return: str
        """
        proj = database.getProjectDict()
        path = self.parent.getPath(dirLocation='cacheLocation', ext='')
        cachePath = os.path.join(*path)

        if make:
            if not os.path.exists(cachePath):
                os.makedirs(cachePath)

        ver = 'v%03d_' % self.parent.caches['cam']['cacheVer']
        cacheName = database.templateName(self.getDataDict(), proj['cacheNameTemplate']) + '_' + self.ns
        cacheFileName = ver + cacheName + '.abc'

        return os.path.join(cachePath, cacheFileName)
Example #3
0
    def getPublishPath(self, make=False):
        """
        Return the publish path for this component
        If make is true create the folder if needed

        :param make: boolean
        :return: str
        """
        proj = database.getProjectDict()
        sourceItem = self.getSourceItem()
        path = sourceItem.getPath(dirLocation='cacheLocation', ext='')
        cachePath = os.path.join(*path)

        if make:
            if not os.path.exists(cachePath):
                os.makedirs(cachePath)

        ver = 'v%03d_' % self.cacheVer
        cacheName = database.templateName(
            self.getDataDict(), proj['cacheNameTemplate']) + '_' + self.ns
        cacheFileName = ver + cacheName + '.abc'

        return os.path.join(cachePath, cacheFileName)
Example #4
0
    def refreshList(self, path=None, task=None, code=None, itemMData=None):
        color = (0, 0, 0)
        x = None

        itemListProj = database.getProjectDict()

        if itemMData:
            self.path = itemMData['path']
            self.task = itemMData['task']
            self.type = itemMData['type']
        else:
            self.path = path
            self.task = task
            self.type = database.getTaskType(task[0])
            logger.debug('task %s, type %s' % (task[0], self.type))

        collection = database.getCollection(self.type)

        if code:
            result = collection.find({'path': self.path, 'code': code})
        else:
            if self.task == ['asset']:
                result = collection.find({'path': self.path, 'task': 'model'})
            elif self.task == ['shot']:
                result = collection.find({'path': self.path, 'task': 'layout'})
            else:
                result = collection.find({
                    'path': self.path,
                    'task': {
                        '$in': self.task
                    }
                })

        flowChilds = pm.flowLayout(self.widgetName, q=True, ca=True)
        if flowChilds:
            for i in flowChilds:
                pm.deleteUI(i)

        self.itemList = []
        self.selectedItem = None

        for itemMData in result:
            logger.debug(itemMData)
            if not code and (task == 'asset' or task == 'shot'):
                templateToUse = [
                    x for x in itemListProj['assetNameTemplate']
                    if x != '$task'
                ]
                name = database.templateName(itemMData, template=templateToUse)
                taskLabel = task.upper()
                createdColor = (0, .2, .50)
                notCreatedColor = (0, .2, .50)
            else:
                name = database.templateName(itemMData)
                taskLabel = itemMData['task'].upper()
                notCreatedColor = (.2, .2, .2)
                createdColor = (1, .8, .20)

            status = itemMData['status']
            if status == 'notCreated':
                color = notCreatedColor
            elif status == 'created':
                color = createdColor

            thumbPath = version.getThumb(itemMData)
            x = ItemBase(name=name,
                         itemName=itemMData['name'],
                         imgPath=thumbPath,
                         label=taskLabel,
                         status=itemMData['status'],
                         parentWidget=self,
                         color=color)
            x.infoWidget = self.infoWidget

            if code:
                x.task = itemMData['task']
                x.workVer = itemMData['workVer']
                x.publishVer = itemMData['publishVer']
            else:
                x.task = itemMData['task']
                x.workVer = 0
                x.publishVer = 0

            x.code = itemMData['code']
            self.itemList.append(x)
            x.addToLayout(self.viewOption)
Example #5
0
def cacheScene(task, code):
    ver = 0

    collection = database.getCollection('shot')
    shotMData = database.getItemMData(task=task, code=code, itemType='shot')

    if 'caches' not in shotMData:
        shotMData['caches'] = copy.deepcopy(shotMData['components'])

        for item in shotMData['caches'].itervalues():
            item['ver'] = 0
            item['type'] = 'cache'
            item['assembleMode'] = 'cache'
            item['cacheVer'] = 0
            item['name'] = ''

    itemComponents = shotMData['components']
    itemCaches = shotMData['caches']
    geoGroups = pm.ls('geo_group', r=True)

    choosen = pm.layoutDialog(ui=lambda: cachePrompt(geoGroups))

    if 'Abort' in choosen:
        return

    path = database.getPath(shotMData, dirLocation='cacheLocation', ext='')
    cachePath = os.path.join(*path)

    if not os.path.exists(cachePath):
        os.makedirs(cachePath)

    choosenGeoGroups = [pm.PyNode(x) for x in choosen.split(',')]

    for geoGroup in choosenGeoGroups:
        # get all geometry on geo_group
        geosShape = geoGroup.getChildren(allDescendents=True,
                                         type='geometryShape')
        geos = [x.getParent() for x in geosShape]
        jobGeos = ''

        for geo in geos:
            if '|' in geo:

                logger.error('Naming problem on geo %s' % geo)
            else:
                jobGeos = jobGeos + ' -root ' + geo

                # make path and name for alembic file

        ns = geoGroup.namespace()[:-1]
        cacheMData = itemCaches[ns]  # get the data for this component

        # get version and increment
        cacheMData['cacheVer'] += 1

        ver = cacheMData['cacheVer']

        # get cache publish path

        cacheName = database.templateName(cacheMData) + '_' + ns
        cacheFileName = str('v%03d_' % ver) + cacheName
        cacheFullPath = os.path.join(cachePath, cacheFileName)

        jobFile = " -file " + cacheFullPath + ".abc "

        # get scene frame range
        ini = str(int(pm.playbackOptions(q=True, min=True)))
        fim = str(int(pm.playbackOptions(q=True, max=True)))
        jobFrameRange = ' -frameRange ' + ini + ' ' + fim

        # set parameters for alembic cache
        jobAttr = ' -attr translateX -attr translateY -attr translateZ -attr rotateX ' \
                  '-attr rotateY -attr rotateZ -attr scaleX -attr scaleY -attr scaleZ -attr visibility'
        jobOptions = " -worldSpace -uv -writeVisibility"

        # build cache arguments
        jobArg = jobFrameRange + jobOptions + jobAttr + jobGeos + jobFile

        # do caching
        pm.AbcExport(j=jobArg)

    collection.find_one_and_update({
        'task': task,
        'code': code
    }, {'$set': shotMData})

    logger.info('Cache Ver: %s')