Move Anim_Setup
module into Blender_Kitsu
#5
@ -21,6 +21,7 @@
|
||||
import hashlib
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
|
||||
from typing import Optional, Any, Set, Tuple, List
|
||||
from pathlib import Path
|
||||
@ -157,6 +158,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__
|
||||
|
||||
@ -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]:
|
||||
@ -438,6 +471,30 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
|
||||
return False
|
||||
|
||||
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:
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user