Bases: MayaInstancePlugin
Collect out hierarchy data for instance.
Collect all hierarchy nodes which reside in the out_SET of the animation instance or point cache instance. This is to unify the logic of retrieving that specific data. This eliminates the need to write two separate pieces of logic to fetch all hierarchy nodes.
Results in a list of nodes from the content of the instances
Source code in client/ayon_maya/plugins/publish/collect_animation.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 | class CollectAnimationOutputGeometry(plugin.MayaInstancePlugin):
"""Collect out hierarchy data for instance.
Collect all hierarchy nodes which reside in the out_SET of the animation
instance or point cache instance. This is to unify the logic of retrieving
that specific data. This eliminates the need to write two separate pieces
of logic to fetch all hierarchy nodes.
Results in a list of nodes from the content of the instances
"""
order = pyblish.api.CollectorOrder + 0.4
families = ["animation"]
label = "Collect Animation Output Geometry"
ignore_type = ["constraints"]
def process(self, instance):
"""Collect the hierarchy nodes"""
product_type = instance.data["productType"]
out_set = next((i for i in instance.data["setMembers"] if
i.endswith("out_SET")), None)
if out_set is None:
self.log.warning((
"Expecting out_SET for instance of product type '{}'"
).format(product_type))
return
members = cmds.ls(cmds.sets(out_set, query=True), long=True)
# Get all the relatives of the members
descendants = cmds.listRelatives(members,
allDescendents=True,
fullPath=True) or []
descendants = cmds.ls(descendants, noIntermediate=True, long=True)
# Add members and descendants together for a complete overview
hierarchy = members + descendants
# Ignore certain node types (e.g. constraints)
ignore = cmds.ls(hierarchy, type=self.ignore_type, long=True)
if ignore:
ignore = set(ignore)
hierarchy = [node for node in hierarchy if node not in ignore]
# Store data in the instance for the validator
instance.data["out_hierarchy"] = hierarchy
if instance.data.get("farm"):
instance.data["families"].append("publish.farm")
|
process(instance)
Collect the hierarchy nodes
Source code in client/ayon_maya/plugins/publish/collect_animation.py
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 | def process(self, instance):
"""Collect the hierarchy nodes"""
product_type = instance.data["productType"]
out_set = next((i for i in instance.data["setMembers"] if
i.endswith("out_SET")), None)
if out_set is None:
self.log.warning((
"Expecting out_SET for instance of product type '{}'"
).format(product_type))
return
members = cmds.ls(cmds.sets(out_set, query=True), long=True)
# Get all the relatives of the members
descendants = cmds.listRelatives(members,
allDescendents=True,
fullPath=True) or []
descendants = cmds.ls(descendants, noIntermediate=True, long=True)
# Add members and descendants together for a complete overview
hierarchy = members + descendants
# Ignore certain node types (e.g. constraints)
ignore = cmds.ls(hierarchy, type=self.ignore_type, long=True)
if ignore:
ignore = set(ignore)
hierarchy = [node for node in hierarchy if node not in ignore]
# Store data in the instance for the validator
instance.data["out_hierarchy"] = hierarchy
if instance.data.get("farm"):
instance.data["families"].append("publish.farm")
|