add support to assign default shaders to the published setdress

This commit is contained in:
Kayla Man 2024-06-21 22:34:41 +08:00
parent f6c7d508d9
commit 89eb86a140

View file

@ -5,7 +5,7 @@ import os
from ayon_core.lib import BoolDef from ayon_core.lib import BoolDef
from ayon_core.pipeline import AVALON_CONTAINER_ID, AYON_CONTAINER_ID from ayon_core.pipeline import AVALON_CONTAINER_ID, AYON_CONTAINER_ID
from ayon_core.pipeline.publish import AYONPyblishPluginMixin from ayon_core.pipeline.publish import AYONPyblishPluginMixin
from ayon_maya.api.lib import maintained_selection from ayon_maya.api.lib import maintained_selection, shader
from ayon_maya.api import plugin from ayon_maya.api import plugin
from maya import cmds from maya import cmds
@ -88,17 +88,30 @@ class ExtractMayaSceneRaw(plugin.MayaExtractorPlugin, AYONPyblishPluginMixin):
) )
with maintained_selection(): with maintained_selection():
cmds.select(selection, noExpand=True) cmds.select(selection, noExpand=True)
cmds.file(path, if instance.data.get("shader", True):
force=True, with shader(selection, shadingEngine="initialShadingGroup"):
typ="mayaAscii" if self.scene_type == "ma" else "mayaBinary", # noqa: E501 cmds.file(path,
exportSelected=True, force=True,
preserveReferences=attribute_values[ typ="mayaAscii" if self.scene_type == "ma" else "mayaBinary", # noqa: E501
"preserve_references" exportSelected=True,
], preserveReferences=attribute_values[
constructionHistory=True, "preserve_references"
shader=instance.data.get("shader", True), ],
constraints=True, constructionHistory=True,
expressions=True) shader=instance.data.get("shader", True),
expressions=True)
else:
cmds.file(path,
force=True,
typ="mayaAscii" if self.scene_type == "ma" else "mayaBinary", # noqa: E501
exportSelected=True,
preserveReferences=attribute_values[
"preserve_references"
],
constructionHistory=True,
shader=True,
constraints=True,
expressions=True)
if "representations" not in instance.data: if "representations" not in instance.data:
instance.data["representations"] = [] instance.data["representations"] = []