Bases: InstancePlugin
Validates that no Material Library is present.
This validator checks if a material library is present in the scene to ensure users publishing look instances with material libraries. Repair action is provided to open the material library if the file exists, or clean up the instance if the material library file is missing.
Source code in client/ayon_max/plugins/publish/validate_no_material_library.py
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
42
43
44
45
46
47
48
49
50 | class ValidateNoMaterialLibrary(pyblish.api.InstancePlugin):
"""Validates that no Material Library is present.
This validator checks if a material library is present
in the scene to ensure users publishing look instances
with material libraries. Repair action is provided
to open the material library if the file exists,
or clean up the instance if the material library
file is missing.
"""
order = pyblish.api.ValidatorOrder
families = ["matlib"]
hosts = ["max"]
label = "No Material Library"
actions = [RepairAction]
def process(self, instance):
matlib_filepath = instance.data["matlib_filepath"]
if not os.path.exists(matlib_filepath):
raise PublishValidationError(
"Material Library file does not exist. "
f"Cannot open Material Library at: {matlib_filepath}"
)
if not rt.sme.HasMtlLib(matlib_filepath):
raise PublishValidationError(
f"Material Library from {instance.name} "
"is not present before publishing. "
)
@classmethod
def repair(cls, instance):
"""Repair action to open the material library."""
matlib_filepath = instance.data.get("matlib_filepath")
if os.path.exists(matlib_filepath):
rt.sme.OpenMtlLib(matlib_filepath)
else:
# Cleaning up the instance if the material library file
instance_node = rt.GetNodeByName(instance.data["instance_node"])
if instance_node:
rt.Delete(instance_node)
|
repair(instance) classmethod
Repair action to open the material library.
Source code in client/ayon_max/plugins/publish/validate_no_material_library.py
40
41
42
43
44
45
46
47
48
49
50 | @classmethod
def repair(cls, instance):
"""Repair action to open the material library."""
matlib_filepath = instance.data.get("matlib_filepath")
if os.path.exists(matlib_filepath):
rt.sme.OpenMtlLib(matlib_filepath)
else:
# Cleaning up the instance if the material library file
instance_node = rt.GetNodeByName(instance.data["instance_node"])
if instance_node:
rt.Delete(instance_node)
|