Skip to content

Commit

Permalink
Merge pull request #316 from BigRoy/enhancement/maya_redshiftproxy_fr…
Browse files Browse the repository at this point in the history
…om_renderlayer

Maya: Fix RedshiftProxy export from renderlayer
  • Loading branch information
antirotor authored Apr 22, 2024
2 parents eb69c5c + 5371d88 commit 01fa343
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
4 changes: 2 additions & 2 deletions client/ayon_core/hosts/maya/api/render_setup_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


@contextlib.contextmanager
def _allow_export_from_render_setup_layer():
def allow_export_from_render_setup_layer():
"""Context manager to override Maya settings to allow RS layer export"""
try:

Expand Down Expand Up @@ -102,7 +102,7 @@ def export_in_rs_layer(path, nodes, export=None):
cmds.disconnectAttr(src, dest)

# Export Selected
with _allow_export_from_render_setup_layer():
with allow_export_from_render_setup_layer():
cmds.select(nodes, noExpand=True)
if export:
export()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
from maya import cmds

from ayon_core.pipeline import publish
from ayon_core.hosts.maya.api.lib import maintained_selection
from ayon_core.hosts.maya.api.lib import (
maintained_selection,
renderlayer
)
from ayon_core.hosts.maya.api.render_setup_tools import (
allow_export_from_render_setup_layer
)


class ExtractRedshiftProxy(publish.Extractor):
Expand All @@ -18,6 +24,9 @@ class ExtractRedshiftProxy(publish.Extractor):
def process(self, instance):
"""Extractor entry point."""

# Make sure Redshift is loaded
cmds.loadPlugin("redshift4maya", quiet=True)

staging_dir = self.staging_dir(instance)
file_name = "{}.rs".format(instance.name)
file_path = os.path.join(staging_dir, file_name)
Expand Down Expand Up @@ -60,14 +69,22 @@ def process(self, instance):

# Write out rs file
self.log.debug("Writing: '%s'" % file_path)

# Allow overriding what renderlayer to export from. By default force
# it to the default render layer. (Note that the renderlayer isn't
# currently exposed as an attribute to artists)
layer = instance.data.get("renderLayer", "defaultRenderLayer")

with maintained_selection():
cmds.select(instance.data["setMembers"], noExpand=True)
cmds.file(file_path,
pr=False,
force=True,
type="Redshift Proxy",
exportSelected=True,
options=rs_options)
with renderlayer(layer):
with allow_export_from_render_setup_layer():
cmds.select(instance.data["setMembers"], noExpand=True)
cmds.file(file_path,
preserveReferences=False,
force=True,
type="Redshift Proxy",
exportSelected=True,
options=rs_options)

if "representations" not in instance.data:
instance.data["representations"] = []
Expand Down

0 comments on commit 01fa343

Please sign in to comment.