Bases: MayaInstancePlugin
, OptionalPyblishPluginMixin
Ensure Assembly name ends with GRP
Check if assembly name ends with _GRP
string.
Source code in client/ayon_maya/plugins/publish/validate_assembly_name.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
59 | class ValidateAssemblyName(plugin.MayaInstancePlugin,
OptionalPyblishPluginMixin):
""" Ensure Assembly name ends with `GRP`
Check if assembly name ends with `_GRP` string.
"""
label = "Validate Assembly Name"
order = pyblish.api.ValidatorOrder
families = ["assembly"]
actions = [ayon_maya.api.action.SelectInvalidAction]
active = False
optional = True
@classmethod
def get_invalid(cls, instance):
cls.log.debug("Checking name of {}".format(instance.name))
content_instance = instance.data.get("setMembers", None)
if not content_instance:
cls.log.error("Instance has no nodes!")
return True
# All children will be included in the extracted export so we also
# validate *all* descendents of the set members and we skip any
# intermediate shapes
descendants = cmds.listRelatives(content_instance,
allDescendents=True,
fullPath=True) or []
descendants = cmds.ls(
descendants, noIntermediate=True, type="transform")
content_instance = list(set(content_instance + descendants))
assemblies = cmds.ls(content_instance, assemblies=True, long=True)
invalid = []
for cr in assemblies:
if not cr.endswith('_GRP'):
cls.log.error("{} doesn't end with _GRP".format(cr))
invalid.append(cr)
return invalid
def process(self, instance):
if not self.is_active(instance.data):
return
invalid = self.get_invalid(instance)
if invalid:
raise PublishValidationError("Found {} invalid named assembly "
"items".format(len(invalid)))
|