mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
improved get_id function
This commit is contained in:
parent
f6539d4e33
commit
f0aafec1fa
2 changed files with 53 additions and 6 deletions
|
|
@ -663,14 +663,10 @@ def get_id(node):
|
||||||
if node is None:
|
if node is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
if not cmds.attributeQuery("cbId", node=node, exists=True):
|
||||||
attr = "{}.cbId".format(node)
|
|
||||||
attribute_value = cmds.getAttr(attr)
|
|
||||||
except Exception as e:
|
|
||||||
log.debug(e)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
return attribute_value
|
return cmds.getAttr("{}.cbId".format(node))
|
||||||
|
|
||||||
|
|
||||||
def get_representation_file(representation, template=TEMPLATE):
|
def get_representation_file(representation, template=TEMPLATE):
|
||||||
|
|
|
||||||
51
colorbleed/plugins/maya/publish/validate_node_ids_related.py
Normal file
51
colorbleed/plugins/maya/publish/validate_node_ids_related.py
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
import maya.cmds as cmds
|
||||||
|
|
||||||
|
import pyblish.api
|
||||||
|
import colorbleed.api
|
||||||
|
|
||||||
|
from colorbleed.maya import lib
|
||||||
|
|
||||||
|
|
||||||
|
class ValidateNodeIDs(pyblish.api.InstancePlugin):
|
||||||
|
"""Validate nodes have a Colorbleed Id
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
order = colorbleed.api.ValidatePipelineOrder
|
||||||
|
label = 'Node Ids (ID)'
|
||||||
|
hosts = ['maya']
|
||||||
|
families = ["colorbleed.model",
|
||||||
|
"colorbleed.lookdev",
|
||||||
|
"colorbleed.rig"]
|
||||||
|
|
||||||
|
actions = [colorbleed.api.SelectInvalidAction,
|
||||||
|
colorbleed.api.GenerateUUIDsOnInvalidAction]
|
||||||
|
|
||||||
|
def process(self, instance):
|
||||||
|
"""Process all meshes"""
|
||||||
|
|
||||||
|
# Ensure all nodes have a cbId
|
||||||
|
invalid = self.get_invalid(instance)
|
||||||
|
if invalid:
|
||||||
|
raise RuntimeError("Nodes found without "
|
||||||
|
"IDs: {0}".format(invalid))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_invalid(cls, instance):
|
||||||
|
"""Return the member nodes that are invalid"""
|
||||||
|
invalid = list()
|
||||||
|
|
||||||
|
# TODO: Implement check on only nodes like on_save callback.
|
||||||
|
instance_shape = cmds.ls(instance, type="shape")
|
||||||
|
|
||||||
|
# We do want to check the referenced nodes as we it might be
|
||||||
|
# part of the end product
|
||||||
|
nodes = lib.filter_out_nodes(set(instance_shape), defaults=True)
|
||||||
|
for node in nodes:
|
||||||
|
if not lib.get_id(node):
|
||||||
|
invalid.append(node)
|
||||||
|
|
||||||
|
return invalid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue