Improve validations for meshes without any faces/geometry

Easiest reproducable: `maya.cmds.createNode("mesh")`
This commit is contained in:
Roy Nieterau 2024-04-11 15:18:11 +02:00
parent 95b4d64b6a
commit d0b622ffc0
2 changed files with 18 additions and 2 deletions

View file

@ -45,6 +45,11 @@ class ValidateMeshNgons(pyblish.api.InstancePlugin,
# Get all faces
faces = ['{0}.f[*]'.format(node) for node in meshes]
# Skip meshes that for some reason have no faces, e.g. empty meshes
faces = cmds.ls(faces)
if not faces:
return []
# Filter to n-sided polygon faces (ngons)
invalid = lib.polyConstraint(faces,
t=0x0008, # type=face

View file

@ -29,8 +29,8 @@ class ValidateMeshUVSetMap1(pyblish.api.InstancePlugin,
actions = [ayon_core.hosts.maya.api.action.SelectInvalidAction,
RepairAction]
@staticmethod
def get_invalid(instance):
@classmethod
def get_invalid(cls, instance):
meshes = cmds.ls(instance, type='mesh', long=True)
@ -40,6 +40,11 @@ class ValidateMeshUVSetMap1(pyblish.api.InstancePlugin,
# Get existing mapping of uv sets by index
indices = cmds.polyUVSet(mesh, query=True, allUVSetsIndices=True)
maps = cmds.polyUVSet(mesh, query=True, allUVSets=True)
if not indices or not maps:
cls.log.warning("Mesh has no UV set: %s", mesh)
invalid.append(mesh)
continue
mapping = dict(zip(indices, maps))
# Get the uv set at index zero.
@ -68,6 +73,12 @@ class ValidateMeshUVSetMap1(pyblish.api.InstancePlugin,
# Get existing mapping of uv sets by index
indices = cmds.polyUVSet(mesh, query=True, allUVSetsIndices=True)
maps = cmds.polyUVSet(mesh, query=True, allUVSets=True)
if not indices or not maps:
# No UV set exist at all, create a `map1` uv set
# This may fail silently if the mesh has no geometry at all
cmds.polyUVSet(mesh, create=True, uvSet="map1")
continue
mapping = dict(zip(indices, maps))
# Ensure there is no uv set named map1 to avoid