-
Notifications
You must be signed in to change notification settings - Fork 1
/
validate_no_rename.py
45 lines (33 loc) · 1.45 KB
/
validate_no_rename.py
1
2
3
4
5
6
7
8
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
import re
import pyblish.api
from maya import cmds
def short_name(node):
return node.rsplit("|", 1)[-1].rsplit(":", 1)[-1]
class ValidateNoRename(pyblish.api.Validator):
"""Checks to see if there are nodes with the original names.
If so it can be a cue for a scene/model that hasn't been cleaned yet.
This will check for geometry related names, like nurbs & polygons.
"""
families = ['model']
hosts = ['maya']
category = 'cleanup'
optional = True
version = (0, 1, 0)
label = 'No Default Naming'
__simpleNames = set(['pSphere', 'pCube', 'pCylinder', 'pCone', 'pPlane', 'pTorus',
'pPrism', 'pPyramid', 'pPipe', 'pHelix', 'pSolid',
'nurbsSphere', 'nurbsCube', 'nurbsCylinder', 'nurbsCone',
'nurbsPlane', 'nurbsTorus', 'nurbsCircle', 'nurbsSquare'])
__simpleNamesRegex = [re.compile('{0}[0-9]?$'.format(x)) for x in __simpleNames]
def process(self, instance):
"""Process all the nodes in the instance 'objectSet'"""
transforms = cmds.ls(instance, type='transform')
invalid = []
for t in transforms:
t_shortName = short_name(t)
for regex in self.__simpleNamesRegex:
if regex.match(t_shortName):
invalid.append(t)
break
if invalid:
raise ValueError("Non-renamed objects found: {0}".format(invalid))