mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
improved functions, list comprehension
This commit is contained in:
parent
42d7779ce0
commit
6442c16964
5 changed files with 25 additions and 58 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from maya import cmds
|
||||
|
||||
import pyblish.api
|
||||
import colorbleed.api
|
||||
|
||||
|
|
@ -20,11 +22,10 @@ class ValidateLookDefaultShadersConnections(pyblish.api.InstancePlugin):
|
|||
label = 'Look Default Shader Connections'
|
||||
|
||||
# The default connections to check
|
||||
DEFAULTS = [
|
||||
("initialShadingGroup.surfaceShader", "lambert1"),
|
||||
("initialParticleSE.surfaceShader", "lambert1"),
|
||||
("initialParticleSE.volumeShader", "particleCloud1")
|
||||
]
|
||||
DEFAULTS = [("initialShadingGroup.surfaceShader", "lambert1"),
|
||||
("initialParticleSE.surfaceShader", "lambert1"),
|
||||
("initialParticleSE.volumeShader", "particleCloud1")
|
||||
]
|
||||
|
||||
def process(self, instance):
|
||||
|
||||
|
|
@ -33,19 +34,15 @@ class ValidateLookDefaultShadersConnections(pyblish.api.InstancePlugin):
|
|||
# the family is not present in an instance.
|
||||
key = "__validate_look_default_shaders_connections_checked"
|
||||
context = instance.context
|
||||
is_run = context.data.get(key,
|
||||
False)
|
||||
is_run = context.data.get(key, False)
|
||||
if is_run:
|
||||
return
|
||||
else:
|
||||
context.data[key] = True
|
||||
|
||||
# Process as usual
|
||||
from maya import cmds
|
||||
|
||||
invalid = list()
|
||||
for plug, input_node in self.DEFAULTS:
|
||||
|
||||
inputs = cmds.listConnections(plug,
|
||||
source=True,
|
||||
destination=False) or None
|
||||
|
|
|
|||
|
|
@ -4,15 +4,7 @@ from maya import cmds
|
|||
|
||||
import pyblish.api
|
||||
import colorbleed.api
|
||||
|
||||
|
||||
def get_unique_id(node):
|
||||
attr = 'cbId'
|
||||
unique_id = None
|
||||
has_attribute = cmds.attributeQuery(attr, node=node, exists=True)
|
||||
if has_attribute:
|
||||
unique_id = cmds.getAttr("{}.{}".format(node, attr))
|
||||
return unique_id
|
||||
import colorbleed.maya.lib as lib
|
||||
|
||||
|
||||
class ValidateNonDuplicateRelationshipMembers(pyblish.api.InstancePlugin):
|
||||
|
|
@ -43,26 +35,22 @@ class ValidateNonDuplicateRelationshipMembers(pyblish.api.InstancePlugin):
|
|||
# Get all members from the sets
|
||||
members = []
|
||||
relationships = instance.data["lookData"]["relationships"]
|
||||
for sg in relationships:
|
||||
sg_members = [member['name'] for member in sg['members']]
|
||||
members.extend(sg_members)
|
||||
for relationship in relationships:
|
||||
members.extend([i['name'] for i in relationship['members']])
|
||||
|
||||
# Ensure we don't have components but the objects
|
||||
members = cmds.ls(members, objectsOnly=True, long=True)
|
||||
members = list(set(members))
|
||||
members = set(cmds.ls(members, objectsOnly=True, long=True))
|
||||
members = list(members)
|
||||
|
||||
# Group members per id
|
||||
id_nodes = defaultdict(set)
|
||||
for node in members:
|
||||
node_id = get_unique_id(node)
|
||||
node_id = lib.get_id(node)
|
||||
if not node_id:
|
||||
continue
|
||||
id_nodes[node_id].add(node)
|
||||
|
||||
invalid = list()
|
||||
for nodes in id_nodes.itervalues():
|
||||
if len(nodes) > 1:
|
||||
invalid.extend(nodes)
|
||||
invalid = [n for n in id_nodes.itervalues() if len(n) > 1]
|
||||
|
||||
return invalid
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
from collections import defaultdict
|
||||
|
||||
import maya.cmds as cmds
|
||||
|
||||
import pyblish.api
|
||||
import colorbleed.api
|
||||
import colorbleed.maya.lib as lib
|
||||
|
||||
|
||||
class ValidateLookNodeUniqueIds(pyblish.api.InstancePlugin):
|
||||
|
|
@ -25,19 +24,13 @@ class ValidateLookNodeUniqueIds(pyblish.api.InstancePlugin):
|
|||
|
||||
# Ensure all nodes have a cbId
|
||||
id_sets = defaultdict(list)
|
||||
invalid = list()
|
||||
for node in nodes:
|
||||
unique_id = None
|
||||
if cmds.attributeQuery("cbId", node=node, exists=True):
|
||||
unique_id = cmds.getAttr("{}.cbId".format(node))
|
||||
unique_id = lib.get_id(node)
|
||||
if not unique_id:
|
||||
continue
|
||||
|
||||
id_sets[unique_id].append(node)
|
||||
|
||||
for unique_id, nodes in id_sets.iteritems():
|
||||
if len(nodes) > 1:
|
||||
invalid.extend(nodes)
|
||||
invalid = [n for n in id_sets.itervalues() if len(n) > 1]
|
||||
|
||||
return invalid
|
||||
|
||||
|
|
|
|||
|
|
@ -20,11 +20,16 @@ class ValidateNoAnimation(pyblish.api.Validator):
|
|||
optional = True
|
||||
actions = [colorbleed.api.SelectInvalidAction]
|
||||
|
||||
def process(self, instance):
|
||||
|
||||
invalid = self.get_invalid(instance)
|
||||
if invalid:
|
||||
raise RuntimeError("Keyframes found: {0}".format(invalid))
|
||||
|
||||
@staticmethod
|
||||
def get_invalid(instance):
|
||||
|
||||
nodes = instance[:]
|
||||
|
||||
if not nodes:
|
||||
return []
|
||||
|
||||
|
|
@ -33,10 +38,3 @@ class ValidateNoAnimation(pyblish.api.Validator):
|
|||
return list(set(cmds.listConnections(curves)))
|
||||
|
||||
return []
|
||||
|
||||
def process(self, instance):
|
||||
|
||||
invalid = self.get_invalid(instance)
|
||||
|
||||
if invalid:
|
||||
raise RuntimeError("Keyframes found: {0}".format(invalid))
|
||||
|
|
|
|||
|
|
@ -34,20 +34,11 @@ class ValidateNodeIDs(pyblish.api.InstancePlugin):
|
|||
def get_invalid(cls, instance):
|
||||
"""Return the member nodes that are invalid"""
|
||||
|
||||
invalid = list()
|
||||
|
||||
# We do want to check the referenced nodes as it might be
|
||||
# part of the end product
|
||||
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)
|
||||
invalid = [n for n in nodes if not lib.get_id(n)
|
||||
and not cls.validate_children(n)]
|
||||
|
||||
return invalid
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue