Skip to content

validate_single_assembly

ValidateSingleAssembly

Bases: MayaInstancePlugin, OptionalPyblishPluginMixin

Ensure the content of the instance is grouped in a single hierarchy

The instance must have a single root node containing all the content. This root node must be a top group in the outliner.

Example outliner

root_GRP -- geometry_GRP -- mesh_GEO -- controls_GRP -- control_CTL

Source code in client/ayon_maya/plugins/publish/validate_single_assembly.py
 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
class ValidateSingleAssembly(plugin.MayaInstancePlugin,
                             OptionalPyblishPluginMixin):
    """Ensure the content of the instance is grouped in a single hierarchy

    The instance must have a single root node containing all the content.
    This root node *must* be a top group in the outliner.

    Example outliner:
        root_GRP
            -- geometry_GRP
               -- mesh_GEO
            -- controls_GRP
               -- control_CTL

    """

    order = ValidateContentsOrder
    families = ['rig']
    label = 'Single Assembly'

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

        from maya import cmds

        assemblies = cmds.ls(instance, assemblies=True)

        # ensure unique (somehow `maya.cmds.ls` doesn't manage that)
        assemblies = set(assemblies)

        if len(assemblies) == 0:
            raise PublishValidationError(
                "One assembly required for: %s (currently empty?)" % instance
            )
        elif len(assemblies) > 1:
            raise PublishValidationError(
                'Multiple assemblies found: %s' % assemblies
            )