Skip to content

validate_tyflow_data

ValidateTyFlowData

Bases: InstancePlugin

Validate TyFlow plugins or relevant operators are set correctly.

Source code in client/ayon_max/plugins/publish/validate_tyflow_data.py
  6
  7
  8
  9
 10
 11
 12
 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
 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
class ValidateTyFlowData(pyblish.api.InstancePlugin):
    """Validate TyFlow plugins or relevant operators are set correctly."""

    order = pyblish.api.ValidatorOrder
    families = ["pointcloud"]
    hosts = ["max"]
    label = "TyFlow Data"

    def process(self, instance):
        """
        Notes:
            1. Validate the container only include tyFlow objects
            2. Validate if tyFlow operator Export Particle exists

        """
        errors = []
        invalid_object = self.get_tyflow_object(instance)
        if invalid_object:
            errors.append(f"Non tyFlow object found: {invalid_object}")

        invalid_operator = self.get_tyflow_operator(instance)
        if invalid_operator:
            errors.append(invalid_operator)
        if errors:
            bullet_point_invalid_statement = "\n".join(
                "- {}".format(error) for error
                in errors
            )
            report = (
                "TyFlow Data has invalid values(s).\n\n"
                f"{bullet_point_invalid_statement}\n\n"
            )
            raise PublishValidationError(
                report,
                title="Invalid value(s) for TyFlow Data")


    def get_tyflow_object(self, instance):
        """Get the nodes which are not tyFlow object(s)
        and editable mesh(es)

        Args:
            instance (pyblish.api.Instance): instance

        Returns:
            list: invalid nodes which are not tyFlow
                object(s) and editable mesh(es).
        """
        container = instance.data["instance_node"]
        self.log.debug(f"Validating tyFlow container for {container}")

        allowed_classes = [rt.tyFlow, rt.Editable_Mesh]
        return [
            member for member in instance.data["members"]
            if rt.ClassOf(member) not in allowed_classes
        ]

    def get_tyflow_operator(self, instance):
        """Check if the Export Particle Operators in the node
        connections.

        Args:
            instance (str): instance node

        Returns:
            invalid(list): list of invalid nodes which are not
            export particle operators or with the invalid export
            modes
        """
        invalid = []
        members = instance.data["members"]
        for member in members:
            obj = member.baseobject
            # There must be at least one animation with export
            # particles enabled
            anim_names = rt.GetSubAnimNames(obj)
            has_export_particle = False
            for anim_name in anim_names:
                # get name of the related tyFlow node
                sub_anim = rt.GetSubAnim(obj, anim_name)
                # Isolate only the events
                if not rt.isKindOf(sub_anim, rt.tyEvent):
                    continue
                # Look through all the nodes in the events
                node_names = rt.GetSubAnimNames(sub_anim)
                for node_name in node_names:
                    node_sub_anim = rt.GetSubAnim(sub_anim, node_name)
                    if rt.hasProperty(node_sub_anim, "exportMode"):
                        # check if the current export mode of the operator
                        # is valid for the tycache export.
                        if node_sub_anim.exportMode == 1 or \
                            node_sub_anim.exportMode == 2 or \
                                node_sub_anim.exportMode == 6:
                            has_export_particle = True
                            break

            if has_export_particle:
                break

            if not has_export_particle:
                invalid.append(f"{member.name} has invalid Export Mode.")

        return invalid

get_tyflow_object(instance)

Get the nodes which are not tyFlow object(s) and editable mesh(es)

Parameters:

Name Type Description Default
instance Instance

instance

required

Returns:

Name Type Description
list

invalid nodes which are not tyFlow object(s) and editable mesh(es).

Source code in client/ayon_max/plugins/publish/validate_tyflow_data.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
def get_tyflow_object(self, instance):
    """Get the nodes which are not tyFlow object(s)
    and editable mesh(es)

    Args:
        instance (pyblish.api.Instance): instance

    Returns:
        list: invalid nodes which are not tyFlow
            object(s) and editable mesh(es).
    """
    container = instance.data["instance_node"]
    self.log.debug(f"Validating tyFlow container for {container}")

    allowed_classes = [rt.tyFlow, rt.Editable_Mesh]
    return [
        member for member in instance.data["members"]
        if rt.ClassOf(member) not in allowed_classes
    ]

