mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 05:42:15 +01:00
✨ cache collected instances
This commit is contained in:
parent
daabdb5cc6
commit
21e98faef0
2 changed files with 14 additions and 10 deletions
|
|
@ -435,10 +435,13 @@ def list_instances(creator_id=None):
|
|||
|
||||
"""
|
||||
instance_signature = {
|
||||
"id": "pyblish.avalon.instance",
|
||||
"identifier": creator_id
|
||||
"id": "pyblish.avalon.instance"
|
||||
}
|
||||
return lib.lsattrs(instance_signature)
|
||||
|
||||
return [
|
||||
i for i in lib.lsattrs(instance_signature)
|
||||
if i.paramEval("creator_identifier") == creator_id
|
||||
]
|
||||
|
||||
|
||||
def remove_instance(instance):
|
||||
|
|
@ -448,12 +451,8 @@ def remove_instance(instance):
|
|||
because it might contain valuable data for artist.
|
||||
|
||||
"""
|
||||
nodes = instance.get("members")
|
||||
if not nodes:
|
||||
return
|
||||
|
||||
# Assume instance node is first node
|
||||
instance_node = hou.node(nodes[0])
|
||||
instance_node = hou.node(instance.data.get("instance_node"))
|
||||
to_delete = None
|
||||
for parameter in instance_node.spareParms():
|
||||
if parameter.name() == "id" and \
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ class HoudiniCreator(NewCreator):
|
|||
|
||||
# wondering if we'll ever need more than one member here
|
||||
# in Houdini
|
||||
instance_data["members"] = [instance_node.path()]
|
||||
# instance_data["members"] = [instance_node.path()]
|
||||
instance_data["instance_node"] = instance_node.path()
|
||||
|
||||
instance = CreatedInstance(
|
||||
|
|
@ -167,7 +167,12 @@ class HoudiniCreator(NewCreator):
|
|||
self.log.debug("missing lock pattern {}".format(name))
|
||||
|
||||
def collect_instances(self):
|
||||
for instance in list_instances(creator_id=self.identifier):
|
||||
instances = [i for i in self.collection_shared_data.get(
|
||||
"houdini_cached_instances", []) if i.paramEval("creator_identifier") == self.identifier]
|
||||
if not instances:
|
||||
print("not using cached instances")
|
||||
instances = list_instances(creator_id=self.identifier)
|
||||
for instance in instances:
|
||||
created_instance = CreatedInstance.from_existing(
|
||||
read(instance), self
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue