def refreshList(self, path=None, task=None, code=None, itemMData=None): color = (0, 0, 0) createdColor = (.5, .5, .20) if not itemMData: print 'ERROR: No search item!!' self.item = itemMData childs = pm.flowLayout(self.widgetName, q=True, ca=True) if childs: for i in childs: pm.deleteUI(i) self.itemList = [] self.selectedItem = None for ns, component in itemMData['components'].iteritems(): type = component['type'] collection = database.getCollection(type, self.projectName) result = collection.find_one({ 'task': component['task'], 'code': component['code'] }) if not result: print 'component %s %s missing!' % (component['task'], component['code']) continue name = ns + ':' + database.getTaskShort( result['task']) + result['code'] + '_' + result['name'] if result['task'] == 'rig': createdColor = (0, .5, .20) elif result['task'] == 'uvs': createdColor = (.5, .5, .20) notCreatedColor = (.2, .2, .2) status = result['status'] if status == 'notCreated': color = notCreatedColor elif status == 'created': color = createdColor thumbPath = version.getThumb(result) x = ComponentWidget(name=name, itemName=result['name'], imgPath=thumbPath, label=result['task'], status=result['status'], parentWidget=self, color=color) self.itemList.append(x) x.task = result['task'] x.code = result['code'] x.addToLayout(self.viewOption)
def getItem(self): projName = self.parentWidget.projectName itemType = database.getTaskType(self.task) collection = database.getCollection(itemType, projName) if self.task == 'asset': searchTask = 'model' elif self.task == 'shot': searchTask = 'layout' else: searchTask = self.task item = collection.find_one({'task': searchTask, 'code': self.code}) return item
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)
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')