This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
/
collect_animation.py
60 lines (41 loc) · 1.99 KB
/
collect_animation.py
1
2
3
4
5
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
import pyblish.api
import maya.cmds as cmds
class CollectAnimationOutputGeometry(pyblish.api.InstancePlugin):
"""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"
hosts = ["maya"]
ignore_type = ["constraints"]
def process(self, instance):
"""Collect the hierarchy nodes"""
family = instance.data["family"]
out_set = next((i for i in instance.data["setMembers"] if
i.endswith("out_SET")), None)
if out_set is None:
warning = "Expecting out_SET for instance of family '%s'" % family
self.log.warning(warning)
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")