From 56490932308362aa6fa615616919fc679e53d78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Tue, 9 Apr 2024 12:15:56 +0200 Subject: [PATCH] :bug: fix how folder name is used --- client/ayon_core/hosts/unreal/api/pipeline.py | 24 ++++++++++----- .../hosts/unreal/plugins/load/load_camera.py | 29 ++++++++++--------- .../hosts/unreal/plugins/load/load_layout.py | 7 ++++- pyproject.toml | 2 +- 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/client/ayon_core/hosts/unreal/api/pipeline.py b/client/ayon_core/hosts/unreal/api/pipeline.py index a60564d5b0..c5b2e6ee68 100644 --- a/client/ayon_core/hosts/unreal/api/pipeline.py +++ b/client/ayon_core/hosts/unreal/api/pipeline.py @@ -5,6 +5,7 @@ import logging from typing import List from contextlib import contextmanager import time +from pathlib import Path import semver import pyblish.api @@ -47,7 +48,7 @@ INVENTORY_PATH = os.path.join(PLUGINS_DIR, "inventory") class UnrealHost(HostBase, ILoadHost, IPublishHost): """Unreal host implementation. - For some time this class will re-use functions from module based + For some time this class will reuse functions from module based implementation for backwards compatibility of older unreal projects. """ @@ -590,22 +591,27 @@ def set_sequence_hierarchy( hid_section.set_level_names(maps) -def generate_sequence(h, h_dir): +def generate_sequence(folder_path: Path, unreal_directory: str): + """Generate Level Sequence from AYON folder. + + Args: + folder_path (Path): Path to AYON folder + unreal_directory (str): Unreal directory path + + """ tools = unreal.AssetToolsHelpers().get_asset_tools() sequence = tools.create_asset( - asset_name=h, - package_path=h_dir, + asset_name=folder_path.name, + package_path=unreal_directory, asset_class=unreal.LevelSequence, factory=unreal.LevelSequenceFactoryNew() ) project_name = get_current_project_name() - # TODO Fix this does not return folder path - folder_path = h_dir.split('/')[-1], folder_entity = ayon_api.get_folder_by_path( project_name, - folder_path, + folder_path.as_posix(), fields={"id", "attrib.fps"} ) @@ -627,6 +633,10 @@ def generate_sequence(h, h_dir): fields={"id", "attrib.clipIn", "attrib.clipOut"} )) + # folder doesn't have time data + if not start_frames or end_frames: + return + min_frame = min(start_frames) max_frame = max(end_frames) diff --git a/client/ayon_core/hosts/unreal/plugins/load/load_camera.py b/client/ayon_core/hosts/unreal/plugins/load/load_camera.py index 285834c911..777eb895e3 100644 --- a/client/ayon_core/hosts/unreal/plugins/load/load_camera.py +++ b/client/ayon_core/hosts/unreal/plugins/load/load_camera.py @@ -3,25 +3,24 @@ from pathlib import Path import ayon_api - import unreal -from unreal import ( - EditorAssetLibrary, - EditorLevelLibrary, - EditorLevelUtils, - LevelSequenceEditorBlueprintLibrary as LevelSequenceLib, +from ayon_core.hosts.unreal.api import plugin +from ayon_core.hosts.unreal.api.pipeline import ( + create_container, + generate_sequence, + imprint, + set_sequence_hierarchy, ) from ayon_core.pipeline import ( AYON_CONTAINER_ID, get_current_project_name, get_representation_path, ) -from ayon_core.hosts.unreal.api import plugin -from ayon_core.hosts.unreal.api.pipeline import ( - generate_sequence, - set_sequence_hierarchy, - create_container, - imprint, +from unreal import ( + EditorAssetLibrary, + EditorLevelLibrary, + EditorLevelUtils, + LevelSequenceEditorBlueprintLibrary as LevelSequenceLib, ) @@ -177,7 +176,11 @@ class CameraLoader(plugin.Loader): seq.get_asset().get_playback_start(), seq.get_asset().get_playback_end())) else: - sequence, frame_range = generate_sequence(h, h_dir) + sequence_data = generate_sequence( + Path(folder_path), h_dir) + if not sequence_data: + continue + sequence, frame_range = sequence_data[0], sequence_data[1] sequences.append(sequence) frame_ranges.append(frame_range) diff --git a/client/ayon_core/hosts/unreal/plugins/load/load_layout.py b/client/ayon_core/hosts/unreal/plugins/load/load_layout.py index b0f09ee8b0..315c6794aa 100644 --- a/client/ayon_core/hosts/unreal/plugins/load/load_layout.py +++ b/client/ayon_core/hosts/unreal/plugins/load/load_layout.py @@ -587,7 +587,12 @@ class LayoutLoader(plugin.Loader): ] if not existing_sequences: - sequence, frame_range = generate_sequence(h, h_dir) + sequence_data = generate_sequence( + Path(folder_path), h_dir + ) + if not sequence_data: + continue + sequence, frame_range = sequence_data[0], sequence_data[1] sequences.append(sequence) frame_ranges.append(frame_range) diff --git a/pyproject.toml b/pyproject.toml index 3c9ff4ea0a..acc0ee373a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -92,7 +92,7 @@ line-ending = "auto" [tool.codespell] # Ignore words that are not in the dictionary. -ignore-words-list = "ayon,ynput,parms,parm,hda" +ignore-words-list = "ayon,ynput,parms,parm,hda,ue" skip = "./.*,./package/*,*/vendor/*,*/unreal/integration/*,*/aftereffects/api/extension/js/libs/*" count = true quiet-level = 3