Skip to content

validate_ornatrix_cache_content

ValidateOrnatrixCacheContent

Bases: MayaInstancePlugin, OptionalPyblishPluginMixin

Adheres to the content of 'oxcache' product type

See get_description for more details.

Source code in client/ayon_maya/plugins/publish/validate_ornatrix_cache_content.py
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
61
62
63
64
65
class ValidateOrnatrixCacheContent(plugin.MayaInstancePlugin,
                                   OptionalPyblishPluginMixin):
    """Adheres to the content of 'oxcache' product type

    See `get_description` for more details.

    """

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

    optional = False

    @classmethod
    def get_invalid(cls, instance):

        nodes = list(instance[:])
        ox_hair_shapes = cmds.ls(nodes, type="HairShape")
        invalid = []
        if len(ox_hair_shapes) == 0:
            cls.log.warning("No Ornatrix Hair shapes found to cache from.")
            invalid.append(nodes)

        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 cache content is invalid",
                message="Ornatrix cache content is invalid. "
                        "See log for more details.",
                description=self.get_description()
            )

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

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

            - Must have a Ornatrix `HairShape` nodes to cache.

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