Add job context parameter to USD publisher

E.g. You can now directly export with a `Arnold` job context (if it's registered) so that the USD export is Arnold supported and directly renderable with shaders/render attributes by Arnold renderer.
This commit is contained in:
Roy Nieterau 2023-09-06 16:02:46 +02:00
parent 862907079c
commit a0f7951ea3
2 changed files with 26 additions and 1 deletions

View file

@ -5,6 +5,8 @@ from openpype.lib import (
TextDef
)
from maya import cmds
class CreateMayaUsd(plugin.MayaCreator):
"""Create Maya USD Export"""
@ -15,11 +17,28 @@ class CreateMayaUsd(plugin.MayaCreator):
icon = "cubes"
description = "Create Maya USD Export"
cache = {}
def get_publish_families(self):
return ["usd", "mayaUsd"]
def get_instance_attr_defs(self):
if "jobContextItems" not in self.cache:
# Query once instead of per instance
job_context_items = {}
try:
cmds.loadPlugin("mayaUsdPlugin", quiet=True)
job_context_items = {
cmds.mayaUSDListJobContexts(jobContext=name): name
for name in cmds.mayaUSDListJobContexts(export=True)
}
except RuntimeError:
# Likely `mayaUsdPlugin` plug-in not available
self.log.warning("Unable to retrieve available job "
"contexts for `mayaUsdPlugin` exports")
self.cache["jobContextItems"] = job_context_items
defs = lib.collect_animation_defs()
defs.extend([
EnumDef("defaultUSDFormat",
@ -45,7 +64,11 @@ class CreateMayaUsd(plugin.MayaCreator):
TextDef("attrPrefix",
label="Custom Attributes Prefix",
default="",
placeholder="prefix1, prefix2")
placeholder="prefix1, prefix2"),
EnumDef("jobContext",
label="Job Context",
items=self.cache["jobContextItems"],
multiselection=True),
])
return defs

View file

@ -148,6 +148,7 @@ class ExtractMayaUsd(publish.Extractor):
"exportRefsAsInstanceable": bool,
"eulerFilter": bool,
"renderableOnly": bool,
"jobContext": (list, None) # optional list
# "worldspace": bool,
}
@ -169,6 +170,7 @@ class ExtractMayaUsd(publish.Extractor):
"exportRefsAsInstanceable": False,
"eulerFilter": True,
"renderableOnly": False,
"jobContext": None
# "worldspace": False
}