Skip to content

validate_subset_name

Validator for correct naming of Static Meshes.

ValidateSubsetName

Bases: HoudiniInstancePlugin, OptionalPyblishPluginMixin

Validate Product name.

Source code in client/ayon_houdini/plugins/publish/validate_subset_name.py
 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
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
class ValidateSubsetName(plugin.HoudiniInstancePlugin,
                         OptionalPyblishPluginMixin):
    """Validate Product name.

    """

    families = ["staticMesh", "hda"]
    label = "Validate Product Name"
    order = ValidateContentsOrder + 0.1
    actions = [FixProductNameAction, SelectInvalidAction]

    optional = True

    def process(self, instance):

        if not self.is_active(instance.data):
            return

        invalid = self.get_invalid(instance)
        if invalid:
            raise PublishValidationError(
                "See log for details. "
                "Invalid ROP node: {0}".format(invalid[0].path())
            )

    @classmethod
    def get_invalid(cls, instance):

        rop_node = hou.node(instance.data["instance_node"])

        # Check product name
        folder_entity = instance.data["folderEntity"]
        task_entity = instance.data["taskEntity"]
        task_name = task_type = None
        if task_entity:
            task_name = task_entity["name"]
            task_type = task_entity["taskType"]
        product_name = get_product_name(
            instance.context.data["projectName"],
            task_name,
            task_type,
            instance.context.data["hostName"],
            instance.data["productType"],
            variant=instance.data["variant"],
            dynamic_data={
                "asset": folder_entity["name"],
                "folder": {
                            "label": folder_entity["label"],
                            "name": folder_entity["name"]
                            }
                }
        )

        if instance.data.get("productName") != product_name:
            cls.log.error(
                "Invalid product name on rop node '%s' should be '%s'.",
                rop_node.path(), product_name
            )
            return [rop_node]

    @classmethod
    def repair(cls, instance):
        rop_node = hou.node(instance.data["instance_node"])

        # Check product name
        folder_entity = instance.data["folderEntity"]
        task_entity = instance.data["taskEntity"]
        task_name = task_type = None
        if task_entity:
            task_name = task_entity["name"]
            task_type = task_entity["taskType"]
        product_name = get_product_name(
            instance.context.data["projectName"],
            task_name,
            task_type,
            instance.context.data["hostName"],
            instance.data["productType"],
            variant=instance.data["variant"],
            dynamic_data={
                "asset": folder_entity["name"],
                "folder": {
                            "label": folder_entity["label"],
                            "name": folder_entity["name"]
                            }
                }
        )

        instance.data["productName"] = product_name
        rop_node.parm("AYON_productName").set(product_name)

        cls.log.debug(
            "Product name on rop node '%s' has been set to '%s'.",
            rop_node.path(), product_name
        )