Bases: MayaInstancePlugin
, OptionalPyblishPluginMixin
Validate Arnold Scene Source Cbid.
It is required for the proxy and content nodes to share the same cbid.
Source code in client/ayon_maya/plugins/publish/validate_arnold_scene_source_cbid.py
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 | class ValidateArnoldSceneSourceCbid(plugin.MayaInstancePlugin,
OptionalPyblishPluginMixin):
"""Validate Arnold Scene Source Cbid.
It is required for the proxy and content nodes to share the same cbid.
"""
order = ValidateContentsOrder
families = ["assProxy"]
label = "Validate Arnold Scene Source CBID"
actions = [RepairAction]
optional = False
@classmethod
def apply_settings(cls, project_settings):
# Disable plug-in if cbId workflow is disabled
if not project_settings["maya"].get("use_cbid_workflow", True):
cls.enabled = False
return
@staticmethod
def _get_nodes_by_name(nodes):
nodes_by_name = {}
for node in nodes:
node_name = node.rsplit("|", 1)[-1].rsplit(":", 1)[-1]
nodes_by_name[node_name] = node
return nodes_by_name
@classmethod
def get_invalid_couples(cls, instance):
nodes_by_name = cls._get_nodes_by_name(instance.data["members"])
proxy_nodes_by_name = cls._get_nodes_by_name(instance.data["proxy"])
invalid_couples = []
for content_name, content_node in nodes_by_name.items():
proxy_node = proxy_nodes_by_name.get(content_name, None)
if not proxy_node:
cls.log.debug(
"Content node '{}' has no matching proxy node.".format(
content_node
)
)
continue
content_id = lib.get_id(content_node)
proxy_id = lib.get_id(proxy_node)
if content_id != proxy_id:
invalid_couples.append((content_node, proxy_node))
return invalid_couples
def process(self, instance):
if not self.is_active(instance.data):
return
# Proxy validation.
if not instance.data["proxy"]:
return
# Validate for proxy nodes sharing the same cbId as content nodes.
invalid_couples = self.get_invalid_couples(instance)
if invalid_couples:
raise PublishValidationError(
"Found proxy nodes with mismatching cbid:\n{}".format(
invalid_couples
)
)
@classmethod
def repair(cls, instance):
for content_node, proxy_node in cls.get_invalid_couples(instance):
lib.set_id(proxy_node, lib.get_id(content_node), overwrite=True)
|