Skip to content

Commit

Permalink
Enhancement: build layout load audio before board (#54)
Browse files Browse the repository at this point in the history
* build layour load auido before board

* build workfile clear_scene clear sequencer
  • Loading branch information
kaamaurice authored and Tilix4 committed Dec 12, 2023
1 parent 8fd9004 commit f314d09
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
7 changes: 5 additions & 2 deletions openpype/hosts/blender/api/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
21 changes: 8 additions & 13 deletions openpype/hosts/blender/scripts/build_workfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)

Expand Down

0 comments on commit f314d09

Please sign in to comment.