Skip to content

validate_step_size

ValidateStepSize

Bases: MayaInstancePlugin, OptionalPyblishPluginMixin

Validates the step size for the instance is in a valid range.

For example the step size should never be lower or equal to zero.

Source code in client/ayon_maya/plugins/publish/validate_step_size.py
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
class ValidateStepSize(plugin.MayaInstancePlugin,
                       OptionalPyblishPluginMixin):
    """Validates the step size for the instance is in a valid range.

    For example the `step` size should never be lower or equal to zero.

    """

    order = ValidateContentsOrder
    label = 'Step size'
    families = ['camera',
                'pointcache',
                'animation']
    actions = [ayon_maya.api.action.SelectInvalidAction]
    optional = False
    MIN = 0.01
    MAX = 1.0

    @classmethod
    def get_invalid(cls, instance):

        objset = instance.data['instance_node']
        step = instance.data.get("step", 1.0)

        if step < cls.MIN or step > cls.MAX:
            cls.log.warning("Step size is outside of valid range: {0} "
                            "(valid: {1} to {2})".format(step,
                                                         cls.MIN,
                                                         cls.MAX))
            return objset

        return []

    def process(self, instance):
        if not self.is_active(instance.data):
            return
        invalid = self.get_invalid(instance)
        if invalid:
            raise PublishValidationError(
                "Instance found with invalid step size: {0}".format(invalid))