From f314d092e9b4d996f2785477ad14857c9863a042 Mon Sep 17 00:00:00 2001 From: kaa Date: Thu, 6 Jul 2023 12:12:34 +0200 Subject: [PATCH] Enhancement: build layout load audio before board (#54) * build layour load auido before board * build workfile clear_scene clear sequencer --- openpype/hosts/blender/api/ops.py | 7 +++++-- .../hosts/blender/scripts/build_workfile.py | 21 +++++++------------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/openpype/hosts/blender/api/ops.py b/openpype/hosts/blender/api/ops.py index 0060d59e944..08279366cb8 100644 --- a/openpype/hosts/blender/api/ops.py +++ b/openpype/hosts/blender/api/ops.py @@ -1026,9 +1026,9 @@ def __init__(self): def _build_first_workfile(self, clear_scene: bool, save_as: bool): """Execute Build First workfile process. - + Args: - clear_scene (bool): Clear scene content before the build. + clear_scene (bool): Clear scene content before the build. save_as (bool): Save as new incremented workfile after the build. """ if clear_scene: @@ -1042,6 +1042,9 @@ def _build_first_workfile(self, clear_scene: bool, save_as: bool): bpy.data.objects.remove(obj) for collection in set(bpy.data.collections): bpy.data.collections.remove(collection) + # clear sequencer + for seq in bpy.context.scene.sequence_editor.sequences: + bpy.context.scene.sequence_editor.sequences.remove(seq) # purgne unused datablock while bpy.data.orphans_purge( do_local_ids=False, do_recursive=True diff --git a/openpype/hosts/blender/scripts/build_workfile.py b/openpype/hosts/blender/scripts/build_workfile.py index 254ecb84bdf..f8d5f7e30c1 100644 --- a/openpype/hosts/blender/scripts/build_workfile.py +++ b/openpype/hosts/blender/scripts/build_workfile.py @@ -342,26 +342,21 @@ def load_references( """ errors = [] - # load the board mov as image background linked into the camera - if board_repre: - load_subset(project_name, board_repre, "Background") + # load the audio reference as sound into sequencer + if audio_repre: + load_subset(project_name, audio_repre, "Audio") else: errors.append( - "load subset BoardReference failed:" + "load subset AudioReference failed:" f" Missing subset for {asset_name}" ) - # Delete sound sequence from board mov - if len(bpy.context.scene.sequence_editor.sequences) > 0: - if sound_seq := bpy.context.scene.sequence_editor.sequences[-1]: - bpy.context.scene.sequence_editor.sequences.remove(sound_seq) - - # load the audio reference as sound into sequencer - if audio_repre: - load_subset(project_name, audio_repre, "Audio") + # load the board mov as image background linked into the camera + if board_repre: + load_subset(project_name, board_repre, "Background") else: errors.append( - "load subset AudioReference failed:" + "load subset BoardReference failed:" f" Missing subset for {asset_name}" )