diff --git a/colorbleed/maya/lib.py b/colorbleed/maya/lib.py index 1493f7385e..5ba2122072 100644 --- a/colorbleed/maya/lib.py +++ b/colorbleed/maya/lib.py @@ -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: