Skip to content

validate_object_mode

ValidateObjectIsInObjectMode

Bases: BlenderInstancePlugin, OptionalPyblishPluginMixin

Validate that the objects in the instance are in Object Mode.

Source code in client/ayon_blender/plugins/publish/validate_object_mode.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
41
42
43
44
class ValidateObjectIsInObjectMode(
    plugin.BlenderInstancePlugin,
    OptionalPyblishPluginMixin,
):
    """Validate that the objects in the instance are in Object Mode."""

    order = pyblish.api.ValidatorOrder - 0.01
    hosts = ["blender"]
    families = ["model", "rig", "layout"]
    label = "Validate Object Mode"
    actions = [ayon_blender.api.action.SelectInvalidAction]
    optional = False

    @staticmethod
    def get_invalid(instance) -> List:
        invalid = []
        for obj in instance:
            if isinstance(obj, bpy.types.Object) and obj.mode != "OBJECT":
                invalid.append(obj)
        return invalid

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

        invalid = self.get_invalid(instance)
        if invalid:
            names = ", ".join(obj.name for obj in invalid)
            raise PublishValidationError(
                f"Object found in instance is not in Object Mode: {names}"
            )