get_tyflow_operator(instance)

Check if the Export Particle Operators in the node connections.

Parameters:

Name Type Description Default
instance str

instance node

required

Returns:

Name Type Description
invalid list

list of invalid nodes which are not

export particle operators or with the invalid export

modes

Source code in client/ayon_max/plugins/publish/validate_tyflow_data.py
 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
def get_tyflow_operator(self, instance):
    """Check if the Export Particle Operators in the node
    connections.

    Args:
        instance (str): instance node

    Returns:
        invalid(list): list of invalid nodes which are not
        export particle operators or with the invalid export
        modes
    """
    invalid = []
    members = instance.data["members"]
    for member in members:
        obj = member.baseobject
        # There must be at least one animation with export
        # particles enabled
        anim_names = rt.GetSubAnimNames(obj)
        has_export_particle = False
        for anim_name in anim_names:
            # get name of the related tyFlow node
            sub_anim = rt.GetSubAnim(obj, anim_name)
            # Isolate only the events
            if not rt.isKindOf(sub_anim, rt.tyEvent):
                continue
            # Look through all the nodes in the events
            node_names = rt.GetSubAnimNames(sub_anim)
            for node_name in node_names:
                node_sub_anim = rt.GetSubAnim(sub_anim, node_name)
                if rt.hasProperty(node_sub_anim, "exportMode"):
                    # check if the current export mode of the operator
                    # is valid for the tycache export.
                    if node_sub_anim.exportMode == 1 or \
                        node_sub_anim.exportMode == 2 or \
                            node_sub_anim.exportMode == 6:
                        has_export_particle = True
                        break

        if has_export_particle:
            break

        if not has_export_particle:
            invalid.append(f"{member.name} has invalid Export Mode.")

    return invalid

process(instance)

Notes
  1. Validate the container only include tyFlow objects
  2. Validate if tyFlow operator Export Particle exists
Source code in client/ayon_max/plugins/publish/validate_tyflow_data.py
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
def process(self, instance):
    """
    Notes:
        1. Validate the container only include tyFlow objects
        2. Validate if tyFlow operator Export Particle exists

    """
    errors = []
    invalid_object = self.get_tyflow_object(instance)
    if invalid_object:
        errors.append(f"Non tyFlow object found: {invalid_object}")

    invalid_operator = self.get_tyflow_operator(instance)
    if invalid_operator:
        errors.append(invalid_operator)
    if errors:
        bullet_point_invalid_statement = "\n".join(
            "- {}".format(error) for error
            in errors
        )
        report = (
            "TyFlow Data has invalid values(s).\n\n"
            f"{bullet_point_invalid_statement}\n\n"
        )
        raise PublishValidationError(
            report,
            title="Invalid value(s) for TyFlow Data")

ValidateTyFlowTySplineData

Bases: ValidateTyFlowData

