Skip to content

Instantly share code, notes, and snippets.

@BigRoy
Created December 3, 2025 23:13
Show Gist options
  • Select an option

  • Save BigRoy/9c7e49d57f802fddcbed4858e03d44fd to your computer and use it in GitHub Desktop.

Select an option

Save BigRoy/9c7e49d57f802fddcbed4858e03d44fd to your computer and use it in GitHub Desktop.
Poor man's reopen scene plug-in set up with an "Export Mode" in AYON-Maya
import pyblish.api
from maya import cmds
ATTR = "__export_mode" # make sure to pick some quite unique name
class EnableExportModeAttributes(pyblish.api.ContextPlugin):
label = "Enable export modes"
order = pyblish.api.ExtractorOrder - 0.48 # after save scene
families = ["*"]
targets = ["local"]
set_value = True
def process(self, context):
original_values = context.data.setdefault("revertAttrValues", {})
# Find all of the attributes in the scene
for plug in cmds.ls(f"*.{ATTR}", recursive=True, long=True):
value = cmds.getAttr(plug)
if value != self.set_value:
# Override it
original_values[plug] = value
cmds.setAttr(plug, self.set_value)
class RevertAttributes(pyblish.api.ContextPlugin):
label = "Revert export mode attributes"
order = pyblish.api.ExtractorOrder + 0.4999 # end of extractions
families = ["*"]
targets = ["local"]
def process(self, context):
original_values = context.data.get("revertAttrValues", {})
for plug, value in original_values.items():
if not cmds.objExists(plug):
# Ignore attributes that suddenly do not exist anymore
continue
cmds.setAttr(plug, value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment