Skip to content

Commit

Permalink
Merge pull request #364 from BigRoy/enhancement/maya_validate_node_id…
Browse files Browse the repository at this point in the history
…s_unique

Maya: Improve validate node ids unique report
  • Loading branch information
kalisp authored Apr 5, 2024
2 parents 7af860f + b4139cb commit 83e9b38
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import ayon_core.hosts.maya.api.action
from ayon_core.hosts.maya.api import lib

from maya import cmds


class ValidateNodeIdsUnique(pyblish.api.InstancePlugin):
"""Validate the nodes in the instance have a unique Colorbleed Id
Expand Down Expand Up @@ -41,7 +43,7 @@ def process(self, instance):
if invalid:
label = "Nodes found with non-unique folder ids"
raise PublishValidationError(
message="{}: {}".format(label, invalid),
message="{}, see log".format(label),
title="Non-unique folder ids on nodes",
description="{}\n- {}".format(label,
"\n- ".join(sorted(invalid)))
Expand All @@ -54,7 +56,6 @@ def get_invalid(cls, instance):
# Check only non intermediate shapes
# todo: must the instance itself ensure to have no intermediates?
# todo: how come there are intermediates?
from maya import cmds
instance_members = cmds.ls(instance, noIntermediate=True, long=True)

# Collect each id with their members
Expand All @@ -67,10 +68,14 @@ def get_invalid(cls, instance):

# Take only the ids with more than one member
invalid = list()
_iteritems = getattr(ids, "iteritems", ids.items)
for _ids, members in _iteritems():
for members in ids.values():
if len(members) > 1:
cls.log.error("ID found on multiple nodes: '%s'" % members)
members_text = "\n".join(
"- {}".format(member) for member in sorted(members)
)
cls.log.error(
"ID found on multiple nodes:\n{}".format(members_text)
)
invalid.extend(members)

return invalid

0 comments on commit 83e9b38

Please sign in to comment.