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 65 additions and 1 deletions
Showing only changes of commit b46156f636 - Show all commits

View File

@ -21,6 +21,7 @@
import hashlib
import sys
import os
import re
from typing import Optional, Any, Set, Tuple, List
from pathlib import Path
@ -158,6 +159,28 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
def init_playblast_file_model(self, context: bpy.types.Context) -> None:
ops_playblast_data.init_playblast_file_model(context)
def init_editoral_export_directory(self, context:bpy.types.Context) -> None:
edit_export_path = Path(self.edit_export_dir)
files_list = [
f
for f in edit_export_path.iterdir()
if f.is_file()
]
files_list = sorted(files_list, reverse=True)
valid_file = False
for item in files_list:
match = re.search(self.edit_export_file_pattern, item._str)
if match:
valid_file = True
if not valid_file:
self.edit_export_file_pattern = ""
logger.error(
"Failed to initialize editorial export file model. Invalid path/pattern. Check addon preferences"
)
logger.info("Initialized editorial export file model, successfully.")
bl_idname = __package__
host: bpy.props.StringProperty( # type: ignore
@ -297,9 +320,18 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
edit_export_dir: bpy.props.StringProperty( # type: ignore
name="Editorial Export Directory",
options={"HIDDEN", "SKIP_SAVE"},
description="Directory path to editorial's export folder containing storyboard/animatic exports. Path should be similar to '~/shared-pets/editorial/export/'",
description="Directory path to editorial's export folder containing storyboard/animatic exports. Path should be similar to '~/shared-{proj_name}/editorial/export/'",
subtype="DIR_PATH",
)
edit_export_file_pattern: bpy.props.StringProperty( # type: ignore
name="Editorial Export File Pattern",
options={"HIDDEN", "SKIP_SAVE"},
description="File pattern to search for latest editorial export. Typically '{proj_name}_v\d\d\d.mp4'",
default="petprojects_v\d\d\d.mp4",
update=init_editoral_export_directory,
)
session: Session = Session()
tasks: bpy.props.CollectionProperty(type=KITSU_task)
@ -396,6 +428,7 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
box = layout.box()
box.label(text="Shot Builder", icon="MOD_BUILD")
box.row().prop(self, "edit_export_dir")
box.row().prop(self, "edit_export_file_pattern")
@property
def playblast_root_path(self) -> Optional[Path]:
@ -439,6 +472,30 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
return True
@property
def is_editorial_dir_valid(self) -> bool:
edit_export_path = Path(self.edit_export_dir)
files_list = [
f
for f in edit_export_path.iterdir()
if f.is_file()
]
files_list = sorted(files_list, reverse=True)
valid_file = False
for item in files_list:
match = re.search(self.edit_export_file_pattern, item._str)
if match:
valid_file = True
if not valid_file:
logger.error(
"Failed to initialize editorial export file model. Invalid path/pattern. Check addon preferences"
)
return False
logger.info("Initialized editorial export file model, successfully.")
return True
def session_get(context: bpy.types.Context) -> Session:
"""

View File

@ -150,6 +150,13 @@ class SHOTBUILDER_OT_NewShotFile(bpy.types.Operator):
self.report(
{'ERROR'}, "Shot builder can only be started from the File menu. Shortcuts like CTRL-N don't work")
return {'CANCELLED'}
addon_prefs = bpy.context.preferences.addons["blender_kitsu"].preferences
if not addon_prefs.is_editorial_dir_valid:
self.report(
{'ERROR'}, "Shot builder is dependant on a valid editorial export path and file pattern. Check Preferences, errors appear in console")
return {'CANCELLED'}
ensure_loaded_production(context)
production = get_active_production()