mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
Updated the loading of the layout to support nested containers
This commit is contained in:
parent
3c65258901
commit
1c27e66109
2 changed files with 31 additions and 21 deletions
|
|
@ -29,15 +29,19 @@ def get_unique_number(
|
|||
c for c in bpy.data.collections
|
||||
if c.name == 'AVALON_CONTAINERS'
|
||||
]
|
||||
loaded_assets = []
|
||||
containers = []
|
||||
# First, add the children of avalon containers
|
||||
for c in avalon_containers:
|
||||
loaded_assets.extend(c.children)
|
||||
collections_names = [
|
||||
c.name for c in loaded_assets
|
||||
containers.extend(c.children)
|
||||
# then keep looping to include all the children
|
||||
for c in containers:
|
||||
containers.extend(c.children)
|
||||
container_names = [
|
||||
c.name for c in containers
|
||||
]
|
||||
count = 1
|
||||
name = f"{asset}_{count:0>2}_{subset}_CON"
|
||||
while name in collections_names:
|
||||
while name in container_names:
|
||||
count += 1
|
||||
name = f"{asset}_{count:0>2}_{subset}_CON"
|
||||
return f"{count:0>2}"
|
||||
|
|
@ -197,16 +201,16 @@ class AssetLoader(api.Loader):
|
|||
return None
|
||||
|
||||
# Only containerise if it's not already a collection from a .blend file.
|
||||
representation = context["representation"]["name"]
|
||||
if representation != "blend":
|
||||
from avalon.blender.pipeline import containerise
|
||||
return containerise(
|
||||
name=name,
|
||||
namespace=namespace,
|
||||
nodes=nodes,
|
||||
context=context,
|
||||
loader=self.__class__.__name__,
|
||||
)
|
||||
# representation = context["representation"]["name"]
|
||||
# if representation != "blend":
|
||||
# from avalon.blender.pipeline import containerise
|
||||
# return containerise(
|
||||
# name=name,
|
||||
# namespace=namespace,
|
||||
# nodes=nodes,
|
||||
# context=context,
|
||||
# loader=self.__class__.__name__,
|
||||
# )
|
||||
|
||||
asset = context["asset"]["name"]
|
||||
subset = context["subset"]["name"]
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ class BlendLayoutLoader(plugin.AssetLoader):
|
|||
assert libpath.is_file(), (
|
||||
f"The file doesn't exist: {libpath}"
|
||||
)
|
||||
assert extension in pype.hosts.blender.plugin.VALID_EXTENSIONS, (
|
||||
assert extension in plugin.VALID_EXTENSIONS, (
|
||||
f"Unsupported file: {libpath}"
|
||||
)
|
||||
|
||||
|
|
@ -350,17 +350,17 @@ class UnrealLayoutLoader(plugin.AssetLoader):
|
|||
asset, subset, unique_number
|
||||
)
|
||||
|
||||
container = bpy.data.collections.new(lib_container)
|
||||
container.name = container_name
|
||||
layout_container = bpy.data.collections.new(lib_container)
|
||||
layout_container.name = container_name
|
||||
blender.pipeline.containerise_existing(
|
||||
container,
|
||||
layout_container,
|
||||
name,
|
||||
namespace,
|
||||
context,
|
||||
self.__class__.__name__,
|
||||
)
|
||||
|
||||
container_metadata = container.get(
|
||||
container_metadata = layout_container.get(
|
||||
blender.pipeline.AVALON_PROPERTY)
|
||||
|
||||
container_metadata["libpath"] = libpath
|
||||
|
|
@ -375,6 +375,9 @@ class UnrealLayoutLoader(plugin.AssetLoader):
|
|||
|
||||
all_loaders = api.discover(api.Loader)
|
||||
|
||||
avalon_container = bpy.data.collections.get(
|
||||
blender.pipeline.AVALON_CONTAINERS)
|
||||
|
||||
for element in data:
|
||||
reference = element.get('reference')
|
||||
family = element.get('family')
|
||||
|
|
@ -396,6 +399,9 @@ class UnrealLayoutLoader(plugin.AssetLoader):
|
|||
if not element_container:
|
||||
continue
|
||||
|
||||
avalon_container.children.unlink(element_container)
|
||||
layout_container.children.link(element_container)
|
||||
|
||||
element_metadata = element_container.get(
|
||||
blender.pipeline.AVALON_PROPERTY)
|
||||
|
||||
|
|
@ -426,7 +432,7 @@ class UnrealLayoutLoader(plugin.AssetLoader):
|
|||
# Save the list of objects in the metadata container
|
||||
container_metadata["objects"] = layout_collection.all_objects
|
||||
|
||||
nodes = [container]
|
||||
nodes = [layout_container]
|
||||
self[:] = nodes
|
||||
return nodes
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue