def applyCache(cacheGrp, abcFile, alwaysRebuild=True): abcFile = abcFile.replace("\\", "/") # get current node if exists alembicNodes = hook.getAlembicNode(cacheGrp) if not alembicNodes: isRef = mc.referenceQuery(cacheGrp, isNodeReferenced=True) if isRef: mode = "add" else: mode = "add_remove" result = abcUtils.importABC(cacheGrp, abcFile, mode=mode) logger.debug("Apply abc node %s %s" % (result, abcFile)) else: if alwaysRebuild: mc.delete(alembicNodes) logger.debug("Delete nodes %s" % alembicNodes) applyCache(cacheGrp, abcFile, alwaysRebuild=True) else: activeNode = alembicNodes[0] mc.setAttr("%s.abc_File" % activeNode, abcFile, type="string") logger.debug("setAttr %s %s" % (activeNode, abcFile)) return True
def applyCache(cacheGrp, abcFile, alwaysRebuild=True): abcFile = abcFile.replace('\\', '/') # get current node if exists alembicNodes = hook.getAlembicNode(cacheGrp) if not alembicNodes: isRef = mc.referenceQuery(cacheGrp, isNodeReferenced=True) if isRef: mode = 'add' else: mode = 'add_remove' result = abcUtils.importABC(cacheGrp, abcFile, mode=mode) logger.debug('Apply abc node %s %s' % (result, abcFile)) else: if alwaysRebuild: mc.delete(alembicNodes) logger.debug('Delete nodes %s' % alembicNodes) applyCache(cacheGrp, abcFile, alwaysRebuild=True) else: activeNode = alembicNodes[0] mc.setAttr('%s.abc_File' % activeNode, abcFile, type='string') logger.debug('setAttr %s %s' % (activeNode, abcFile)) return True
def findCurrentAbcVersion(self, assetName) : # find current version cacheGrp = self.cacheData[assetName]['cacheGrp'] if hook.objectExists(cacheGrp) : alembicNode = hook.getAlembicNode(cacheGrp) if alembicNode : currentAbcFile = hook.getAlembicPath(alembicNode[0]) currentAbcVersion = os.path.dirname(currentAbcFile).split('/')[-1] return currentAbcVersion
def doRemoveCacheNode(self) : # list listWidget = 'asset_tableWidget' assetNames = self.getTableData(listWidget, self.nonCacheListCol) if self.cacheData : for each in assetNames : cacheGrp = self.cacheData[each]['cacheGrp'] alembicNode = hook.getAlembicNode(cacheGrp) hook.delete(alembicNode) logger.debug('Remove alembic nodes -> %s' % alembicNode) self.refreshUI()
def doRemoveCacheAsset(self) : # list listWidget = 'asset_tableWidget' assetNames = self.getTableData(listWidget, self.nonCacheListCol) allRefs = hook.getAllReference() if self.cacheData : for each in assetNames : namespace = each cacheGrp = self.cacheData[each]['cacheGrp'] shadeFile = self.cacheData[each]['shadeFile'] if hook.objectExists(cacheGrp) : alembicNode = hook.getAlembicNode(cacheGrp) if hook.objectExists(cacheGrp) : isRef = hook.isReference(cacheGrp) hook.delete(alembicNode) if isRef : hook.removeReference(cacheGrp) else : # delete upper level == Rig_Grp rigGrp = hook.getParent(cacheGrp) if rigGrp : hook.delete(rigGrp[0]) if shadeFile in allRefs : namespaceShade = hook.getNamespace(shadeFile) hook.removeReferenceByPath(shadeFile) hook.removeNamespace(namespaceShade) hook.removeNamespace(namespace) hook.deleteUnUsedNodes() self.refreshUI()