-
Notifications
You must be signed in to change notification settings - Fork 1
/
validate_mesh_non_zero_face_area.py
41 lines (28 loc) · 1.32 KB
/
validate_mesh_non_zero_face_area.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pyblish.api
from maya import cmds
import pyblish_magenta.utils.maya.mesh as mesh_utils
class ValidateMeshNonZeroFaceArea(pyblish.api.Validator):
"""Validate meshes don't have zero area faces.
.. note:: This can be slow for high-res meshes.
Also see: http://help.autodesk.com/view/MAYAUL/2015/ENU/?guid=Mesh__Cleanup
Check is based on Maya's polyCleanup *'Faces with zero geometry area'* script.
"""
families = ['model']
hosts = ['maya']
category = 'geometry'
version = (0, 1, 0)
label = 'Mesh Face Area Non Zero'
__tolerance = 1e-8
def process(self, instance):
"""Process all meshes"""
meshes = cmds.ls(instance, type='mesh', dag=True, long=True)
# Get all faces
faces = ['{0}.f[*]'.format(node) for node in meshes]
# Filter by constraint on face area
invalid = mesh_utils.polyConstraint(faces,
disable=True, # Disable previous settings, use only current
t=0x0008, # type: 0x0008(face)
geometricarea=1,
geometricareabound=(0, self.__tolerance))
if invalid:
raise RuntimeError("Meshes found with zero face areas: {0}".format(invalid))