Skip to content

validate_no_colons_in_name

ValidateNoColonsInName

Bases: BlenderInstancePlugin, OptionalPyblishPluginMixin

There cannot be colons in names

Object or bone names cannot include colons. Other software do not handle colons correctly.

Source code in client/ayon_blender/plugins/publish/validate_no_colons_in_name.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
45
46
47
48
49
50
51
52
53
class ValidateNoColonsInName(
    plugin.BlenderInstancePlugin,
    OptionalPyblishPluginMixin
):
    """There cannot be colons in names

    Object or bone names cannot include colons. Other software do not
    handle colons correctly.

    """

    order = ValidateContentsOrder
    hosts = ["blender"]
    families = ["model", "rig"]
    label = "No Colons in names"
    actions = [ayon_blender.api.action.SelectInvalidAction]

    @staticmethod
    def get_invalid(instance) -> List:
        invalid = []
        for obj in instance:
            if ':' in obj.name:
                invalid.append(obj)
            if isinstance(obj, bpy.types.Object) and obj.type == 'ARMATURE':
                for bone in obj.data.bones:
                    if ':' in bone.name:
                        invalid.append(obj)
                        break
        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"Objects found with colon in name: {names}"
            )