mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
update retrieving output nodes
This commit is contained in:
parent
1678bd5603
commit
79aab2534e
3 changed files with 65 additions and 63 deletions
|
|
@ -649,3 +649,42 @@ def get_color_management_preferences():
|
|||
"display": hou.Color.ocio_defaultDisplay(),
|
||||
"view": hou.Color.ocio_defaultView()
|
||||
}
|
||||
|
||||
|
||||
def get_obj_node_output(obj_node):
|
||||
"""Find output node.
|
||||
|
||||
get the output node with the minimum 'outputidx'
|
||||
or the node with display flag.
|
||||
"""
|
||||
|
||||
outputs = obj_node.subnetOutputs()
|
||||
if not outputs:
|
||||
return
|
||||
|
||||
elif len(outputs) == 1:
|
||||
return outputs[0]
|
||||
|
||||
else:
|
||||
return min(outputs,
|
||||
key=lambda node: node.evalParm('outputidx'))
|
||||
|
||||
|
||||
def get_output_children(output_node, include_sops=True):
|
||||
"""Recursively return a list of all output nodes
|
||||
contained in this node including this node.
|
||||
|
||||
It works in a similar manner to output_node.allNodes().
|
||||
"""
|
||||
out_list = [output_node]
|
||||
|
||||
if output_node.childTypeCategory() == hou.objNodeTypeCategory():
|
||||
for child in output_node.children():
|
||||
out_list += get_output_children(child, include_sops=include_sops)
|
||||
|
||||
elif include_sops and output_node.childTypeCategory() == hou.sopNodeTypeCategory():
|
||||
out = get_obj_node_output(output_node)
|
||||
if out:
|
||||
out_list += [out]
|
||||
|
||||
return out_list
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ from openpype.pipeline import (
|
|||
from openpype.pipeline.publish import ValidateContentsOrder
|
||||
|
||||
from openpype.hosts.houdini.api.action import SelectInvalidAction
|
||||
from openpype.hosts.houdini.api.lib import get_output_children
|
||||
|
||||
import hou
|
||||
|
||||
|
|
@ -47,24 +48,14 @@ class ValidateMeshIsStatic(pyblish.api.InstancePlugin,
|
|||
)
|
||||
return
|
||||
|
||||
all_outputs = get_output_children(output_node)
|
||||
|
||||
|
||||
if output_node.name().isTimeDependent():
|
||||
invalid.append(output_node)
|
||||
cls.log.error(
|
||||
"Output node '%s' is time dependent.",
|
||||
output_node.name()
|
||||
)
|
||||
|
||||
if output_node.childTypeCategory() == hou.objNodeTypeCategory():
|
||||
for child in output_node.children():
|
||||
if output_node.name().isTimeDependent():
|
||||
invalid.append(child)
|
||||
cls.log.error(
|
||||
"Child node '%s' in '%s' "
|
||||
"his time dependent.",
|
||||
child.name(), output_node.path()
|
||||
)
|
||||
break
|
||||
for output in all_outputs:
|
||||
if output.isTimeDependent():
|
||||
invalid.append(output)
|
||||
cls.log.error(
|
||||
"Output node '%s' is time dependent.",
|
||||
output.path()
|
||||
)
|
||||
|
||||
return invalid
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ from openpype.pipeline import (
|
|||
from openpype.pipeline.publish import ValidateContentsOrder
|
||||
|
||||
from openpype.hosts.houdini.api.action import SelectInvalidAction
|
||||
from openpype.hosts.houdini.api.lib import get_output_children
|
||||
|
||||
import hou
|
||||
|
||||
|
|
@ -69,28 +70,26 @@ class ValidateUnrealStaticMeshName(pyblish.api.InstancePlugin,
|
|||
)
|
||||
return
|
||||
|
||||
if not rop_node.evalParm('buildfrompath'):
|
||||
# This validator doesn't support naming check if
|
||||
# building hierarchy from path' is used
|
||||
cls.log.info(
|
||||
"Using 'Build Hierarchy from Path Attribute', skipping check.."
|
||||
)
|
||||
return
|
||||
|
||||
# Check nodes names
|
||||
if output_node.childTypeCategory() == hou.objNodeTypeCategory():
|
||||
for child in output_node.children():
|
||||
for prefix in cls.collision_prefixes:
|
||||
if child.name().startswith(prefix):
|
||||
invalid.append(child)
|
||||
cls.log.error(
|
||||
"Invalid name: Child node '%s' in '%s' "
|
||||
"has a collision prefix '%s'",
|
||||
child.name(), output_node.path(), prefix
|
||||
)
|
||||
break
|
||||
else:
|
||||
cls.log.debug(output_node.name())
|
||||
all_outputs = get_output_children(output_node, include_sops=False)
|
||||
for output in all_outputs:
|
||||
for prefix in cls.collision_prefixes:
|
||||
if output_node.name().startswith(prefix):
|
||||
invalid.append(output_node)
|
||||
if output.name().startswith(prefix):
|
||||
invalid.append(output)
|
||||
cls.log.error(
|
||||
"Invalid name: output node '%s' "
|
||||
"has a collision prefix '%s'",
|
||||
output_node.name(), prefix
|
||||
"Invalid node name: Node '%s' "
|
||||
"includes a collision prefix '%s'",
|
||||
output.path(), prefix
|
||||
)
|
||||
break
|
||||
|
||||
# Check subset name
|
||||
subset_name = "{}_{}{}".format(
|
||||
|
|
@ -107,30 +106,3 @@ class ValidateUnrealStaticMeshName(pyblish.api.InstancePlugin,
|
|||
)
|
||||
|
||||
return invalid
|
||||
|
||||
def get_outputs(self, output_node):
|
||||
|
||||
if output_node.childTypeCategory() == hou.objNodeTypeCategory():
|
||||
out_list = [output_node]
|
||||
for child in output_node.children():
|
||||
out_list += self.get_outputs(child)
|
||||
|
||||
return out_list
|
||||
|
||||
elif output_node.childTypeCategory() == hou.sopNodeTypeCategory():
|
||||
return [output_node, self.get_obj_output(output_node)]
|
||||
|
||||
def get_obj_output(self, obj_node):
|
||||
"""Find sop output node, """
|
||||
|
||||
outputs = obj_node.subnetOutputs()
|
||||
|
||||
if not outputs:
|
||||
return
|
||||
|
||||
elif len(outputs) == 1:
|
||||
return outputs[0]
|
||||
|
||||
else:
|
||||
return min(outputs,
|
||||
key=lambda node: node.evalParm('outputidx'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue