raise PublishXmlValidationError in validate duplicated layer names

This commit is contained in:
iLLiCiTiT 2021-12-22 11:04:10 +01:00
parent 4759b6db37
commit f13923d31c
2 changed files with 33 additions and 4 deletions

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Layer names</title>
<description>## Duplicated layer names
Can't determine which layers should be published because there are duplicated layer names in the scene.
### Duplicated layer names
{layer_names}
*Check layer names for all subsets in list on left side.*
### How to repair?
Hide/rename/remove layers that should not be published.
If all of them should be published then you have duplicated subset names in the scene. In that case you have to recrete them and use different variant name.
</description>
</error>
</root>

View file

@ -1,4 +1,5 @@
import pyblish.api
from openpype.pipeline import PublishXmlValidationError
class ValidateLayersGroup(pyblish.api.InstancePlugin):
@ -30,14 +31,20 @@ class ValidateLayersGroup(pyblish.api.InstancePlugin):
"\"{}\"".format(layer_name)
for layer_name in duplicated_layer_names
])
# Raise an error
raise AssertionError(
detail_lines = [
"- {}".format(layer_name)
for layer_name in set(duplicated_layer_names)
]
raise PublishXmlValidationError(
self,
(
"Layers have duplicated names for instance {}."
# Description what's wrong
" There are layers with same name and one of them is marked"
" for publishing so it is not possible to know which should"
" be published. Please look for layers with names: {}"
).format(instance.data["label"], layers_msg)
).format(instance.data["label"], layers_msg),
formatting_data={
"layer_names": "<br/>".join(detail_lines)
}
)