Skip to content

validate_ornatrix_rig_content

ValidateOrnatrixRigContent

Bases: MayaInstancePlugin, OptionalPyblishPluginMixin

Adheres to the content of 'oxrig' product type

See get_description for more details.

Source code in client/ayon_maya/plugins/publish/validate_ornatrix_rig_content.py
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
class ValidateOrnatrixRigContent(plugin.MayaInstancePlugin,
                                 OptionalPyblishPluginMixin):
    """Adheres to the content of 'oxrig' product type

    See `get_description` for more details.

    """

    order = ValidateContentsOrder
    families = ["oxrig"]
    label = "Validate Ornatrix Rig Content"
    actions = [ayon_maya.api.action.SelectInvalidAction]

    optional = False

    @classmethod
    def get_invalid(cls, instance):
        invalid = []
        nodes = instance.data["setMembers"]
        for node in nodes:
            # Members must have shapes
            node_shapes = cmds.listRelatives(node, shapes=True, fullPath=True)
            if not node_shapes:
                invalid.append(node)

            # Shapes must have a connection to ornatrix nodes
            ox_nodes = cmds.ls(cmds.listConnections(
                node_shapes, destination=True) or [], type=ORNATRIX_NODES)
            if not ox_nodes:
                invalid.append(node)

        return invalid

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

        if invalid:
            raise PublishValidationError(
                title="Ornatrix rig content is invalid",
                message="Ornatrix rig content is invalid. "
                        "See log for more details.",
                description=self.get_description()
            )

    @classmethod
    def get_description(self):
        return inspect.cleandoc("""
            ### Ornatrix content is invalid

            Your oxrig instance does not adhere to the rules of an
            oxrig product type:

            - Must have the Ornatrix nodes connected to the shape
            of the mesh
            - May only have members that have shapes.

            Using the *Select Invalid* action will select all nodes that do
            not adhere to these rules.
        """)