Merge pull request #124 from aardschok/122

Refactor out inhouse dependency
This commit is contained in:
Wijnand Koreman 2018-07-02 10:38:02 +02:00 committed by GitHub
commit 2660ca2ac8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,8 +13,6 @@ from collections import OrderedDict, defaultdict
from maya import cmds, mel
from avalon import api, maya, io, pipeline
from cb.utils.maya import core
import cb.utils.maya.context
log = logging.getLogger(__name__)
@ -287,6 +285,26 @@ def renderlayer(layer):
cmds.editRenderLayerGlobals(currentRenderLayer=original)
@contextlib.contextmanager
def evaluation(mode="off"):
"""Set the evaluation manager during context.
Arguments:
mode (str): The mode to apply during context.
"off": The standard DG evaluation (stable)
"serial": A serial DG evaluation
"parallel": The Maya 2016+ parallel evaluation
"""
original = cmds.evaluationManager(query=True, mode=1)[0]
try:
cmds.evaluationManager(mode=mode)
yield
finally:
cmds.evaluationManager(mode=original)
def get_renderer(layer):
with renderlayer(layer):
return cmds.getAttr("defaultRenderGlobals.currentRenderer")
@ -579,7 +597,7 @@ def extract_alembic(file,
# Disable the parallel evaluation temporarily to ensure no buggy
# exports are made. (PLN-31)
# TODO: Make sure this actually fixes the issues
with cb.utils.maya.context.evaluation("off"):
with evaluation("off"):
cmds.AbcExport(j=job_str, verbose=verbose)
if verbose: