Move Anim_Setup module into Blender_Kitsu #5

Merged
Nick Alberelli merged 27 commits from :feature/merge_anim_setup_into_blender_kitsu into master 2023-04-05 17:38:41 +02:00
2 changed files with 24 additions and 16 deletions
Showing only changes of commit 44cb913195 - Show all commits

View File

@ -5,16 +5,18 @@ from typing import Set
from blender_kitsu import prefs from blender_kitsu import prefs
from blender_kitsu import cache from blender_kitsu import cache
def editorial_export_get_latest(self, context:bpy.types.Context): def editorial_export_get_latest(context:bpy.types.Context) -> list[bpy.types.Sequence]:
"""Loads latest export from editorial department""" """Loads latest export from editorial department"""
addon_prefs = prefs.addon_prefs_get(context) addon_prefs = prefs.addon_prefs_get(context)
edit_export_path = Path(addon_prefs.edit_export_dir) edit_export_path = Path(addon_prefs.edit_export_dir)
strip_channel = 1 strip_channel = 1
latest_file = editorial_export_check_latest(context) latest_file = editorial_export_check_latest(context)
if not latest_file: if not latest_file:
self.report( return None
{"ERROR"}, f"Found no edit file in: {edit_export_path.as_posix()}" shot = cache.shot_active_get()
) # Check if Kitsu server returned empty shot
if shot.id == '':
return None
strip_filepath = latest_file.as_posix() strip_filepath = latest_file.as_posix()
strip_frame_start = addon_prefs.shot_builder_frame_offset strip_frame_start = addon_prefs.shot_builder_frame_offset
@ -23,20 +25,19 @@ def editorial_export_get_latest(self, context:bpy.types.Context):
scene.sequence_editor_create() scene.sequence_editor_create()
seq_editor = scene.sequence_editor seq_editor = scene.sequence_editor
movie_strip = seq_editor.sequences.new_movie( movie_strip = seq_editor.sequences.new_movie(
strip_filepath, latest_file.name,
strip_filepath, strip_filepath,
strip_channel + 1, strip_channel + 1,
strip_frame_start, strip_frame_start,
fit_method="FIT", fit_method="FIT",
) )
sound_strip = seq_editor.sequences.new_sound( sound_strip = seq_editor.sequences.new_sound(
strip_filepath, latest_file.name,
strip_filepath, strip_filepath,
strip_channel, strip_channel,
strip_frame_start, strip_frame_start,
) )
shot = cache.shot_active_get() new_strips = [movie_strip, sound_strip]
# Update shift frame range prop. # Update shift frame range prop.
frame_in = shot.frame_in frame_in = shot.frame_in
@ -44,10 +45,10 @@ def editorial_export_get_latest(self, context:bpy.types.Context):
frame_3d_offset = frame_3d_in - addon_prefs.shot_builder_frame_offset frame_3d_offset = frame_3d_in - addon_prefs.shot_builder_frame_offset
# Set sequence strip start kitsu data. # Set sequence strip start kitsu data.
for strip in scene.sequence_editor.sequences_all: for strip in new_strips:
strip.frame_start = -frame_in + (strip_frame_start * 2) + frame_3d_offset strip.frame_start = -frame_in + (strip_frame_start * 2) + frame_3d_offset
return new_strips
self.report({"INFO"}, f"Loaded latest edit: {latest_file.name}")
def editorial_export_check_latest(context: bpy.types.Context): def editorial_export_check_latest(context: bpy.types.Context):

View File

@ -2,20 +2,27 @@ import bpy
from typing import Set from typing import Set
from blender_kitsu.shot_builder.editorial.core import editorial_export_get_latest from blender_kitsu.shot_builder.editorial.core import editorial_export_get_latest
class ANIM_SETUP_OT_load_latest_edit(bpy.types.Operator): class ANIM_SETUP_OT_load_latest_editorial(bpy.types.Operator):
bl_idname = "asset_setup.load_latest_edit" bl_idname = "asset_setup.load_latest_editorial"
bl_label = "Load edit" bl_label = "Load Editorial Export"
bl_description = ( bl_description = (
"Loads latest edit from shot_preview_folder " "Loads latest edit from shot_preview_folder "
"Shifts edit so current shot starts at 3d_in metadata shot key from Kitsu" "Shifts edit so current shot starts at 3d_in metadata shot key from Kitsu"
) )
def execute(self, context: bpy.types.Context) -> Set[str]: def execute(self, context: bpy.types.Context) -> Set[str]:
editorial_export_get_latest(self, context) strips = editorial_export_get_latest(self, context)
if strips is None:
self.report(
{"ERROR"}, f"No valid editorial export in editorial export path."
)
return {"CANCELLED"}
self.report({"INFO"}, f"Loaded latest edit: {strips[0].name}")
return {"FINISHED"} return {"FINISHED"}
classes = [ classes = [
ANIM_SETUP_OT_load_latest_edit, ANIM_SETUP_OT_load_latest_editorial,
] ]