Skip to content

validate_skeleton_top_group_hierarchy

ValidateSkeletonTopGroupHierarchy

Bases: MayaInstancePlugin, OptionalPyblishPluginMixin

Validates top group hierarchy in the SETs Make sure the object inside the SETs are always top group of the hierarchy

Source code in client/ayon_maya/plugins/publish/validate_skeleton_top_group_hierarchy.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class ValidateSkeletonTopGroupHierarchy(plugin.MayaInstancePlugin,
                                        OptionalPyblishPluginMixin):
    """Validates top group hierarchy in the SETs
    Make sure the object inside the SETs are always top
    group of the hierarchy
    """
    order = ValidateContentsOrder + 0.05
    label = "Skeleton Rig Top Group Hierarchy"
    families = ["rig.fbx"]
    optional = True

    def process(self, instance):
        if not self.is_active(instance.data):
            return

        skeleton_mesh_nodes = instance.data("skeleton_mesh", [])
        if not skeleton_mesh_nodes:
            return

        invalid = get_non_root_nodes(skeleton_mesh_nodes)
        if invalid:
            raise PublishValidationError(
                "The skeletonMesh_SET includes the object which "
                "is not at the top hierarchy: {}".format(invalid))

get_non_root_nodes(nodes)

Return all nodes that are not root nodes (they have parents)

Parameters:

Name Type Description Default
nodes list[str]

Maya nodes.

required

Returns:

Type Description

list[str]: Non-root maya node (long names)

Source code in client/ayon_maya/plugins/publish/validate_skeleton_top_group_hierarchy.py
10
11
12
13
14
15
16
17
18
19
20
21
22
def get_non_root_nodes(nodes):
    """Return all nodes that are not root nodes (they have parents)

    Arguments:
        nodes (list[str]): Maya nodes.

    Returns:
        list[str]: Non-root maya node (long names)
    """
    nodes = cmds.ls(nodes, long=True)  # ensure long names
    return [
        node for node in nodes if node.count("|") > 2
    ]