mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-27 14:22:37 +01:00
Add logic to collect user defined attributes and merge logic with pointcache and animation family + optimize the query by doing only one cmds.listAttr call
This commit is contained in:
parent
f4a0ab45e4
commit
17d494c1a2
3 changed files with 39 additions and 29 deletions
|
|
@ -58,17 +58,3 @@ class CollectAnimationOutputGeometry(pyblish.api.InstancePlugin):
|
|||
if instance.data.get("farm"):
|
||||
instance.data["families"].append("publish.farm")
|
||||
|
||||
# Collect user defined attributes.
|
||||
if not instance.data.get("includeUserDefinedAttributes", False):
|
||||
return
|
||||
|
||||
user_defined_attributes = set()
|
||||
for node in hierarchy:
|
||||
attrs = cmds.listAttr(node, userDefined=True) or list()
|
||||
shapes = cmds.listRelatives(node, shapes=True) or list()
|
||||
for shape in shapes:
|
||||
attrs.extend(cmds.listAttr(shape, userDefined=True) or list())
|
||||
|
||||
user_defined_attributes.update(attrs)
|
||||
|
||||
instance.data["userDefinedAttributes"] = list(user_defined_attributes)
|
||||
|
|
|
|||
|
|
@ -45,18 +45,3 @@ class CollectPointcache(pyblish.api.InstancePlugin):
|
|||
if proxy_set:
|
||||
instance.remove(proxy_set)
|
||||
instance.data["setMembers"].remove(proxy_set)
|
||||
|
||||
# Collect user defined attributes.
|
||||
if not instance.data.get("includeUserDefinedAttributes", False):
|
||||
return
|
||||
|
||||
user_defined_attributes = set()
|
||||
for node in instance:
|
||||
attrs = cmds.listAttr(node, userDefined=True) or list()
|
||||
shapes = cmds.listRelatives(node, shapes=True) or list()
|
||||
for shape in shapes:
|
||||
attrs.extend(cmds.listAttr(shape, userDefined=True) or list())
|
||||
|
||||
user_defined_attributes.update(attrs)
|
||||
|
||||
instance.data["userDefinedAttributes"] = list(user_defined_attributes)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
from maya import cmds
|
||||
|
||||
import pyblish.api
|
||||
|
||||
|
||||
class CollectUserDefinedAttributes(pyblish.api.InstancePlugin):
|
||||
"""Collect user defined attributes for nodes in instance."""
|
||||
|
||||
order = pyblish.api.CollectorOrder + 0.4
|
||||
families = ["pointcache", "animation", "usd"]
|
||||
label = "Collect User Defined Attributes"
|
||||
hosts = ["maya"]
|
||||
|
||||
def process(self, instance):
|
||||
|
||||
# Collect user defined attributes.
|
||||
if not instance.data.get("includeUserDefinedAttributes", False):
|
||||
return
|
||||
|
||||
if "out_hierarchy" in instance.data:
|
||||
# animation family
|
||||
nodes = instance.data["out_hierarchy"]
|
||||
else:
|
||||
nodes = instance[:]
|
||||
if not nodes:
|
||||
return
|
||||
|
||||
shapes = cmds.listRelatives(nodes, shapes=True, fullPath=True) or []
|
||||
nodes = set(nodes).union(shapes)
|
||||
|
||||
attrs = cmds.listAttr(list(nodes), userDefined=True) or []
|
||||
user_defined_attributes = list(sorted(set(attrs)))
|
||||
instance.data["userDefinedAttributes"] = user_defined_attributes
|
||||
|
||||
self.log.debug(
|
||||
"Collected user defined attributes: {}".format(
|
||||
", ".join(user_defined_attributes)
|
||||
)
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue