mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +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
|
import pyblish.api
|
||||||
|
|
||||||
from maya import cmds
|
from maya import cmds
|
||||||
from ayon_core.pipeline.publish import (
|
from ayon_core.pipeline.publish import (
|
||||||
context_plugin_should_run,
|
context_plugin_should_run,
|
||||||
|
PublishValidationError,
|
||||||
OptionalPyblishPluginMixin
|
OptionalPyblishPluginMixin
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ValidateCurrentRenderLayerIsRenderable(pyblish.api.ContextPlugin,
|
class ValidateCurrentRenderLayerIsRenderable(pyblish.api.ContextPlugin,
|
||||||
OptionalPyblishPluginMixin):
|
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
|
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:
|
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):
|
if not context_plugin_should_run(self, context):
|
||||||
return
|
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)
|
cameras = cmds.ls(type="camera", long=True)
|
||||||
renderable = any(c for c in cameras if cmds.getAttr(c + ".renderable"))
|
renderable = any(c for c in cameras if cmds.getAttr(c + ".renderable"))
|
||||||
assert renderable, ("Current render layer '%s' has no renderable "
|
if not renderable:
|
||||||
"camera" % layer)
|
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