Bases: BlenderInstancePlugin, OptionalPyblishPluginMixin
Validate that the current mesh has UV's.
Source code in client/ayon_blender/plugins/publish/validate_mesh_has_uv.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54 | class ValidateMeshHasUvs(
plugin.BlenderInstancePlugin,
OptionalPyblishPluginMixin,
):
"""Validate that the current mesh has UV's."""
order = ValidateContentsOrder
hosts = ["blender"]
families = ["model"]
label = "Mesh Has UVs"
actions = [ayon_blender.api.action.SelectInvalidAction]
optional = True
@staticmethod
def has_uvs(obj: bpy.types.Object) -> bool:
"""Check if an object has uv's."""
return bool(obj.data.uv_layers)
@classmethod
def get_invalid(cls, instance) -> List:
invalid = []
for obj in instance:
if isinstance(obj, bpy.types.Object) and obj.type == 'MESH':
if obj.mode != "OBJECT":
cls.log.warning(
f"Mesh object {obj.name} should be in 'OBJECT' mode"
" to be properly checked."
)
if not cls.has_uvs(obj):
invalid.append(obj)
return invalid
def process(self, instance):
if not self.is_active(instance.data):
return
invalid = self.get_invalid(instance)
if invalid:
raise PublishValidationError(
f"Meshes found in instance without valid UV's: {invalid}"
)
|
has_uvs(obj) staticmethod
Check if an object has uv's.
Source code in client/ayon_blender/plugins/publish/validate_mesh_has_uv.py
| @staticmethod
def has_uvs(obj: bpy.types.Object) -> bool:
"""Check if an object has uv's."""
return bool(obj.data.uv_layers)
|