mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
tweaks on the validation report & repair action
This commit is contained in:
parent
caf4295653
commit
69c8d1985b
1 changed files with 27 additions and 13 deletions
|
|
@ -11,7 +11,7 @@ from openpype.hosts.maya.api.lib import reset_scene_resolution
|
|||
|
||||
class ValidateSceneResolution(pyblish.api.InstancePlugin,
|
||||
OptionalPyblishPluginMixin):
|
||||
"""Validate the scene resolution setting aligned with DB"""
|
||||
"""Validate the render resolution setting aligned with DB"""
|
||||
|
||||
order = pyblish.api.ValidatorOrder - 0.01
|
||||
families = ["renderlayer"]
|
||||
|
|
@ -23,25 +23,34 @@ class ValidateSceneResolution(pyblish.api.InstancePlugin,
|
|||
def process(self, instance):
|
||||
if not self.is_active(instance.data):
|
||||
return
|
||||
invalid = self.get_invalid_resolution(instance)
|
||||
if invalid:
|
||||
raise PublishValidationError("issues occurred", description=(
|
||||
"Wrong render resolution setting. Please use repair button to fix it.\n"
|
||||
"If current renderer is vray, make sure vraySettings node has been created"
|
||||
))
|
||||
|
||||
def get_invalid_resolution(self, instance):
|
||||
width, height, pixelAspect = self.get_db_resolution(instance)
|
||||
current_renderer = cmds.getAttr(
|
||||
"defaultRenderGlobals.currentRenderer")
|
||||
layer = instance.data["renderlayer"]
|
||||
invalids = []
|
||||
if current_renderer == "vray":
|
||||
vray_node = "vraySettings"
|
||||
if cmds.objExists(vray_node):
|
||||
control_node = vray_node
|
||||
current_width = lib.get_attr_in_layer(
|
||||
"{}.width".format(control_node), layer=layer)
|
||||
"{}.width".format(vray_node), layer=layer)
|
||||
current_height = lib.get_attr_in_layer(
|
||||
"{}.height".format(control_node), layer=layer)
|
||||
"{}.height".format(vray_node), layer=layer)
|
||||
current_pixelAspect = lib.get_attr_in_layer(
|
||||
"{}.pixelAspect".format(control_node), layer=layer
|
||||
"{}.pixelAspect".format(vray_node), layer=layer
|
||||
)
|
||||
else:
|
||||
raise PublishValidationError(
|
||||
"Can't set VRay resolution because there is no node "
|
||||
"named: `%s`" % vray_node)
|
||||
invalid = self.log.error(
|
||||
"Can't detect VRay resolution because there is no node "
|
||||
"named: `{}`".format(vray_node))
|
||||
invalids.append(invalid)
|
||||
else:
|
||||
current_width = lib.get_attr_in_layer(
|
||||
"defaultResolution.width", layer=layer)
|
||||
|
|
@ -51,15 +60,18 @@ class ValidateSceneResolution(pyblish.api.InstancePlugin,
|
|||
"defaultResolution.pixelAspect", layer=layer
|
||||
)
|
||||
if current_width != width or current_height != height:
|
||||
raise PublishValidationError(
|
||||
invalid = self.log.error(
|
||||
"Render resolution {}x{} does not match asset resolution {}x{}".format( # noqa:E501
|
||||
current_width, current_height, width, height
|
||||
))
|
||||
invalids.append("{0}\n".format(invalid))
|
||||
if current_pixelAspect != pixelAspect:
|
||||
raise PublishValidationError(
|
||||
invalid = self.log.error(
|
||||
"Render pixel aspect {} does not match asset pixel aspect {}".format( # noqa:E501
|
||||
current_pixelAspect, pixelAspect
|
||||
))
|
||||
invalids.append("{0}\n".format(invalid))
|
||||
return invalids
|
||||
|
||||
def get_db_resolution(self, instance):
|
||||
asset_doc = instance.data["assetEntity"]
|
||||
|
|
@ -71,11 +83,13 @@ class ValidateSceneResolution(pyblish.api.InstancePlugin,
|
|||
width = data["resolutionWidth"]
|
||||
height = data["resolutionHeight"]
|
||||
pixelAspect = data["pixelAspect"]
|
||||
return int(width), int(height), int(pixelAspect)
|
||||
return int(width), int(height), float(pixelAspect)
|
||||
|
||||
# Defaults if not found in asset document or project document
|
||||
return 1920, 1080, 1
|
||||
return 1920, 1080, 1.0
|
||||
|
||||
@classmethod
|
||||
def repair(cls, instance):
|
||||
return reset_scene_resolution()
|
||||
layer = instance.data["renderlayer"]
|
||||
with lib.renderlayer(layer):
|
||||
reset_scene_resolution()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue