improved validation

This commit is contained in:
aardschok 2017-08-09 12:02:16 +02:00
parent 52a36f3c94
commit 2dd251473c
2 changed files with 28 additions and 11 deletions

View file

@ -90,19 +90,23 @@ class ValidateLookContents(pyblish.api.InstancePlugin):
"""Check if instance content items are part of the default nodes"""
invalid = []
cams = cmds.ls(['frontShape', 'perspShape', 'sideShape', 'topShape'],
long=True)
defaults = cmds.ls(long=True, defaultNodes=True)
defaults.extend(cams)
cams = ["perspShape", "topShape", "frontShape", "sideShape"]
cameras = cmds.ls(cams, long=True)
references = cmds.ls(referencedNodes=True)
default_nodes = cmds.ls(defaultNodes=True, long=True)
defaults = list(set(cameras + references + default_nodes))
for node in cmds.ls(instance[:], long=True):
# might be a transform of a default item listed
if cmds.nodeType(node) == "transform":
node = cmds.listRelatives(node,
children=True,
fullPath=True)[0] or None
print node, node in defaults
children = cmds.listRelatives(node,
children=True,
fullPath=True)
if children:
node = children
else:
continue
if node in defaults:
invalid.append(node)

View file

@ -12,7 +12,7 @@ class ValidateNodeIDs(pyblish.api.InstancePlugin):
"""
order = colorbleed.api.ValidatePipelineOrder
label = 'Node Ids (ID)'
label = 'Instance Nodes Have ID'
hosts = ['maya']
families = ["colorbleed.model",
"colorbleed.lookdev",
@ -41,9 +41,22 @@ class ValidateNodeIDs(pyblish.api.InstancePlugin):
nodes = lib.filter_out_nodes(set(instance[:]), defaults=True)
for node in nodes:
if not lib.get_id(node):
# check if siblings have IDs
valid_hierarchy = cls.validate_children(node)
if valid_hierarchy:
continue
invalid.append(node)
return invalid
@staticmethod
def validate_children(node):
"""Validate the children of the node if the ID is not present"""
children = cmds.listRelatives(node, children=True)
for child in children:
if lib.get_id(child):
return True
return False