mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #299 from BigRoy/enhancement/maya_validate_current_renderlayer_renderabke
Maya: Improve validate current renderlayer renderable artist report
This commit is contained in:
commit
704fe89db5
1 changed files with 39 additions and 4 deletions
|
|
@ -1,14 +1,18 @@
|
|||
import inspect
|
||||
|
||||
import pyblish.api
|
||||
|
||||
from maya import cmds
|
||||
from ayon_core.pipeline.publish import (
|
||||
context_plugin_should_run,
|
||||
PublishValidationError,
|
||||
OptionalPyblishPluginMixin
|
||||
)
|
||||
|
||||
|
||||
class ValidateCurrentRenderLayerIsRenderable(pyblish.api.ContextPlugin,
|
||||
OptionalPyblishPluginMixin):
|
||||
"""Validate if current render layer has a renderable camera
|
||||
"""Validate if current render layer has a renderable camera.
|
||||
|
||||
There is a bug in Redshift which occurs when the current render layer
|
||||
at file open has no renderable camera. The error raised is as follows:
|
||||
|
|
@ -32,8 +36,39 @@ class ValidateCurrentRenderLayerIsRenderable(pyblish.api.ContextPlugin,
|
|||
if not context_plugin_should_run(self, context):
|
||||
return
|
||||
|
||||
layer = cmds.editRenderLayerGlobals(query=True, currentRenderLayer=True)
|
||||
# This validator only makes sense when publishing renderlayer instances
|
||||
# with Redshift. We skip validation if there isn't any.
|
||||
if not any(self.is_active_redshift_render_instance(instance)
|
||||
for instance in context):
|
||||
return
|
||||
|
||||
cameras = cmds.ls(type="camera", long=True)
|
||||
renderable = any(c for c in cameras if cmds.getAttr(c + ".renderable"))
|
||||
assert renderable, ("Current render layer '%s' has no renderable "
|
||||
"camera" % layer)
|
||||
if not renderable:
|
||||
layer = cmds.editRenderLayerGlobals(query=True,
|
||||
currentRenderLayer=True)
|
||||
raise PublishValidationError(
|
||||
"Current render layer '{}' has no renderable camera".format(
|
||||
layer
|
||||
),
|
||||
description=inspect.getdoc(self)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def is_active_redshift_render_instance(instance) -> bool:
|
||||
"""Return whether instance is an active renderlayer instance set to
|
||||
render with Redshift renderer."""
|
||||
if not instance.data.get("active", True):
|
||||
return False
|
||||
|
||||
# Check this before families just because it's a faster check
|
||||
if not instance.data.get("renderer") == "redshift":
|
||||
return False
|
||||
|
||||
families = set()
|
||||
families.add(instance.data.get("family"))
|
||||
families.update(instance.data.get("families", []))
|
||||
if "renderlayer" not in families:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue