Skip to content
49 changes: 49 additions & 0 deletions client/ayon_max/plugins/publish/validate_render_active_viewport.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""Validates whether the render active viewport is set in render settings."""
import pyblish.api
from ayon_core.pipeline import (
PublishValidationError,
OptionalPyblishPluginMixin,
)
from ayon_core.pipeline.publish import RepairAction
from pymxs import runtime as rt


class ValidateNoActiveViewport(pyblish.api.ContextPlugin,
OptionalPyblishPluginMixin):
"""Validates No Active Viewport

Check if there is no active viewport set in the render settings.
"""

order = pyblish.api.ValidatorOrder
families = ["maxrender"]
hosts = ["max"]
label = "No Render Active Viewport"
optional = False
actions = [RepairAction]

def process(self, context):
if not self.is_active(context.data):
return
if not rt.rendUseActiveView:
raise PublishValidationError(
title="No Active Render Viewport",
message=(
"The render active viewport is currently disabled "
"in the render settings. Please use the repair action "
"to activate it."
),
description=(
"## Render Active Render Viewport\n"
"The render active viewport is currently "
"disabled in the render settings.\n\n"
"We need to enable the render active viewport "
"to ensure the correct render viewport is used.\n\n"
"You can use the repair action to activate it."
)
Comment thread
moonyuet marked this conversation as resolved.

)

@classmethod
def repair(cls, context):
rt.rendUseActiveView = True
Comment thread
moonyuet marked this conversation as resolved.
9 changes: 9 additions & 0 deletions server/settings/publishers.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ class PublishersModel(BaseSettingsModel):
default_factory=ValidateModelNameModel,
title="Validate Model Name"
)
ValidateNoActiveViewport: BasicValidateModel = SettingsField(
default_factory=BasicValidateModel,
title="Validate No Active Viewport"
)
ValidateRenderPasses: BasicValidateModel = SettingsField(
default_factory=BasicValidateModel,
title="Validate Render Passes"
Expand Down Expand Up @@ -216,6 +220,11 @@ class PublishersModel(BaseSettingsModel):
"optional": True,
"active": False,
},
"ValidateNoActiveViewport": {
"enabled": True,
"optional": False,
"active": True
},
"ValidateRenderPasses": {
"enabled": True,
"optional": False,
Expand Down
Loading