Merge pull request #245 from BigRoy/chore/houdini_remove_collect_instances.py

Houdini: Remove legacy collect instances
This commit is contained in:
Ondřej Samohel 2024-03-26 17:17:34 +01:00 committed by GitHub
commit e31eb9119d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,100 +0,0 @@
import hou
import pyblish.api
from ayon_core.pipeline import AYON_INSTANCE_ID, AVALON_INSTANCE_ID
from ayon_core.hosts.houdini.api import lib
class CollectInstances(pyblish.api.ContextPlugin):
"""Gather instances by all node in out graph and pre-defined attributes
This collector takes into account folders that are associated with
an specific node and marked with a unique identifier;
Identifier:
id (str): "ayon.create.instance"
Specific node:
The specific node is important because it dictates in which way the
product is being exported.
alembic: will export Alembic file which supports cascading attributes
like 'cbId' and 'path'
geometry: Can export a wide range of file types, default out
"""
order = pyblish.api.CollectorOrder - 0.01
label = "Collect Instances"
hosts = ["houdini"]
def process(self, context):
nodes = hou.node("/out").children()
nodes += hou.node("/obj").children()
# Include instances in USD stage only when it exists so it
# remains backwards compatible with version before houdini 18
stage = hou.node("/stage")
if stage:
nodes += stage.recursiveGlob("*", filter=hou.nodeTypeFilter.Rop)
for node in nodes:
if not node.parm("id"):
continue
if node.evalParm("id") not in {
AYON_INSTANCE_ID, AVALON_INSTANCE_ID
}:
continue
# instance was created by new creator code, skip it as
# it is already collected.
if node.parm("creator_identifier"):
continue
has_family = node.evalParm("family")
assert has_family, "'%s' is missing 'family'" % node.name()
self.log.info(
"Processing legacy instance node {}".format(node.path())
)
data = lib.read(node)
# Check bypass state and reverse
if hasattr(node, "isBypassed"):
data.update({"active": not node.isBypassed()})
# temporarily translation of `active` to `publish` till issue has
# been resolved.
# https://github.com/pyblish/pyblish-base/issues/307
if "active" in data:
data["publish"] = data["active"]
# Create nice name if the instance has a frame range.
label = data.get("name", node.name())
label += " (%s)" % data["folderPath"] # include folder in name
instance = context.create_instance(label)
# Include `families` using `family` data
product_type = data["family"]
data["productType"] = product_type
instance.data["families"] = [product_type]
instance[:] = [node]
instance.data["instance_node"] = node.path()
instance.data.update(data)
def sort_by_family(instance):
"""Sort by family"""
return instance.data.get(
"families", instance.data.get("productType")
)
# Sort/grouped by family (preserving local index)
context[:] = sorted(context, key=sort_by_family)
return context