From 60e79682e738cf178cddc1a84dbc6ee922943c0a Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Thu, 23 May 2024 12:55:10 -0400 Subject: [PATCH 1/2] Blender Kitsu: Add Episode Support to Edit Export Directory Import/Export --- .../addons/blender_kitsu/edit/core.py | 4 +-- .../addons/blender_kitsu/edit/ops.py | 10 +++++-- .../addons/blender_kitsu/edit/opsdata.py | 4 +-- scripts-blender/addons/blender_kitsu/prefs.py | 7 +++-- .../addons/blender_kitsu/propsdata.py | 30 +++++++++++++------ 5 files changed, 38 insertions(+), 17 deletions(-) diff --git a/scripts-blender/addons/blender_kitsu/edit/core.py b/scripts-blender/addons/blender_kitsu/edit/core.py index 20a8fda0..3b5537c5 100644 --- a/scripts-blender/addons/blender_kitsu/edit/core.py +++ b/scripts-blender/addons/blender_kitsu/edit/core.py @@ -1,5 +1,5 @@ import bpy -from .. import prefs +from .. import prefs, propsdata import re from pathlib import Path @@ -18,7 +18,7 @@ def edit_export_get_all(context: bpy.types.Context): """Find all renders in editorial export directory""" addon_prefs = prefs.addon_prefs_get(context) - edit_export_path = Path(addon_prefs.edit_export_dir) + edit_export_path = propsdata.get_edit_export_dir() files_list = [ f diff --git a/scripts-blender/addons/blender_kitsu/edit/ops.py b/scripts-blender/addons/blender_kitsu/edit/ops.py index ca7634b2..61b5747b 100644 --- a/scripts-blender/addons/blender_kitsu/edit/ops.py +++ b/scripts-blender/addons/blender_kitsu/edit/ops.py @@ -3,7 +3,7 @@ from bpy.types import Sequence, Context import os from typing import Set, List from pathlib import Path -from .. import cache, prefs, util +from .. import cache, prefs, util, propsdata from ..types import Task, TaskStatus from ..playblast.core import override_render_path, override_render_format from . import opsdata @@ -149,7 +149,13 @@ class KITSU_OT_edit_export_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 != "") + if addon_prefs.edit_export_dir == "": + cls.poll_message_set("Edit Export Directory is not set, check add-on preferences") + return False + if not propsdata.get_edit_export_dir().exists(): + cls.poll_message_set("Edit Export Directory does not exist") + return False + return True def execute(self, context: bpy.types.Context) -> Set[str]: kitsu_props = context.scene.kitsu diff --git a/scripts-blender/addons/blender_kitsu/edit/opsdata.py b/scripts-blender/addons/blender_kitsu/edit/opsdata.py index 50d283ca..cc1d81b9 100644 --- a/scripts-blender/addons/blender_kitsu/edit/opsdata.py +++ b/scripts-blender/addons/blender_kitsu/edit/opsdata.py @@ -20,7 +20,7 @@ from typing import Any, List, Tuple from pathlib import Path -from .. import prefs +from .. import prefs, propsdata import bpy from ..models import FileListModel @@ -43,7 +43,7 @@ def init_edit_export_file_model( addon_prefs = prefs.addon_prefs_get(context) kitsu_props = context.scene.kitsu - edit_export_dir = Path(addon_prefs.edit_export_dir) + edit_export_dir = propsdata.get_edit_export_dir() # Is None if invalid. if addon_prefs.edit_export_dir == "" or not edit_export_dir.exists(): diff --git a/scripts-blender/addons/blender_kitsu/prefs.py b/scripts-blender/addons/blender_kitsu/prefs.py index daebafec..cdd97a9d 100644 --- a/scripts-blender/addons/blender_kitsu/prefs.py +++ b/scripts-blender/addons/blender_kitsu/prefs.py @@ -28,7 +28,7 @@ from pathlib import Path import bpy -from . import cache, bkglobals +from . import cache, bkglobals, propsdata from .props import get_safely_string_prop # TODO: restructure this to not access ops_playblast_data. @@ -608,7 +608,10 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences): def is_edit_export_root_valid(self) -> bool: if self.edit_export_dir.strip() == "": return False - if not Path(self.edit_export_dir).exists(): + edit_export_path = Path(self.edit_export_dir) + if '' in edit_export_path.parts: + edit_export_path = propsdata.get_edit_export_dir() + if not edit_export_path.exists(): return False return True diff --git a/scripts-blender/addons/blender_kitsu/propsdata.py b/scripts-blender/addons/blender_kitsu/propsdata.py index 7ff611fc..43957608 100644 --- a/scripts-blender/addons/blender_kitsu/propsdata.py +++ b/scripts-blender/addons/blender_kitsu/propsdata.py @@ -130,12 +130,7 @@ def get_playblast_dir(self: Any) -> str: else: playblast_dir = addon_prefs.shot_playblast_root_path - # Inject episode name if available (and if specified as ) - if episode and '' in playblast_dir.parts: - i = playblast_dir.parts.index('') - playblast_dir = Path(*playblast_dir.parts[:i]).joinpath( - episode.name, *playblast_dir.parts[i + 1 :] - ) + playblast_dir = set_episode_variable(playblast_dir) if context_core.is_sequence_context(): playblast_dir = playblast_dir / sequence.name / 'sequence_previews' @@ -181,14 +176,18 @@ def get_playblast_file(self: Any) -> str: return Path(self.playblast_dir).joinpath(file_name).as_posix() +def get_edit_export_dir() -> str: + addon_prefs = prefs.addon_prefs_get(bpy.context) + return set_episode_variable(Path(addon_prefs.edit_export_dir)) + + def get_edit_export_file(self: Any) -> str: addon_prefs = prefs.addon_prefs_get(bpy.context) - if not bool(addon_prefs.edit_export_dir): - return "" + export_dir = get_edit_export_dir() version = self.edit_export_version file_pattern = addon_prefs.edit_export_file_pattern file_name = file_pattern.replace('v###', version) - return Path(addon_prefs.edit_export_dir).joinpath(file_name).as_posix() + return export_dir.joinpath(file_name).as_posix() _active_category_cache_init: bool = False @@ -227,3 +226,16 @@ def reset_all_kitsu_props(self: Any, context: bpy.types.Context) -> None: cache.asset_active_reset(context) cache.episode_active_reset(context) cache.task_type_active_reset(context) + + +def set_episode_variable(base_path: Path) -> Path: + episode = cache.episode_active_get() + active_project = cache.project_active_get() + if not ( + episode + and '' in base_path.parts + and active_project.production_type == bkglobals.KITSU_TV_PROJECT + ): + return base_path + i = base_path.parts.index('') + return Path(*base_path.parts[:i]).joinpath(episode.name, *base_path.parts[i + 1 :]) -- 2.30.2 From 9cf239ef379df042f96036a348b54eab2e0a2d86 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 29 May 2024 11:26:37 -0400 Subject: [PATCH 2/2] Docs: Update File Types Documentation with Editorial Export --- docs/naming-conventions/file-types.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/naming-conventions/file-types.md b/docs/naming-conventions/file-types.md index 558d56c2..959168f4 100644 --- a/docs/naming-conventions/file-types.md +++ b/docs/naming-conventions/file-types.md @@ -38,6 +38,12 @@ Sets are more tricky to define, since they can differ even on a shot level. In p **TV Show Location:** `{project root}/pro/shots/{episode identifier}/{sequence number}/{shot identifier}/{shot identifier}-{task identifier}.blend` +## Edit Export + +**Standard Location:** `{project root}/shared/editorial/export/{edit name}-v{version}.mp4` + +**TV Show Location:** `{project root}/shared/editorial/{episode identifier}/export/{edit name}-v{version}.mp4` + ## Example: `prop-dresser_wood.faded-modeling.png` -- 2.30.2