Skip to content

validate_node_no_ghosting

ValidateNodeNoGhosting

Bases: MayaInstancePlugin, OptionalPyblishPluginMixin

Ensure nodes do not have ghosting enabled.

If one would publish towards a non-Maya format it's likely that stats like ghosting won't be exported, eg. exporting to Alembic.

Instead of creating many micro-managing checks (like this one) to ensure attributes have not been changed from their default it could be more efficient to export to a format that will never hold such data anyway.

Source code in client/ayon_maya/plugins/publish/validate_node_no_ghosting.py
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
class ValidateNodeNoGhosting(plugin.MayaInstancePlugin,
                             OptionalPyblishPluginMixin):
    """Ensure nodes do not have ghosting enabled.

    If one would publish towards a non-Maya format it's likely that stats
    like ghosting won't be exported, eg. exporting to Alembic.

    Instead of creating many micro-managing checks (like this one) to ensure
    attributes have not been changed from their default it could be more
    efficient to export to a format that will never hold such data anyway.

    """

    order = ValidateContentsOrder
    families = ['model', 'rig']
    label = "No Ghosting"
    actions = [ayon_maya.api.action.SelectInvalidAction]
    optional = False

    _attributes = {'ghosting': 0}

    @classmethod
    def get_invalid(cls, instance):

        # Transforms and shapes seem to have ghosting
        nodes = cmds.ls(instance, long=True, type=['transform', 'shape'])
        invalid = []
        for node in nodes:
            _iteritems = getattr(
                cls._attributes, "iteritems", cls._attributes.items
            )
            for attr, required_value in _iteritems():
                if cmds.attributeQuery(attr, node=node, exists=True):

                    value = cmds.getAttr('{0}.{1}'.format(node, attr))
                    if value != required_value:
                        invalid.append(node)

        return invalid

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

        if invalid:
            raise PublishValidationError(
                "Nodes with ghosting enabled found: {0}".format(invalid))