Raise PublishValidationError

This commit is contained in:
Roy Nieterau 2024-03-28 13:57:37 +01:00
parent c131071c7d
commit 149c83e136

View file

@ -3,9 +3,11 @@ 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
@ -35,5 +37,9 @@ class ValidateCurrentRenderLayerIsRenderable(pyblish.api.ContextPlugin,
layer = cmds.editRenderLayerGlobals(query=True, currentRenderLayer=True)
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:
raise PublishValidationError(
"Current render layer '{}' has no renderable camera".format(
layer
)
)