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"""
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 = [
f
for f in edit_render_path.iterdir()
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
@ -78,7 +78,7 @@ def edit_render_import_latest(
frame_in = shot.data.get("frame_in")
frame_3d_start = shot.get_3d_start()
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.
for strip in new_strips:

View File

@ -148,7 +148,7 @@ class KITSU_OT_edit_render_set_version(bpy.types.Operator):
@classmethod
def poll(cls, context: bpy.types.Context) -> bool:
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]:
kitsu_props = context.scene.kitsu
@ -282,7 +282,7 @@ class KITSU_OT_edit_render_import_latest(bpy.types.Operator):
if all_edit_render_paths == []:
self.report(
{"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"}

View File

@ -43,10 +43,10 @@ def init_edit_render_file_model(
addon_prefs = prefs.addon_prefs_get(context)
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.
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(
"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',
)
def set_edit_export_dir(self, input):
self['edit_export_dir'] = input
def set_edit_render_dir(self, input):
self['edit_render_dir'] = input
return
def get_edit_export_dir(
def get_edit_render_dir(
self,
) -> 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/")
if dir.exists():
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
name="Editorial Export Directory",
edit_render_dir: bpy.props.StringProperty( # type: ignore
name="Render Directory",
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",
get=get_edit_export_dir,
set=set_edit_export_dir,
get=get_edit_render_dir,
set=set_edit_render_dir,
)
def set_edit_export_file_pattern(self, input):
self['edit_export_file_pattern'] = input
def set_edit_render_file_pattern(self, input):
self['edit_render_file_pattern'] = input
return
def get_edit_export_file_pattern(
def get_edit_render_file_pattern(
self,
) -> str:
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()
# HACK for Project Gold at Blender Studio
if proj_name == "project_gold":
return f"gold-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
name="Editorial Export File Pattern",
edit_render_file_pattern: bpy.props.StringProperty( # type: ignore
name="Render File Pattern",
options={"HIDDEN", "SKIP_SAVE"},
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. "
"Pattern must contain exactly v### representing the version, pattern must end in .mp4"
),
default="",
get=get_edit_export_file_pattern,
set=set_edit_export_file_pattern,
get=get_edit_render_file_pattern,
set=set_edit_render_file_pattern,
)
edit_export_frame_offset: bpy.props.IntProperty( # type: ignore
name="Editorial Export Offset",
description="Shift Editorial Export by this frame-range after set-up.",
edit_render_frame_offset: bpy.props.IntProperty( # type: ignore
name="Render Offset",
description="Shift Editorial Render by this frame-range after import",
default=-101, # HARD CODED FOR GOLD PROJECTS BLENDER FILM
)
@ -490,11 +490,11 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
# Editorial Settings
box = col.box()
box.label(text="Video Sequence Editor", icon="SEQ_SEQUENCER")
box.row().prop(self, "edit_export_dir")
box.label(text="Editorial", icon="SEQ_SEQUENCER")
box.row().prop(self, "edit_render_dir")
file_pattern_row = box.row(align=True)
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.
self.lookdev.draw(context, col)
@ -527,7 +527,7 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
# Shot_Builder settings.
box = col.box()
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")
if self.shot_builder_show_advanced:
start_frame_row = box.row()
@ -574,17 +574,17 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
@property
def is_edit_render_root_valid(self) -> bool:
if self.edit_export_dir.strip() == "":
if self.edit_render_dir.strip() == "":
return False
if not Path(self.edit_export_dir).exists():
if not Path(self.edit_render_dir).exists():
return False
return True
@property
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
if not "###" in self.edit_export_file_pattern:
if not "###" in self.edit_render_file_pattern:
return False
return True
@ -614,15 +614,6 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
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:
"""

View File

@ -170,12 +170,12 @@ def get_playblast_file(self: Any) -> str:
def get_edit_render_file(self: Any) -> str:
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 ""
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)
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