Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maya: Validate Model Content improve validation message #267

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve artist-facing report
  • Loading branch information
BigRoy committed Apr 4, 2024
commit 1e0c115a5ad52375b63060250e32fd8a95037f82
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import inspect

from maya import cmds

import pyblish.api
Expand All @@ -14,8 +16,7 @@ class ValidateModelContent(pyblish.api.InstancePlugin,
OptionalPyblishPluginMixin):
"""Adheres to the content of 'model' product type

- Must have one top group. (configurable)
- Must only contain: transforms, meshes and groups
See `get_description` for more details.

"""

Expand All @@ -35,7 +36,8 @@ def get_invalid(cls, instance):

content_instance = instance.data.get("setMembers", None)
if not content_instance:
cls.log.error("Instance has no nodes!")
cls.log.error("Model instance has no nodes. "
"It is not allowed to be empty")
return [instance.data["instance_node"]]

# All children will be included in the extracted export so we also
Expand All @@ -53,10 +55,13 @@ def get_invalid(cls, instance):
invalid = set(nodes) - set(valid)

if invalid:
# List as bullet points
invalid_bullets = "\n".join(f"- {node}" for node in invalid)

cls.log.error(
"These nodes are not allowed: {}.\n"
"The valid node types are: {}".format(", ".join(invalid),
", ".join(cls.allowed))
"These nodes are not allowed:\n{}\n"
"The valid node types are: {}".format(
invalid_bullets, ", ".join(cls.allowed))
)
return list(invalid)

Expand Down Expand Up @@ -113,10 +118,20 @@ def process(self, instance):
raise PublishValidationError(
title="Model content is invalid",
message="Model content is invalid. See log for more details.",
description=(
"## Model content is invalid\n"
"Your model instance does not adhere to the rules of a "
"model.\n\n"
"See log for more details."
)
description=self.get_description()
)

@classmethod
def get_description(cls):
return inspect.cleandoc(f"""
### Model content is invalid

Your model instance does not adhere to the rules of a
model product type:

- Must have at least one visible shape in it, like a mesh.
- Must have one root node. When exporting multiple meshes they
must be inside a group.
- May only contain the following node types:
{", ".join(cls.allowed)}
""")
Loading