def on_task_changed(*args): """Wrapped function of app initialize and maya's on task changed""" # Inputs (from the switched session and running app) session = avalon.Session.copy() app_name = os.environ["AVALON_APP_NAME"] # Find the application definition app_definition = pipeline.lib.get_application(app_name) App = type("app_%s" % app_name, (avalon.Application,), {"config": app_definition.copy()}) # Initialize within the new session's environment app = App() env = app.environ(session) app.initialize(env) # Run maya.pipeline._on_task_changed() with maya.suspended_refresh(): lib.set_context_settings() lib.update_content_on_context_change() lib.show_message("Context was changed", ("Context was changed to {}".format( avalon.Session["AVALON_ASSET"])))
def process(self, instance): import os import ava from maya import cmds from avalon import maya self.log.debug("Loading plug-in..") cmds.loadPlugin("AbcExport.mll", quiet=True) self.log.info("Extracting animation..") dirname = ava.format_staging_dir( root=instance.context.data["workspaceDir"], time=instance.context.data["time"], name=instance.data["name"]) try: os.makedirs(dirname) except OSError: pass filename = "{name}.abc".format(**instance.data) out_set = next(( node for node in instance if node.endswith("out_SET") ), None) if out_set: nodes = cmds.sets(out_set, query=True) else: # Backwards compatibility nodes = list(instance) self.log.info("nodes: %s" % str(nodes)) with maya.suspended_refresh(): maya.export_alembic( nodes=nodes, file=os.path.join(dirname, filename).replace("\\", "/"), frame_range=(instance.data["startFrame"], instance.data["endFrame"]), # Include UVs write_uv=True, # Include Visibility write_visibility=True, # Include all attributes prefixed with this attribute_prefix="mb" ) # Store reference for integration if "files" not in instance.data: instance.data["files"] = list() instance.data["files"].append(filename) instance.data["stagingDir"] = dirname self.log.info("Extracted {instance} to {dirname}".format(**locals()))
def on_task_changed(*args): """Wrapped function of app initialize and maya's on task changed""" # Run with suspended_refresh(): lib.set_context_settings() lib.update_content_on_context_change() lib.show_message( "Context was changed", ("Context was changed to {}".format(avalon.Session["AVALON_ASSET"])), )
def on_new(_): """Set project resolution and fps when create a new file""" avalon.logger.info("Running callback on new..") with suspended_refresh(): cmds.evalDeferred("from openpype.hosts.maya.api import lib;" "lib.remove_render_layer_observer()") cmds.evalDeferred("from openpype.hosts.maya.api import lib;" "lib.add_render_layer_observer()") cmds.evalDeferred("from openpype.hosts.maya.api import lib;" "lib.add_render_layer_change_observer()") lib.set_context_settings()
def on_new(_): """Set project resolution and fps when create a new file""" avalon.logger.info("Running callback on new..") with maya.suspended_refresh(): lib.set_context_settings()