Source code in client/ayon_max/plugins/publish/validate_tyflow_data.py
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
class ValidateTyFlowTySplineData(ValidateTyFlowData):
    families = ["tycache", "tyspline"]
    hosts = ["max"]
    label = "TyFlow Data (TyCache)"

    def process(self, instance):
        """
        Notes:
            1. Validate the container only include tyFlow objects
            2. Validate if tyFlow operator Export Particle exists
            3. Validate if tyFlow operator Spline Paths exists

        """
        errors = []
        invalid_operator = self.get_tyflow_operator(instance)
        if invalid_operator:
            errors.append(invalid_operator)
        no_spline_nodes = self.get_invalid_tycache_spline_nodes(instance)
        if no_spline_nodes:
            errors.append(no_spline_nodes)
        if errors:
            bullet_point_invalid_statement = "\n".join(
                "- {}".format(error) for error
                in errors
            )
            report = (
                "TyFlow Data has invalid values(s).\n\n"
                f"{bullet_point_invalid_statement}\n\n"
            )
            raise PublishValidationError(
                report,
                title="Invalid value(s) for TyFlow Data")

    def get_invalid_tycache_spline_nodes(self, instance):
        """Check if there is spline paths operators before the export

        Args:
            instance (pyblish.api.Instance): instance

        Returns:
            invalid: list of invalid nodes which are not
            with spline paths operators
        """
        invalid = []
        node_sub_anim = instance.data["operator"]
        if node_sub_anim is not None:
            if rt.hasProperty(node_sub_anim, "exportMode"):
                # check if the current export mode of the operator
                # is valid for the tycache export.
                if instance.data["exportMode"] == 2:
                    family = instance.data["productType"]
                    self.log.debug(
                        "Skipping checking spline path nodes "
                        f"as this instance exports in {family} format")
                    return invalid
            # check against the spline path node if
            # the export mode is tyspline
            if not rt.hasProperty(node_sub_anim, "splinePathsNode"):
                invalid.append(
                    f"{node_sub_anim.name} has no tycache spline nodes.")

        return invalid

    def get_tyflow_operator(self, instance):
        invalid = []
        node_sub_anim = instance.data["operator"]
        has_export_particle = []
        if node_sub_anim is not None:
            if rt.hasProperty(node_sub_anim, "exportMode"):
                if node_sub_anim.exportMode == 2 or \
                        node_sub_anim.exportMode == 6:
                    has_export_particle.append("True")
                else:
                    has_export_particle.append("False")
                    if "False" in has_export_particle:
                        invalid.append(
                            f"{node_sub_anim.name} has invalid Export Mode.")

        return invalid

get_invalid_tycache_spline_nodes(instance)

Check if there is spline paths operators before the export

Parameters:

Name Type Description Default
instance Instance

instance

required

Returns:

Name Type Description
invalid

list of invalid nodes which are not

with spline paths operators

Source code in client/ayon_max/plugins/publish/validate_tyflow_data.py
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
def get_invalid_tycache_spline_nodes(self, instance):
    """Check if there is spline paths operators before the export

    Args:
        instance (pyblish.api.Instance): instance

    Returns:
        invalid: list of invalid nodes which are not
        with spline paths operators
    """
    invalid = []
    node_sub_anim = instance.data["operator"]
    if node_sub_anim is not None:
        if rt.hasProperty(node_sub_anim, "exportMode"):
            # check if the current export mode of the operator
            # is valid for the tycache export.
            if instance.data["exportMode"] == 2:
                family = instance.data["productType"]
                self.log.debug(
                    "Skipping checking spline path nodes "
                    f"as this instance exports in {family} format")
                return invalid
        # check against the spline path node if
        # the export mode is tyspline
        if not rt.hasProperty(node_sub_anim, "splinePathsNode"):
            invalid.append(
                f"{node_sub_anim.name} has no tycache spline nodes.")

    return invalid

process(instance)

Notes
  1. Validate the container only include tyFlow objects
  2. Validate if tyFlow operator Export Particle exists
  3. Validate if tyFlow operator Spline Paths exists
Source code in client/ayon_max/plugins/publish/validate_tyflow_data.py
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
def process(self, instance):
    """
    Notes:
        1. Validate the container only include tyFlow objects
        2. Validate if tyFlow operator Export Particle exists
        3. Validate if tyFlow operator Spline Paths exists

    """
    errors = []
    invalid_operator = self.get_tyflow_operator(instance)
    if invalid_operator:
        errors.append(invalid_operator)
    no_spline_nodes = self.get_invalid_tycache_spline_nodes(instance)
    if no_spline_nodes:
        errors.append(no_spline_nodes)
    if errors:
        bullet_point_invalid_statement = "\n".join(
            "- {}".format(error) for error
            in errors
        )
        report = (
            "TyFlow Data has invalid values(s).\n\n"
            f"{bullet_point_invalid_statement}\n\n"
        )
        raise PublishValidationError(
            report,
            title="Invalid value(s) for TyFlow Data")