Ejemplo n.º 1
0
def importCache(data):
    # input data
    if data:
        # loop through each namespace dictionary
        for each in data:
            # namespace
            namespace = each

            # alembic abc cache file
            path = data[each]['cachePath']

            # shader file
            shadeFile = data[each]['shadeFile']

            # shader data file
            shadeDateFile = data[each]['shadeDataFile']

            # if no asset in the scene, import new
            if not mc.objExists('%s:Rig_Grp' % namespace):

                # check namespace exists. If not, create one
                if not mc.namespace(exists=namespace):
                    mc.namespace(add=namespace)

                # set to asset namespace
                mc.namespace(set=namespace)

                # import new alembic for this asset
                obj = '/'
                abcResult = abcUtils.importABC(obj, path, 'new')
                logger.info('import cache %s success' % namespace)

                # import shader for this asset
                shadeResult = importShade.applyShade(namespace, shadeFile,
                                                     shadeDateFile)

                # clean unused node
                mm.eval(
                    'hyperShadePanelMenuCommand("hyperShadePanel1", "deleteUnusedNodes");'
                )

                # set namespace back to root
                mc.namespace(set=':')
                logger.info('apply shader')

                # set Rig_Grp to existing geo_grp
                if mc.objExists('%s:%s' % (namespace, exportGrp)):
                    mc.group('%s:%s' % (namespace, exportGrp), n='Rig_Grp')
                    logger.info('set Rig_Grp')

            # if asset already exists, update animation
            else:
                # geo group
                obj = '%s:%s' % (namespace, exportGrp)

                # merge alembic to geo_grp
                abcResult = abcUtils.importABC(obj, path, 'add')
Ejemplo n.º 2
0
def importCache(data):
    # input data
    if data:
        # loop through each namespace dictionary
        for each in data:
            # namespace
            namespace = each

            # alembic abc cache file
            path = data[each]["cachePath"]

            # shader file
            shadeFile = data[each]["shadeFile"]

            # shader data file
            shadeDateFile = data[each]["shadeDataFile"]

            # if no asset in the scene, import new
            if not mc.objExists("%s:Rig_Grp" % namespace):

                # check namespace exists. If not, create one
                if not mc.namespace(exists=namespace):
                    mc.namespace(add=namespace)

                    # set to asset namespace
                mc.namespace(set=namespace)

                # import new alembic for this asset
                obj = "/"
                abcResult = abcUtils.importABC(obj, path, "new")
                logger.info("import cache %s success" % namespace)

                # import shader for this asset
                shadeResult = importShade.applyShade(namespace, shadeFile, shadeDateFile)

                # clean unused node
                mm.eval('hyperShadePanelMenuCommand("hyperShadePanel1", "deleteUnusedNodes");')

                # set namespace back to root
                mc.namespace(set=":")
                logger.info("apply shader")

                # set Rig_Grp to existing geo_grp
                if mc.objExists("%s:%s" % (namespace, exportGrp)):
                    mc.group("%s:%s" % (namespace, exportGrp), n="Rig_Grp")
                    logger.info("set Rig_Grp")

                    # if asset already exists, update animation
            else:
                # geo group
                obj = "%s:%s" % (namespace, exportGrp)

                # merge alembic to geo_grp
                abcResult = abcUtils.importABC(obj, path, "add")
Ejemplo n.º 3
0
def importCacheAsset(namespace, abcFile):
    logger.debug("ImportCacheAsset %s %s" % (namespace, abcFile))
    # input data
    path = abcFile

    # if no asset in the scene, import new
    if not mc.objExists("%s:Rig_Grp" % namespace):

        # check namespace exists. If not, create one
        if not mc.namespace(exists=namespace):
            mc.namespace(add=namespace)

            # set to asset namespace
        mc.namespace(set=namespace)

        # import new alembic for this asset
        obj = "/"
        abcResult = abcUtils.importABC(obj, path, "new")
        logger.info("import cache %s success" % namespace)

        # set namespace back to root
        mc.namespace(set=":")

        # set Rig_Grp to existing geo_grp
        if mc.objExists("%s:%s" % (namespace, exportGrp)):
            rigGrp = "%s:%s" % (namespace, "Rig_Grp")
            # mc.group('%s:%s' % (namespace, exportGrp), n = rigGrp)
            rigGrp = mc.group(em=True, n=rigGrp)
            mc.parent("%s:%s" % (namespace, exportGrp), rigGrp)
            logger.info("set Rig_Grp")
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
def importCacheAsset(namespace, abcFile):
    logger.debug('ImportCacheAsset %s %s' % (namespace, abcFile))
    # input data
    path = abcFile

    # if no asset in the scene, import new
    if not mc.objExists('%s:Rig_Grp' % namespace):

        # check namespace exists. If not, create one
        if not mc.namespace(exists=namespace):
            mc.namespace(add=namespace)

        # set to asset namespace
        mc.namespace(set=namespace)

        # import new alembic for this asset
        obj = '/'
        abcResult = abcUtils.importABC(obj, path, 'new')
        logger.info('import cache %s success' % namespace)

        # set namespace back to root
        mc.namespace(set=':')

        # set Rig_Grp to existing geo_grp
        if mc.objExists('%s:%s' % (namespace, exportGrp)):
            rigGrp = '%s:%s' % (namespace, 'Rig_Grp')
            # mc.group('%s:%s' % (namespace, exportGrp), n = rigGrp)
            rigGrp = mc.group(em=True, n=rigGrp)
            mc.parent('%s:%s' % (namespace, exportGrp), rigGrp)
            logger.info('set Rig_Grp')
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
    def doTestABC(self) : 
        title = 'Test ABC'
        asset = entityInfo.info()
        abcDir = asset.rigDataPath('abc')
        files = fileUtils.listFile(abcDir)
        obj = 'Geo_Grp'

        if files : 
            latestFile = files[-1]
            path = '%s/%s' % (abcDir, latestFile)
            print 'abc file %s' % path 

            abcUtils.importABC(obj, path, mode = 'add')
            self.messageBox('Success', 'Apply cache complete')
            self.setStatus(title, True)

        else : 
            self.messageBox('Error', 'No abc cache file. Contact Rig department')
            self.setStatus(title, False)
Ejemplo n.º 8
0
    def doTestABC(self):
        title = 'Test ABC'
        asset = entityInfo.info()
        abcDir = asset.rigDataPath('abc')
        files = fileUtils.listFile(abcDir)
        obj = 'Geo_Grp'

        if files:
            latestFile = files[-1]
            path = '%s/%s' % (abcDir, latestFile)
            print 'abc file %s' % path

            abcUtils.importABC(obj, path, mode='add')
            self.messageBox('Success', 'Apply cache complete')
            self.setStatus(title, True)

        else:
            self.messageBox('Error',
                            'No abc cache file. Contact Rig department')
            self.setStatus(title, False)