Skip to content

Commit

Permalink
Merge branch 'develop' into enhancement/maya_validate_model_content
Browse files Browse the repository at this point in the history
  • Loading branch information
BigRoy authored Apr 5, 2024
2 parents fca484d + 8fdd804 commit 252e9c2
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 33 deletions.
10 changes: 6 additions & 4 deletions client/ayon_core/hosts/maya/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -3129,7 +3129,7 @@ def load_capture_preset(data):
return options


def get_attr_in_layer(attr, layer):
def get_attr_in_layer(attr, layer, as_string=True):
"""Return attribute value in specified renderlayer.
Same as cmds.getAttr but this gets the attribute's value in a
Expand All @@ -3147,6 +3147,7 @@ def get_attr_in_layer(attr, layer):
Args:
attr (str): attribute name, ex. "node.attribute"
layer (str): layer name
as_string (bool): whether attribute should convert to a string value
Returns:
The return value from `maya.cmds.getAttr`
Expand All @@ -3156,15 +3157,16 @@ def get_attr_in_layer(attr, layer):
try:
if cmds.mayaHasRenderSetup():
from . import lib_rendersetup
return lib_rendersetup.get_attr_in_layer(attr, layer)
return lib_rendersetup.get_attr_in_layer(
attr, layer, as_string=as_string)
except AttributeError:
pass

# Ignore complex query if we're in the layer anyway
current_layer = cmds.editRenderLayerGlobals(query=True,
currentRenderLayer=True)
if layer == current_layer:
return cmds.getAttr(attr)
return cmds.getAttr(attr, asString=as_string)

connections = cmds.listConnections(attr,
plugs=True,
Expand Down Expand Up @@ -3215,7 +3217,7 @@ def get_attr_in_layer(attr, layer):
value *= conversion
return value

return cmds.getAttr(attr)
return cmds.getAttr(attr, asString=as_string)


def fix_incompatible_containers():
Expand Down
21 changes: 18 additions & 3 deletions client/ayon_core/hosts/maya/api/lib_renderproducts.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def get_render_attribute(self, attribute):
"""
return self._get_attr("defaultRenderGlobals", attribute)

def _get_attr(self, node_attr, attribute=None):
def _get_attr(self, node_attr, attribute=None, as_string=True):
"""Return the value of the attribute in the renderlayer
For readability this allows passing in the attribute in two ways.
Expand All @@ -317,7 +317,7 @@ def _get_attr(self, node_attr, attribute=None):
else:
plug = "{}.{}".format(node_attr, attribute)

return lib.get_attr_in_layer(plug, layer=self.layer)
return lib.get_attr_in_layer(plug, layer=self.layer, as_string=as_string)

@staticmethod
def extract_separator(file_prefix):
Expand Down Expand Up @@ -1133,9 +1133,24 @@ def get_render_products(self):
aovs = list(set(aovs) - set(ref_aovs))

products = []
global_aov_enabled = bool(
self._get_attr("redshiftOptions.aovGlobalEnableMode", as_string=False)
)
colorspace = lib.get_color_management_output_transform()
if not global_aov_enabled:
# only beauty output
for camera in cameras:
products.insert(0,
RenderProduct(productName="",
ext=ext,
multipart=self.multipart,
camera=camera,
colorspace=colorspace))
return products

light_groups_enabled = False
has_beauty_aov = False
colorspace = lib.get_color_management_output_transform()

for aov in aovs:
enabled = self._get_attr(aov, "enabled")
if not enabled:
Expand Down
6 changes: 3 additions & 3 deletions client/ayon_core/hosts/maya/api/lib_rendersetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_rendersetup_layer(layer):
if conn.endswith(".legacyRenderLayer")), None)


def get_attr_in_layer(node_attr, layer):
def get_attr_in_layer(node_attr, layer, as_string=True):
"""Return attribute value in Render Setup layer.
This will only work for attributes which can be
Expand Down Expand Up @@ -124,7 +124,7 @@ def get_default_layer_value(node_attr_):
node = history_overrides[-1] if history_overrides else override
node_attr_ = node + ".original"

return get_attribute(node_attr_, asString=True)
return get_attribute(node_attr_, asString=as_string)

layer = get_rendersetup_layer(layer)
rs = renderSetup.instance()
Expand All @@ -144,7 +144,7 @@ def get_default_layer_value(node_attr_):
# we will let it error out.
rs.switchToLayer(current_layer)

return get_attribute(node_attr, asString=True)
return get_attribute(node_attr, asString=as_string)

overrides = get_attr_overrides(node_attr, layer)
default_layer_value = get_default_layer_value(node_attr)
Expand Down
11 changes: 9 additions & 2 deletions client/ayon_core/hosts/maya/plugins/create/create_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,15 @@ def apply_settings(cls, project_settings):
def create(self, product_name, instance_data, pre_create_data):
# Only allow a single render instance to exist
if self._get_singleton_node():
raise CreatorError("A Render instance already exists - only "
"one can be configured.")
raise CreatorError(
"A Render instance already exists - only one can be "
"configured.\n\n"
"To render multiple render layers, create extra Render Setup "
"Layers via Maya's Render Setup UI.\n"
"Then refresh the publisher to detect the new layers for "
"rendering.\n\n"
"With a render instance present all Render Setup layers in "
"your workfile are renderable instances.")

# Apply default project render settings on create
if self.render_settings.get("apply_render_settings"):
Expand Down
39 changes: 18 additions & 21 deletions client/ayon_core/tools/workfiles/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,16 +659,7 @@ def _open_workfile(self, folder_id, task_id, filepath):
folder_id != self.get_current_folder_id()
or task_name != self.get_current_task_name()
):
folder_entity = ayon_api.get_folder_by_id(
event_data["project_name"],
event_data["folder_id"],
)
task_entity = ayon_api.get_task_by_name(
event_data["project_name"],
event_data["folder_id"],
event_data["task_name"]
)
change_current_context(folder_entity, task_entity)
self._change_current_context(project_name, folder_id, task_id)

self._host_open_workfile(filepath)

Expand Down Expand Up @@ -710,16 +701,8 @@ def _save_as_workfile(
folder_id != self.get_current_folder_id()
or task_name != self.get_current_task_name()
):
folder_entity = ayon_api.get_folder_by_id(
project_name, folder["id"]
)
task_entity = ayon_api.get_task_by_name(
project_name, folder["id"], task_name
)
change_current_context(
folder_entity,
task_entity,
template_key=template_key
self._change_current_context(
project_name, folder_id, task_id, template_key
)

# Save workfile
Expand All @@ -744,4 +727,18 @@ def _save_as_workfile(

# Trigger after save events
emit_event("workfile.save.after", event_data, source="workfiles.tool")
self.reset()

def _change_current_context(
self, project_name, folder_id, task_id, template_key=None
):
# Change current context
folder_entity = self.get_folder_entity(project_name, folder_id)
task_entity = self.get_task_entity(project_name, task_id)
change_current_context(
folder_entity,
task_entity,
template_key=template_key
)
self._current_folder_id = folder_entity["id"]
self._current_folder_path = folder_entity["path"]
self._current_task_name = task_entity["name"]

0 comments on commit 252e9c2

Please sign in to comment.