Bases: InstancePlugin
Validate that work file was saved.
Source code in client/ayon_max/plugins/publish/validate_pointcloud.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126 | class ValidatePointCloud(pyblish.api.InstancePlugin):
"""Validate that work file was saved."""
order = pyblish.api.ValidatorOrder
families = ["pointcloud"]
hosts = ["max"]
label = "Validate Point Cloud"
def process(self, instance):
"""
Notes:
1. Validate if the export mode of Export Particle is at PRT format
2. Validate the partition count and range set as default value
Partition Count : 100
Partition Range : 1 to 1
3. Validate if the custom attribute(s) exist as parameter(s)
of export_particle operator
"""
report = []
if self.validate_export_mode(instance):
report.append("The export mode is not at PRT")
if self.validate_partition_value(instance):
report.append(("tyFlow Partition setting is "
"not at the default value"))
invalid_attribute = self.validate_custom_attribute(instance)
if invalid_attribute:
report.append(("Custom Attribute not found "
f":{invalid_attribute}"))
if report:
raise PublishValidationError(f"{report}")
def validate_custom_attribute(self, instance):
invalid = []
container = instance.data["instance_node"]
self.log.info(
f"Validating tyFlow custom attributes for {container}")
selection_list = instance.data["members"]
project_settings = instance.context.data["project_settings"]
attr_settings = project_settings["max"]["PointCloud"]["attribute"]
for sel in selection_list:
obj = sel.baseobject
anim_names = rt.GetSubAnimNames(obj)
for anim_name in anim_names:
# get all the names of the related tyFlow nodes
sub_anim = rt.GetSubAnim(obj, anim_name)
if rt.IsProperty(sub_anim, "Export_Particles"):
event_name = sub_anim.name
opt = "${0}.{1}.export_particles".format(sel.name,
event_name)
for attr in attr_settings:
key = attr["name"]
value = attr["value"]
custom_attr = "{0}.PRTChannels_{1}".format(opt,
value)
try:
rt.Execute(custom_attr)
except RuntimeError:
invalid.append(key)
return invalid
def validate_partition_value(self, instance):
invalid = []
container = instance.data["instance_node"]
self.log.info(
f"Validating tyFlow partition value for {container}")
selection_list = instance.data["members"]
for sel in selection_list:
obj = sel.baseobject
anim_names = rt.GetSubAnimNames(obj)
for anim_name in anim_names:
# get all the names of the related tyFlow nodes
sub_anim = rt.GetSubAnim(obj, anim_name)
if rt.IsProperty(sub_anim, "Export_Particles"):
event_name = sub_anim.name
opt = "${0}.{1}.export_particles".format(sel.name,
event_name)
count = rt.Execute(f'{opt}.PRTPartitionsCount')
if count != 100:
invalid.append(count)
start = rt.Execute(f'{opt}.PRTPartitionsFrom')
if start != 1:
invalid.append(start)
end = rt.Execute(f'{opt}.PRTPartitionsTo')
if end != 1:
invalid.append(end)
return invalid
def validate_export_mode(self, instance):
invalid = []
container = instance.data["instance_node"]
self.log.info(
f"Validating tyFlow export mode for {container}")
con = rt.GetNodeByName(container)
selection_list = list(con.Children)
for sel in selection_list:
obj = sel.baseobject
anim_names = rt.GetSubAnimNames(obj)
for anim_name in anim_names:
# get all the names of the related tyFlow nodes
sub_anim = rt.GetSubAnim(obj, anim_name)
# check if there is export particle operator
boolean = rt.IsProperty(sub_anim, "Export_Particles")
event_name = sub_anim.name
if boolean:
opt = f"${sel.name}.{event_name}.export_particles"
export_mode = rt.Execute(f'{opt}.exportMode')
if export_mode != 1:
invalid.append(export_mode)
return invalid
|
process(instance)
Notes
- Validate if the export mode of Export Particle is at PRT format
- Validate the partition count and range set as default value Partition Count : 100 Partition Range : 1 to 1
- Validate if the custom attribute(s) exist as parameter(s) of export_particle operator
Source code in client/ayon_max/plugins/publish/validate_pointcloud.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 | def process(self, instance):
"""
Notes:
1. Validate if the export mode of Export Particle is at PRT format
2. Validate the partition count and range set as default value
Partition Count : 100
Partition Range : 1 to 1
3. Validate if the custom attribute(s) exist as parameter(s)
of export_particle operator
"""
report = []
if self.validate_export_mode(instance):
report.append("The export mode is not at PRT")
if self.validate_partition_value(instance):
report.append(("tyFlow Partition setting is "
"not at the default value"))
invalid_attribute = self.validate_custom_attribute(instance)
if invalid_attribute:
report.append(("Custom Attribute not found "
f":{invalid_attribute}"))
if report:
raise PublishValidationError(f"{report}")
|