Skip to content

collect_assembly

Collect all relevant assembly items.

Todo

Publish of assembly need unique namespace for all assets, we should create validator for this.

CollectAssembly

Bases: MayaInstancePlugin

Collect all relevant assembly items

Collected data:

* File name
* Compatible loader
* Matrix per instance
* Namespace

Note: GPU caches are currently not supported in the pipeline. There is no logic yet which supports the swapping of GPU cache to renderable objects.

Source code in client/ayon_maya/plugins/publish/collect_assembly.py
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
class CollectAssembly(plugin.MayaInstancePlugin):
    """Collect all relevant assembly items

    Collected data:

        * File name
        * Compatible loader
        * Matrix per instance
        * Namespace

    Note: GPU caches are currently not supported in the pipeline. There is no
    logic yet which supports the swapping of GPU cache to renderable objects.

    """

    order = pyblish.api.CollectorOrder + 0.49
    label = "Assembly"
    families = ["assembly"]

    def process(self, instance):

        # Find containers
        containers = api.ls()

        # Get all content from the instance
        instance_lookup = set(cmds.ls(instance, type="transform", long=True))
        data = defaultdict(list)

        hierarchy_nodes = []
        for container in containers:

            root = lib.get_container_transforms(container, root=True)
            if not root or root not in instance_lookup:
                continue

            # Retrieve the hierarchy
            parent = cmds.listRelatives(root, parent=True, fullPath=True)[0]
            hierarchy_nodes.append(parent)

            # Temporary warning for GPU cache which are not supported yet
            loader = container["loader"]
            if loader == "GpuCacheLoader":
                self.log.warning("GPU Cache Loader is currently not supported"
                                 "in the pipeline, we will export it tho")

            # Gather info for new data entry
            representation_id = container["representation"]
            instance_data = {"loader": loader,
                             "parent": parent,
                             "namespace": container["namespace"]}

            # Check if matrix differs from default and store changes
            matrix_data = self.get_matrix_data(root)
            if matrix_data:
                instance_data["matrix"] = matrix_data

            data[representation_id].append(instance_data)

        instance.data["scenedata"] = dict(data)
        instance.data["nodesHierarchy"] = list(set(hierarchy_nodes))

    def get_file_rule(self, rule):
        return mel.eval('workspace -query -fileRuleEntry "{}"'.format(rule))

    def get_matrix_data(self, node):
        """Get the matrix of all members when they are not default

        Each matrix which differs from the default will be stored in a
        dictionary

        Args:
            members (list): list of transform nmodes
        Returns:
            dict
        """

        matrix = cmds.xform(node, query=True, matrix=True)
        if matrix == lib.DEFAULT_MATRIX:
            return

        return matrix

get_matrix_data(node)

Get the matrix of all members when they are not default

Each matrix which differs from the default will be stored in a dictionary

Parameters:

Name Type Description Default
members list

list of transform nmodes

required

Returns: dict

Source code in client/ayon_maya/plugins/publish/collect_assembly.py
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
def get_matrix_data(self, node):
    """Get the matrix of all members when they are not default

    Each matrix which differs from the default will be stored in a
    dictionary

    Args:
        members (list): list of transform nmodes
    Returns:
        dict
    """

    matrix = cmds.xform(node, query=True, matrix=True)
    if matrix == lib.DEFAULT_MATRIX:
        return

    return matrix