Blender Kitsu: Add Import Edit Render Operator for Shots #236

Merged
Nick Alberelli merged 6 commits from TinyNick/blender-studio-pipeline:feature/import_edit_export into main 2024-02-19 21:02:44 +01:00
5 changed files with 41 additions and 50 deletions
Showing only changes of commit 0ed5621edd - Show all commits

View File

@ -18,13 +18,13 @@ def edit_renders_get_all(context: bpy.types.Context):
"""Find latest render in editorial render directory""" """Find latest render in editorial render directory"""
addon_prefs = prefs.addon_prefs_get(context) addon_prefs = prefs.addon_prefs_get(context)
edit_render_path = Path(addon_prefs.edit_export_dir) edit_render_path = Path(addon_prefs.edit_render_dir)
files_list = [ files_list = [
f f
for f in edit_render_path.iterdir() for f in edit_render_path.iterdir()
if f.is_file() if f.is_file()
and edit_render_is_valid_edit_name(addon_prefs.edit_export_file_pattern, f.name) and edit_render_is_valid_edit_name(addon_prefs.edit_render_file_pattern, f.name)
] ]
return files_list return files_list
@ -78,7 +78,7 @@ def edit_render_import_latest(
frame_in = shot.data.get("frame_in") frame_in = shot.data.get("frame_in")
frame_3d_start = shot.get_3d_start() frame_3d_start = shot.get_3d_start()
frame_3d_offset = frame_3d_start - addon_prefs.shot_builder_frame_offset frame_3d_offset = frame_3d_start - addon_prefs.shot_builder_frame_offset
edit_export_offset = addon_prefs.edit_export_frame_offset edit_export_offset = addon_prefs.edit_render_frame_offset
# Set sequence strip start kitsu data. # Set sequence strip start kitsu data.
for strip in new_strips: for strip in new_strips:

View File

@ -148,7 +148,7 @@ class KITSU_OT_edit_render_set_version(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context: bpy.types.Context) -> bool: def poll(cls, context: bpy.types.Context) -> bool:
addon_prefs = prefs.addon_prefs_get(context) addon_prefs = prefs.addon_prefs_get(context)
return bool(addon_prefs.edit_export_dir != "") return bool(addon_prefs.edit_render_dir != "")
def execute(self, context: bpy.types.Context) -> Set[str]: def execute(self, context: bpy.types.Context) -> Set[str]:
kitsu_props = context.scene.kitsu kitsu_props = context.scene.kitsu
@ -282,7 +282,7 @@ class KITSU_OT_edit_render_import_latest(bpy.types.Operator):
if all_edit_render_paths == []: if all_edit_render_paths == []:
self.report( self.report(
{"WARNING"}, {"WARNING"},
f"No Edit Renders found in '{addon_prefs.edit_export_dir}' using pattern '{addon_prefs.edit_export_file_pattern}' See Add-On Preferences", f"No Edit Renders found in '{addon_prefs.edit_render_dir}' using pattern '{addon_prefs.edit_render_file_pattern}' See Add-On Preferences",
) )
return {"CANCELLED"} return {"CANCELLED"}

View File

@ -43,10 +43,10 @@ def init_edit_render_file_model(
addon_prefs = prefs.addon_prefs_get(context) addon_prefs = prefs.addon_prefs_get(context)
kitsu_props = context.scene.kitsu kitsu_props = context.scene.kitsu
edit_render_dir = Path(addon_prefs.edit_export_dir) edit_render_dir = Path(addon_prefs.edit_render_dir)
# Is None if invalid. # Is None if invalid.
if addon_prefs.edit_export_dir == "" or not edit_render_dir.exists(): if addon_prefs.edit_render_dir == "" or not edit_render_dir.exists():
logger.error( logger.error(
"Failed to initialize edit render file model. Invalid path. Check addon preferences" "Failed to initialize edit render file model. Invalid path. Check addon preferences"
) )

View File

@ -358,60 +358,60 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
subtype='DIR_PATH', subtype='DIR_PATH',
) )
def set_edit_export_dir(self, input): def set_edit_render_dir(self, input):
self['edit_export_dir'] = input self['edit_render_dir'] = input
return return
def get_edit_export_dir( def get_edit_render_dir(
self, self,
) -> str: ) -> str:
if get_safely_string_prop(self, 'edit_export_dir') == "" and self.project_root_path: if get_safely_string_prop(self, 'edit_render_dir') == "" and self.project_root_path:
dir = self.project_root_path.joinpath("shared/editorial/export/") dir = self.project_root_path.joinpath("shared/editorial/export/")
if dir.exists(): if dir.exists():
return dir.as_posix() return dir.as_posix()
return get_safely_string_prop(self, 'edit_export_dir') return get_safely_string_prop(self, 'edit_render_dir')
edit_export_dir: bpy.props.StringProperty( # type: ignore edit_render_dir: bpy.props.StringProperty( # type: ignore
name="Editorial Export Directory", name="Render Directory",
options={"HIDDEN", "SKIP_SAVE"}, options={"HIDDEN", "SKIP_SAVE"},
description="Directory path to editorial's export folder containing storyboard/animatic exports. Path should be similar to '~/shared-{proj_name}/editorial/export/'", description="Directory path to editorial's render folder containing storyboard/animatic renders. Path should be similar to '~/shared-{proj_name}/editorial/export/'",
subtype="DIR_PATH", subtype="DIR_PATH",
get=get_edit_export_dir, get=get_edit_render_dir,
set=set_edit_export_dir, set=set_edit_render_dir,
) )
def set_edit_export_file_pattern(self, input): def set_edit_render_file_pattern(self, input):
self['edit_export_file_pattern'] = input self['edit_render_file_pattern'] = input
return return
def get_edit_export_file_pattern( def get_edit_render_file_pattern(
self, self,
) -> str: ) -> str:
active_project = cache.project_active_get() active_project = cache.project_active_get()
if get_safely_string_prop(self, 'edit_export_file_pattern') == "" and active_project: if get_safely_string_prop(self, 'edit_render_file_pattern') == "" and active_project:
proj_name = active_project.name.replace(' ', bkglobals.SPACE_REPLACER).lower() proj_name = active_project.name.replace(' ', bkglobals.SPACE_REPLACER).lower()
# HACK for Project Gold at Blender Studio # HACK for Project Gold at Blender Studio
if proj_name == "project_gold": if proj_name == "project_gold":
return f"gold-edit-v###.mp4" return f"gold-edit-v###.mp4"
return f"{proj_name}-edit-v###.mp4" return f"{proj_name}-edit-v###.mp4"
return get_safely_string_prop(self, 'edit_export_file_pattern') return get_safely_string_prop(self, 'edit_render_file_pattern')
edit_export_file_pattern: bpy.props.StringProperty( # type: ignore edit_render_file_pattern: bpy.props.StringProperty( # type: ignore
name="Editorial Export File Pattern", name="Render File Pattern",
options={"HIDDEN", "SKIP_SAVE"}, options={"HIDDEN", "SKIP_SAVE"},
description=( description=(
"File pattern for latest editorial export file. " "File pattern for latest editorial render file. "
"Typically '{proj_name}-edit-v###.mp4' where # represents a number. " "Typically '{proj_name}-edit-v###.mp4' where # represents a number. "
"Pattern must contain exactly v### representing the version, pattern must end in .mp4" "Pattern must contain exactly v### representing the version, pattern must end in .mp4"
), ),
default="", default="",
get=get_edit_export_file_pattern, get=get_edit_render_file_pattern,
set=set_edit_export_file_pattern, set=set_edit_render_file_pattern,
) )
edit_export_frame_offset: bpy.props.IntProperty( # type: ignore edit_render_frame_offset: bpy.props.IntProperty( # type: ignore
name="Editorial Export Offset", name="Render Offset",
description="Shift Editorial Export by this frame-range after set-up.", description="Shift Editorial Render by this frame-range after import",
default=-101, # HARD CODED FOR GOLD PROJECTS BLENDER FILM default=-101, # HARD CODED FOR GOLD PROJECTS BLENDER FILM
) )
@ -490,11 +490,11 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
# Editorial Settings # Editorial Settings
box = col.box() box = col.box()
box.label(text="Video Sequence Editor", icon="SEQ_SEQUENCER") box.label(text="Editorial", icon="SEQ_SEQUENCER")
box.row().prop(self, "edit_export_dir") box.row().prop(self, "edit_render_dir")
file_pattern_row = box.row(align=True) file_pattern_row = box.row(align=True)
file_pattern_row.alert = not self.is_edit_render_pattern_valid file_pattern_row.alert = not self.is_edit_render_pattern_valid
file_pattern_row.prop(self, "edit_export_file_pattern") file_pattern_row.prop(self, "edit_render_file_pattern")
# Lookdev tools settings. # Lookdev tools settings.
self.lookdev.draw(context, col) self.lookdev.draw(context, col)
@ -527,7 +527,7 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
# Shot_Builder settings. # Shot_Builder settings.
box = col.box() box = col.box()
box.label(text="Shot Builder", icon="MOD_BUILD") box.label(text="Shot Builder", icon="MOD_BUILD")
box.row().prop(self, "edit_export_frame_offset") box.row().prop(self, "edit_render_frame_offset")
box.row().prop(self, "shot_builder_show_advanced") box.row().prop(self, "shot_builder_show_advanced")
if self.shot_builder_show_advanced: if self.shot_builder_show_advanced:
start_frame_row = box.row() start_frame_row = box.row()
@ -574,17 +574,17 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
@property @property
def is_edit_render_root_valid(self) -> bool: def is_edit_render_root_valid(self) -> bool:
if self.edit_export_dir.strip() == "": if self.edit_render_dir.strip() == "":
return False return False
if not Path(self.edit_export_dir).exists(): if not Path(self.edit_render_dir).exists():
return False return False
return True return True
@property @property
def is_edit_render_pattern_valid(self) -> bool: def is_edit_render_pattern_valid(self) -> bool:
if not self.edit_export_file_pattern.endswith(".mp4"): if not self.edit_render_file_pattern.endswith(".mp4"):
return False return False
if not "###" in self.edit_export_file_pattern: if not "###" in self.edit_render_file_pattern:
return False return False
return True return True
@ -614,15 +614,6 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
return True return True
@property
def is_editorial_dir_valid(self) -> bool:
if edit_render_get_latest(bpy.context) is None:
logger.error(
"Failed to initialize editorial export file model. Invalid path/pattern. Check addon preferences"
)
return False
return True
def session_get(context: bpy.types.Context) -> Session: def session_get(context: bpy.types.Context) -> Session:
""" """

View File

@ -170,12 +170,12 @@ def get_playblast_file(self: Any) -> str:
def get_edit_render_file(self: Any) -> str: def get_edit_render_file(self: Any) -> str:
addon_prefs = prefs.addon_prefs_get(bpy.context) addon_prefs = prefs.addon_prefs_get(bpy.context)
if not bool(addon_prefs.edit_export_dir): if not bool(addon_prefs.edit_render_dir):
return "" return ""
version = self.edit_render_version version = self.edit_render_version
file_pattern = addon_prefs.edit_export_file_pattern file_pattern = addon_prefs.edit_render_file_pattern
file_name = file_pattern.replace('v###', version) file_name = file_pattern.replace('v###', version)
return Path(addon_prefs.edit_export_dir).joinpath(file_name).as_posix() return Path(addon_prefs.edit_render_dir).joinpath(file_name).as_posix()
_active_category_cache_init: bool = False _active_category_cache_init: bool = False