-
Notifications
You must be signed in to change notification settings - Fork 1
/
validate_display_layer_empty.py
51 lines (36 loc) · 1.23 KB
/
validate_display_layer_empty.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
46
47
48
49
50
51
import pyblish.api
from maya import cmds
class ValidateDisplayLayerEmpty(pyblish.api.Validator):
"""Validate there are no empty displayLayers in the scene.
.. note::
This is a scene wide validation.
.. note::
This filters out checking the display layers
that exist by default in Maya and are mostly
hidden to the end user.
"""
hosts = ['maya']
category = 'scene'
version = (0, 1, 0)
optional = True
label = "No Empty Display Layers"
__skip_layers = ['defaultLayer']
def _get_empty_layers(self):
layers = cmds.ls(type='displayLayer')
empty = []
for layer in layers:
if layer in self.__skip_layers:
continue
members = cmds.editDisplayLayerMembers(layer, q=1)
if not members:
empty.append(layer)
return empty
def process(self, context):
"""Process the Context"""
invalid = self._get_empty_layers()
if invalid:
raise ValueError("Empty displayLayers found: {0}".format(invalid))
def repair(self, context):
"""Repair by deleting the empty layers"""
invalid = self._get_empty_layers()
cmds.delete(invalid)