mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
raise PublishXmlValidationError in validate layers visibility
This commit is contained in:
parent
f13923d31c
commit
3417dc716a
2 changed files with 41 additions and 1 deletions
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<root>
|
||||
<error id="main">
|
||||
<title>Layers visiblity</title>
|
||||
<description>## All layers are not visible
|
||||
|
||||
All layers for subset "{instance_name}" are hidden.
|
||||
|
||||
### Layer names for **{instance_name}**
|
||||
|
||||
{layer_names}
|
||||
|
||||
*Check layer names for all subsets in list on left side.*
|
||||
|
||||
### How to repair?
|
||||
|
||||
Make sure that at least one layer in the scene is visible or disable the subset before hitting publish button after refresh.
|
||||
</description>
|
||||
</error>
|
||||
</root>
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
import pyblish.api
|
||||
from openpype.pipeline import PublishXmlValidationError
|
||||
|
||||
|
||||
# TODO @iLLiCiTiT add repair action to disable instances?
|
||||
class ValidateLayersVisiblity(pyblish.api.InstancePlugin):
|
||||
"""Validate existence of renderPass layers."""
|
||||
|
||||
|
|
@ -9,8 +11,26 @@ class ValidateLayersVisiblity(pyblish.api.InstancePlugin):
|
|||
families = ["review", "renderPass", "renderLayer"]
|
||||
|
||||
def process(self, instance):
|
||||
layer_names = set()
|
||||
for layer in instance.data["layers"]:
|
||||
layer_names.add(layer["name"])
|
||||
if layer["visible"]:
|
||||
return
|
||||
|
||||
raise AssertionError("All layers of instance are not visible.")
|
||||
instance_label = (
|
||||
instance.data.get("label") or instance.data["name"]
|
||||
)
|
||||
|
||||
raise PublishXmlValidationError(
|
||||
self,
|
||||
"All layers of instance \"{}\" are not visible.".format(
|
||||
instance_label
|
||||
),
|
||||
formatting_data={
|
||||
"instance_name": instance_label,
|
||||
"layer_names": "<br/>".join([
|
||||
"- {}".format(layer_name)
|
||||
for layer_name in layer_names
|
||||
])
|
||||
}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue