Blender Kitsu: Rename Edit Render to Edit Export #249
@ -4,32 +4,31 @@ import re
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def edit_render_get_latest(context: bpy.types.Context):
|
||||
"""Find latest render in editorial render directory"""
|
||||
def edit_export_get_latest(context: bpy.types.Context):
|
||||
"""Find latest render in editorial export directory"""
|
||||
|
||||
files_list = edit_renders_get_all(context)
|
||||
files_list = edit_export_get_all(context)
|
||||
if len(files_list) >= 1:
|
||||
files_list = sorted(files_list, reverse=True)
|
||||
return files_list[0]
|
||||
return None
|
||||
|
||||
|
||||
def edit_renders_get_all(context: bpy.types.Context):
|
||||
"""Find latest render in editorial render directory"""
|
||||
def edit_export_get_all(context: bpy.types.Context):
|
||||
"""Find all renders in editorial export directory"""
|
||||
addon_prefs = prefs.addon_prefs_get(context)
|
||||
|
||||
edit_render_path = Path(addon_prefs.edit_render_dir)
|
||||
edit_export_path = Path(addon_prefs.edit_export_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_render_file_pattern, f.name)
|
||||
for f in edit_export_path.iterdir()
|
||||
if f.is_file() and edit_export_is_valid_name(addon_prefs.edit_export_file_pattern, f.name)
|
||||
]
|
||||
return files_list
|
||||
|
||||
|
||||
def edit_render_is_valid_edit_name(file_pattern: str, filename: str) -> bool:
|
||||
def edit_export_is_valid_name(file_pattern: str, filename: str) -> bool:
|
||||
"""Verify file name matches file pattern set in preferences"""
|
||||
# Prevents un-expected matches
|
||||
file_pattern = re.escape(file_pattern)
|
||||
@ -40,13 +39,13 @@ def edit_render_is_valid_edit_name(file_pattern: str, filename: str) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def edit_render_import_latest(
|
||||
def edit_export_import_latest(
|
||||
context: bpy.types.Context, shot
|
||||
) -> list[bpy.types.Sequence]: # TODO add info to shot
|
||||
"""Loads latest render from editorial department"""
|
||||
"""Loads latest export from editorial department"""
|
||||
addon_prefs = prefs.addon_prefs_get(context)
|
||||
strip_channel = 1
|
||||
latest_file = edit_render_get_latest(context)
|
||||
latest_file = edit_export_get_latest(context)
|
||||
if not latest_file:
|
||||
return None
|
||||
# Check if Kitsu server returned empty shot
|
||||
@ -78,7 +77,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_render_frame_offset
|
||||
edit_export_offset = addon_prefs.edit_export_frame_offset
|
||||
|
||||
# Set sequence strip start kitsu data.
|
||||
for strip in new_strips:
|
||||
|
@ -8,14 +8,14 @@ from ..types import Task, TaskStatus
|
||||
from ..playblast.core import override_render_path, override_render_format
|
||||
from . import opsdata
|
||||
from ..logger import LoggerFactory
|
||||
from .core import edit_render_import_latest, edit_renders_get_all, edit_render_get_latest
|
||||
from .core import edit_export_import_latest, edit_export_get_all, edit_export_get_latest
|
||||
|
||||
logger = LoggerFactory.getLogger()
|
||||
|
||||
|
||||
class KITSU_OT_edit_render_publish(bpy.types.Operator):
|
||||
bl_idname = "kitsu.edit_render_publish"
|
||||
bl_label = "Render & Publish"
|
||||
class KITSU_OT_edit_export_publish(bpy.types.Operator):
|
||||
bl_idname = "kitsu.edit_export_publish"
|
||||
bl_label = "Export & Publish"
|
||||
bl_description = (
|
||||
"Renders current VSE Edit as .mp4"
|
||||
"Saves the set version to disk and uploads it to Kitsu with the specified "
|
||||
@ -51,18 +51,18 @@ class KITSU_OT_edit_render_publish(bpy.types.Operator):
|
||||
if kitsu_props.task_type_active_id == "":
|
||||
cls.poll_message_set("Select a task type from Kitsu Context Menu")
|
||||
return False
|
||||
if not addon_prefs.is_edit_render_root_valid:
|
||||
cls.poll_message_set("Edit Render Directory is Invalid, see Add-On preferences")
|
||||
if not addon_prefs.is_edit_export_root_valid:
|
||||
cls.poll_message_set("Edit Export Directory is Invalid, see Add-On preferences")
|
||||
return False
|
||||
if not addon_prefs.is_edit_render_pattern_valid:
|
||||
cls.poll_message_set("Edit Render File Pattern is Invalid, see Add-On preferences")
|
||||
if not addon_prefs.is_edit_export_pattern_valid:
|
||||
cls.poll_message_set("Edit Export File Pattern is Invalid, see Add-On preferences")
|
||||
return False
|
||||
return True
|
||||
|
||||
def invoke(self, context, event):
|
||||
self.thumbnail_frame = context.scene.frame_current
|
||||
|
||||
# Remove file name if set in render.filepath
|
||||
# Remove file name if set in render filepath
|
||||
dir_path = bpy.path.abspath(context.scene.render.filepath)
|
||||
if not os.path.isdir(Path(dir_path)):
|
||||
dir_path = Path(dir_path).parent
|
||||
@ -101,7 +101,7 @@ class KITSU_OT_edit_render_publish(bpy.types.Operator):
|
||||
return {"CANCELLED"}
|
||||
|
||||
# Build render_path
|
||||
render_path = Path(kitsu_props.edit_render_file)
|
||||
render_path = Path(kitsu_props.edit_export_file)
|
||||
render_path_str = render_path.as_posix()
|
||||
render_name = render_path.name
|
||||
if not render_path.parent.exists():
|
||||
@ -129,27 +129,27 @@ class KITSU_OT_edit_render_publish(bpy.types.Operator):
|
||||
if self.use_frame_start:
|
||||
edit_entity.set_frame_start(self.frame_start)
|
||||
|
||||
self.report({"INFO"}, f"Submitted new comment 'Revision {kitsu_props.edit_render_version}'")
|
||||
self.report({"INFO"}, f"Submitted new comment 'Revision {kitsu_props.edit_export_version}'")
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class KITSU_OT_edit_render_set_version(bpy.types.Operator):
|
||||
bl_idname = "kitsu.edit_render_set_version"
|
||||
class KITSU_OT_edit_export_set_version(bpy.types.Operator):
|
||||
bl_idname = "kitsu.edit_export_set_version"
|
||||
bl_label = "Version"
|
||||
bl_property = "versions"
|
||||
bl_description = (
|
||||
"Sets version of edit render. Warning triangle in ui "
|
||||
"Sets version of edit export. Warning triangle in ui "
|
||||
"indicates that version already exists on disk"
|
||||
)
|
||||
|
||||
versions: bpy.props.EnumProperty(
|
||||
items=opsdata.get_edit_render_versions_enum_list, name="Versions"
|
||||
items=opsdata.get_edit_export_versions_enum_list, name="Versions"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context: bpy.types.Context) -> bool:
|
||||
addon_prefs = prefs.addon_prefs_get(context)
|
||||
return bool(addon_prefs.edit_render_dir != "")
|
||||
return bool(addon_prefs.edit_export_dir != "")
|
||||
|
||||
def execute(self, context: bpy.types.Context) -> Set[str]:
|
||||
kitsu_props = context.scene.kitsu
|
||||
@ -158,12 +158,12 @@ class KITSU_OT_edit_render_set_version(bpy.types.Operator):
|
||||
if not version:
|
||||
return {"CANCELLED"}
|
||||
|
||||
if kitsu_props.get('edit_render_version') == version:
|
||||
if kitsu_props.get('edit_export_version') == version:
|
||||
return {"CANCELLED"}
|
||||
|
||||
# Update global scene cache version prop.
|
||||
kitsu_props.edit_render_version = version
|
||||
logger.info("Set edit render version to %s", version)
|
||||
kitsu_props.edit_export_version = version
|
||||
logger.info("Set edit export version to %s", version)
|
||||
|
||||
# Redraw ui.
|
||||
util.ui_redraw()
|
||||
@ -175,10 +175,10 @@ class KITSU_OT_edit_render_set_version(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class KITSU_OT_edit_render_increment_version(bpy.types.Operator):
|
||||
bl_idname = "kitsu.edit_render_increment_version"
|
||||
class KITSU_OT_edit_export_increment_version(bpy.types.Operator):
|
||||
bl_idname = "kitsu.edit_export_increment_version"
|
||||
bl_label = "Add Version Increment"
|
||||
bl_description = "Increment the edit_render version by one"
|
||||
bl_description = "Increment the edit export version by one"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context: bpy.types.Context) -> bool:
|
||||
@ -186,31 +186,31 @@ class KITSU_OT_edit_render_increment_version(bpy.types.Operator):
|
||||
|
||||
def execute(self, context: bpy.types.Context) -> Set[str]:
|
||||
# Incremenet version.
|
||||
version = opsdata.add_edit_render_version_increment(context)
|
||||
version = opsdata.add_edit_export_version_increment(context)
|
||||
|
||||
# Update cache_version prop.
|
||||
context.scene.kitsu.edit_render_version = version
|
||||
context.scene.kitsu.edit_export_version = version
|
||||
|
||||
# Report.
|
||||
self.report({"INFO"}, f"Add edit_render version {version}")
|
||||
self.report({"INFO"}, f"Add edit export version {version}")
|
||||
|
||||
util.ui_redraw()
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class KITSU_OT_edit_render_import_latest(bpy.types.Operator):
|
||||
bl_idname = "kitsu.edit_render_import_latest"
|
||||
bl_label = "Import Latest Edit Render"
|
||||
class KITSU_OT_edit_export_import_latest(bpy.types.Operator):
|
||||
bl_idname = "kitsu.edit_export_import_latest"
|
||||
bl_label = "Import Latest Edit Export"
|
||||
bl_description = (
|
||||
"Find and import the latest editorial render found in the Editorial Render Directory for the current shot. "
|
||||
"Will only Import if the latest render is not already imported. "
|
||||
"Will remove any previous renders currently in the file's Video Sequence Editor"
|
||||
"Find and import the latest editorial render found in the Editorial Export Directory for the current shot. "
|
||||
"Will only Import if the latest export is not already imported. "
|
||||
"Will remove any previous exports currently in the file's Video Sequence Editor"
|
||||
)
|
||||
|
||||
_existing_edit_renders = []
|
||||
_existing_edit_exports = []
|
||||
_removed_movie = 0
|
||||
_removed_audio = 0
|
||||
_latest_render_name = ""
|
||||
_latest_export_name = ""
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context: bpy.types.Context) -> bool:
|
||||
@ -223,8 +223,8 @@ class KITSU_OT_edit_render_import_latest(bpy.types.Operator):
|
||||
if cache.shot_active_get().id == "":
|
||||
cls.poll_message_set("Please set an active shot in Kitsu Context UI")
|
||||
return False
|
||||
if not prefs.addon_prefs_get(context).is_edit_render_root_valid:
|
||||
cls.poll_message_set("Edit Render Directory is Invalid, see Add-On Preferences")
|
||||
if not prefs.addon_prefs_get(context).is_edit_export_root_valid:
|
||||
cls.poll_message_set("Edit Export Directory is Invalid, see Add-On Preferences")
|
||||
return False
|
||||
return True
|
||||
|
||||
@ -244,29 +244,29 @@ class KITSU_OT_edit_render_import_latest(bpy.types.Operator):
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_existing_edit_renders(
|
||||
self, context: Context, all_edit_render_paths: List[Path]
|
||||
def get_existing_edit_exports(
|
||||
self, context: Context, all_edit_export_paths: List[Path]
|
||||
) -> List[Sequence]:
|
||||
sequences = context.scene.sequence_editor.sequences
|
||||
|
||||
# Collect Existing Edit Renders
|
||||
# Collect Existing Edit Export
|
||||
for strip in sequences:
|
||||
if self.compare_strip_to_paths(strip, all_edit_render_paths):
|
||||
self._existing_edit_renders.append(strip)
|
||||
return self._existing_edit_renders
|
||||
if self.compare_strip_to_paths(strip, all_edit_export_paths):
|
||||
self._existing_edit_exports.append(strip)
|
||||
return self._existing_edit_exports
|
||||
|
||||
def check_if_latest_edit_render_is_imported(self, context: Context) -> bool:
|
||||
# Check if latest edit render is already loaded.
|
||||
for strip in self._existing_edit_renders:
|
||||
latest_edit_render_path = edit_render_get_latest(context)
|
||||
if self.compare_strip_to_path(strip, latest_edit_render_path):
|
||||
self._latest_render_name = latest_edit_render_path.name
|
||||
def check_if_latest_edit_export_is_imported(self, context: Context) -> bool:
|
||||
# Check if latest edit export is already loaded.
|
||||
for strip in self._existing_edit_exports:
|
||||
latest_edit_export_path = edit_export_get_latest(context)
|
||||
if self.compare_strip_to_path(strip, latest_edit_export_path):
|
||||
self._latest_export_name = latest_edit_export_path.name
|
||||
return True
|
||||
|
||||
def remove_existing_edit_renders(self, context: Context) -> None:
|
||||
def remove_existing_edit_exports(self, context: Context) -> None:
|
||||
# Remove Existing Strips to make way for new Strip
|
||||
sequences = context.scene.sequence_editor.sequences
|
||||
for strip in self._existing_edit_renders:
|
||||
for strip in self._existing_edit_exports:
|
||||
if strip.type == "MOVIE":
|
||||
self._removed_movie += 1
|
||||
if strip.type == "SOUND":
|
||||
@ -275,42 +275,42 @@ class KITSU_OT_edit_render_import_latest(bpy.types.Operator):
|
||||
|
||||
def execute(self, context: bpy.types.Context) -> Set[str]:
|
||||
# Reset Values
|
||||
self._existing_edit_renders = []
|
||||
self._existing_edit_exports = []
|
||||
self._removed_movie = 0
|
||||
self._removed_audio = 0
|
||||
self._latest_render_name = ""
|
||||
self._latest_export_name = ""
|
||||
|
||||
addon_prefs = prefs.addon_prefs_get(context)
|
||||
|
||||
# Get paths to all edit renders
|
||||
all_edit_render_paths = edit_renders_get_all(context)
|
||||
if all_edit_render_paths == []:
|
||||
# Get paths to all edit exports
|
||||
all_edit_export_paths = edit_export_get_all(context)
|
||||
if all_edit_export_paths == []:
|
||||
self.report(
|
||||
{"WARNING"},
|
||||
f"No Edit Renders found in '{addon_prefs.edit_render_dir}' using pattern '{addon_prefs.edit_render_file_pattern}' See Add-On Preferences",
|
||||
f"No Edit Exports found in '{addon_prefs.edit_export_dir}' using pattern '{addon_prefs.edit_export_file_pattern}' See Add-On Preferences",
|
||||
)
|
||||
return {"CANCELLED"}
|
||||
|
||||
# Collect all existing edit renders
|
||||
self.get_existing_edit_renders(context, all_edit_render_paths)
|
||||
# Collect all existing edit exports
|
||||
self.get_existing_edit_exports(context, all_edit_export_paths)
|
||||
|
||||
# Stop latest render is already imported
|
||||
if self.check_if_latest_edit_render_is_imported(context):
|
||||
# Stop latest export is already imported
|
||||
if self.check_if_latest_edit_export_is_imported(context):
|
||||
self.report(
|
||||
{"WARNING"},
|
||||
f"Latest Editorial Render already loaded '{self._latest_render_name}'",
|
||||
f"Latest Editorial Export already loaded '{self._latest_export_name}'",
|
||||
)
|
||||
return {"CANCELLED"}
|
||||
|
||||
# Remove old edit renders
|
||||
self.remove_existing_edit_renders(context)
|
||||
# Remove old edit exports
|
||||
self.remove_existing_edit_exports(context)
|
||||
|
||||
# Import new edit render
|
||||
# Import new edit export
|
||||
shot = cache.shot_active_get()
|
||||
strips = edit_render_import_latest(context, shot)
|
||||
strips = edit_export_import_latest(context, shot)
|
||||
|
||||
if strips is None:
|
||||
self.report({"WARNING"}, f"Loaded Latest Editorial Render failed to import!")
|
||||
self.report({"WARNING"}, f"Loaded Latest Editorial Export failed to import!")
|
||||
return {"CANCELLED"}
|
||||
|
||||
# Report.
|
||||
@ -319,18 +319,18 @@ class KITSU_OT_edit_render_import_latest(bpy.types.Operator):
|
||||
f"Removed {self._removed_movie} Movie Strips and {self._removed_audio} Audio Strips"
|
||||
)
|
||||
self.report(
|
||||
{"INFO"}, f"Loaded Latest Editorial Render, '{strips[0].name}'. {removed_msg}"
|
||||
{"INFO"}, f"Loaded Latest Editorial Export, '{strips[0].name}'. {removed_msg}"
|
||||
)
|
||||
else:
|
||||
self.report({"INFO"}, f"Loaded Latest Editorial Render, '{strips[0].name}'")
|
||||
self.report({"INFO"}, f"Loaded Latest Editorial Export, '{strips[0].name}'")
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
classes = [
|
||||
KITSU_OT_edit_render_publish,
|
||||
KITSU_OT_edit_render_set_version,
|
||||
KITSU_OT_edit_render_increment_version,
|
||||
KITSU_OT_edit_render_import_latest,
|
||||
KITSU_OT_edit_export_publish,
|
||||
KITSU_OT_edit_export_set_version,
|
||||
KITSU_OT_edit_export_increment_version,
|
||||
KITSU_OT_edit_export_import_latest,
|
||||
]
|
||||
|
||||
|
||||
|
@ -26,54 +26,54 @@ import bpy
|
||||
from ..models import FileListModel
|
||||
from ..logger import LoggerFactory
|
||||
|
||||
EDIT_RENDER_FILE_MODEL = FileListModel()
|
||||
_edit_render_enum_list: List[Tuple[str, str, str]] = []
|
||||
_edit_render_file_model_init: bool = False
|
||||
EDIT_EXPORT_FILE_MODEL = FileListModel()
|
||||
_edit_export_enum_list: List[Tuple[str, str, str]] = []
|
||||
_edit_export_file_model_init: bool = False
|
||||
|
||||
logger = LoggerFactory.getLogger()
|
||||
|
||||
# TODO Compare to Playblast opsdata, maybe centralize some repeated code
|
||||
|
||||
|
||||
def init_edit_render_file_model(
|
||||
def init_edit_export_file_model(
|
||||
context: bpy.types.Context,
|
||||
) -> None:
|
||||
global EDIT_RENDER_FILE_MODEL
|
||||
global _edit_render_file_model_init
|
||||
global EDIT_EXPORT_FILE_MODEL
|
||||
global _edit_export_file_model_init
|
||||
|
||||
addon_prefs = prefs.addon_prefs_get(context)
|
||||
kitsu_props = context.scene.kitsu
|
||||
edit_render_dir = Path(addon_prefs.edit_render_dir)
|
||||
edit_export_dir = Path(addon_prefs.edit_export_dir)
|
||||
|
||||
# Is None if invalid.
|
||||
if addon_prefs.edit_render_dir == "" or not edit_render_dir.exists():
|
||||
if addon_prefs.edit_export_dir == "" or not edit_export_dir.exists():
|
||||
logger.error(
|
||||
"Failed to initialize edit render file model. Invalid path. Check addon preferences"
|
||||
"Failed to initialize edit export file model. Invalid path. Check addon preferences"
|
||||
)
|
||||
return
|
||||
|
||||
EDIT_RENDER_FILE_MODEL.reset()
|
||||
EDIT_RENDER_FILE_MODEL.root_path = edit_render_dir
|
||||
EDIT_EXPORT_FILE_MODEL.reset()
|
||||
EDIT_EXPORT_FILE_MODEL.root_path = edit_export_dir
|
||||
|
||||
if not EDIT_RENDER_FILE_MODEL.versions:
|
||||
EDIT_RENDER_FILE_MODEL.append_item("v001")
|
||||
# Update edit_render_version prop.
|
||||
kitsu_props.edit_render_Version = "v001"
|
||||
if not EDIT_EXPORT_FILE_MODEL.versions:
|
||||
EDIT_EXPORT_FILE_MODEL.append_item("v001")
|
||||
# Update edit_export_version prop.
|
||||
kitsu_props.edit_export_version = "v001"
|
||||
|
||||
else:
|
||||
# Update edit_render_version prop.
|
||||
kitsu_props.edit_render_version = EDIT_RENDER_FILE_MODEL.versions[0]
|
||||
# Update edit_export_version prop.
|
||||
kitsu_props.edit_export_version = EDIT_EXPORT_FILE_MODEL.versions[0]
|
||||
|
||||
_edit_render_file_model_init = True
|
||||
_edit_export_file_model_init = True
|
||||
|
||||
|
||||
def add_edit_render_version_increment(context: bpy.types.Context) -> str:
|
||||
def add_edit_export_version_increment(context: bpy.types.Context) -> str:
|
||||
# Init model if it did not happen.
|
||||
if not _edit_render_file_model_init:
|
||||
init_edit_render_file_model(context)
|
||||
if not _edit_export_file_model_init:
|
||||
init_edit_export_file_model(context)
|
||||
|
||||
# Should be already sorted.
|
||||
versions = EDIT_RENDER_FILE_MODEL.versions
|
||||
versions = EDIT_EXPORT_FILE_MODEL.versions
|
||||
|
||||
if len(versions) > 0:
|
||||
latest_version = versions[0]
|
||||
@ -81,32 +81,32 @@ def add_edit_render_version_increment(context: bpy.types.Context) -> str:
|
||||
else:
|
||||
increment = "v001"
|
||||
|
||||
EDIT_RENDER_FILE_MODEL.append_item(increment)
|
||||
EDIT_EXPORT_FILE_MODEL.append_item(increment)
|
||||
return increment
|
||||
|
||||
|
||||
def get_edit_render_versions_enum_list(
|
||||
def get_edit_export_versions_enum_list(
|
||||
self: Any,
|
||||
context: bpy.types.Context,
|
||||
) -> List[Tuple[str, str, str]]:
|
||||
global _edit_render_enum_list
|
||||
global EDIT_RENDER_FILE_MODEL
|
||||
global init_edit_render_file_model
|
||||
global _edit_render_file_model_init
|
||||
global _edit_export_enum_list
|
||||
global EDIT_EXPORT_FILE_MODEL
|
||||
global init_edit_export_file_model
|
||||
global _edit_export_file_model_init
|
||||
|
||||
# Init model if it did not happen.
|
||||
if not _edit_render_file_model_init:
|
||||
init_edit_render_file_model(context)
|
||||
if not _edit_export_file_model_init:
|
||||
init_edit_export_file_model(context)
|
||||
|
||||
# Clear all versions in enum list.
|
||||
_edit_render_enum_list.clear()
|
||||
_edit_render_enum_list.extend(EDIT_RENDER_FILE_MODEL.versions_as_enum_list)
|
||||
_edit_export_enum_list.clear()
|
||||
_edit_export_enum_list.extend(EDIT_EXPORT_FILE_MODEL.versions_as_enum_list)
|
||||
|
||||
return _edit_render_enum_list
|
||||
return _edit_export_enum_list
|
||||
|
||||
|
||||
def add_version_custom(custom_version: str) -> None:
|
||||
global _edit_render_enum_list
|
||||
global EDIT_RENDER_FILE_MODEL
|
||||
global _edit_export_enum_list
|
||||
global EDIT_EXPORT_FILE_MODEL
|
||||
|
||||
EDIT_RENDER_FILE_MODEL.append_item(custom_version)
|
||||
EDIT_EXPORT_FILE_MODEL.append_item(custom_version)
|
||||
|
@ -3,21 +3,21 @@ from .. import prefs, ui
|
||||
from ..context import core as context_core
|
||||
from pathlib import Path
|
||||
from .ops import (
|
||||
KITSU_OT_edit_render_set_version,
|
||||
KITSU_OT_edit_render_increment_version,
|
||||
KITSU_OT_edit_render_publish,
|
||||
KITSU_OT_edit_render_import_latest,
|
||||
KITSU_OT_edit_export_set_version,
|
||||
KITSU_OT_edit_export_increment_version,
|
||||
KITSU_OT_edit_export_publish,
|
||||
KITSU_OT_edit_export_import_latest,
|
||||
)
|
||||
from ..generic.ops import KITSU_OT_open_path
|
||||
|
||||
|
||||
class KITSU_PT_edit_render_publish(bpy.types.Panel):
|
||||
class KITSU_PT_edit_export_publish(bpy.types.Panel):
|
||||
"""
|
||||
Panel in sequence editor that exposes a set of tools that are used to render latest edit
|
||||
Panel in sequence editor that exposes a set of tools that are used to export latest edit
|
||||
"""
|
||||
|
||||
bl_category = "Kitsu"
|
||||
bl_label = "Render & Publish"
|
||||
bl_label = "Export & Publish"
|
||||
bl_space_type = "SEQUENCE_EDITOR"
|
||||
bl_region_type = "UI"
|
||||
bl_options = {"DEFAULT_CLOSED"}
|
||||
@ -33,46 +33,46 @@ class KITSU_PT_edit_render_publish(bpy.types.Panel):
|
||||
split_factor_small = 0.95
|
||||
|
||||
# # ERROR.
|
||||
if not addon_prefs.is_edit_render_root_valid:
|
||||
if not addon_prefs.is_edit_export_root_valid:
|
||||
box = ui.draw_error_box(layout)
|
||||
ui.draw_error_invalid_edit_render_root_dir(box)
|
||||
ui.draw_error_invalid_edit_export_root_dir(box)
|
||||
|
||||
# Edit Render version op.
|
||||
# Edit Export version op.
|
||||
row = layout.row(align=True)
|
||||
row.operator(
|
||||
KITSU_OT_edit_render_set_version.bl_idname,
|
||||
text=context.scene.kitsu.edit_render_version,
|
||||
KITSU_OT_edit_export_set_version.bl_idname,
|
||||
text=context.scene.kitsu.edit_export_version,
|
||||
icon="DOWNARROW_HLT",
|
||||
)
|
||||
# Edit Render increment version op.
|
||||
# Edit Export increment version op.
|
||||
row.operator(
|
||||
KITSU_OT_edit_render_increment_version.bl_idname,
|
||||
KITSU_OT_edit_export_increment_version.bl_idname,
|
||||
text="",
|
||||
icon="ADD",
|
||||
)
|
||||
|
||||
# Edit Render op.
|
||||
# Edit Export op.
|
||||
row = layout.row(align=True)
|
||||
row.operator(KITSU_OT_edit_render_publish.bl_idname, icon="RENDER_ANIMATION")
|
||||
row.operator(KITSU_OT_edit_export_publish.bl_idname, icon="RENDER_ANIMATION")
|
||||
|
||||
# Edit Render path label.
|
||||
if Path(context.scene.kitsu.edit_render_file).exists():
|
||||
# Edit Export path label.
|
||||
if Path(context.scene.kitsu.edit_export_file).exists():
|
||||
split = layout.split(factor=1 - split_factor_small, align=True)
|
||||
split.label(icon="ERROR")
|
||||
sub_split = split.split(factor=split_factor_small)
|
||||
sub_split.label(text=context.scene.kitsu.edit_render_file)
|
||||
sub_split.label(text=context.scene.kitsu.edit_export_file)
|
||||
sub_split.operator(
|
||||
KITSU_OT_open_path.bl_idname, icon="FILE_FOLDER", text=""
|
||||
).filepath = context.scene.kitsu.edit_render_file
|
||||
).filepath = context.scene.kitsu.edit_export_file
|
||||
else:
|
||||
row = layout.row(align=True)
|
||||
row.label(text=context.scene.kitsu.edit_render_file)
|
||||
row.label(text=context.scene.kitsu.edit_export_file)
|
||||
row.operator(KITSU_OT_open_path.bl_idname, icon="FILE_FOLDER", text="").filepath = (
|
||||
context.scene.kitsu.edit_render_file
|
||||
context.scene.kitsu.edit_export_file
|
||||
)
|
||||
|
||||
|
||||
class KITSU_PT_edit_render_tools(bpy.types.Panel):
|
||||
class KITSU_PT_edit_export_tools(bpy.types.Panel):
|
||||
"""
|
||||
Panel in sequence editor that exposes a set of tools that are used to load the latest edit
|
||||
"""
|
||||
@ -96,10 +96,10 @@ class KITSU_PT_edit_render_tools(bpy.types.Panel):
|
||||
def draw(self, context: bpy.types.Context) -> None:
|
||||
box = self.layout.box()
|
||||
box.label(text="General", icon="MODIFIER")
|
||||
box.operator(KITSU_OT_edit_render_import_latest.bl_idname)
|
||||
box.operator(KITSU_OT_edit_export_import_latest.bl_idname)
|
||||
|
||||
|
||||
classes = [KITSU_PT_edit_render_publish, KITSU_PT_edit_render_tools]
|
||||
classes = [KITSU_PT_edit_export_publish, KITSU_PT_edit_export_tools]
|
||||
|
||||
|
||||
def register():
|
||||
|
@ -41,7 +41,7 @@ from .auth.ops import (
|
||||
)
|
||||
from .context.ops import KITSU_OT_con_productions_load
|
||||
from .lookdev.prefs import LOOKDEV_preferences
|
||||
from .edit.core import edit_render_get_latest
|
||||
from .edit.core import edit_export_get_latest
|
||||
|
||||
|
||||
logger = LoggerFactory.getLogger()
|
||||
@ -358,60 +358,60 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
|
||||
subtype='DIR_PATH',
|
||||
)
|
||||
|
||||
def set_edit_render_dir(self, input):
|
||||
self['edit_render_dir'] = input
|
||||
def set_edit_export_dir(self, input):
|
||||
self['edit_export_dir'] = input
|
||||
return
|
||||
|
||||
def get_edit_render_dir(
|
||||
def get_edit_export_dir(
|
||||
self,
|
||||
) -> str:
|
||||
if get_safely_string_prop(self, 'edit_render_dir') == "" and self.project_root_path:
|
||||
if get_safely_string_prop(self, 'edit_export_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_render_dir')
|
||||
return get_safely_string_prop(self, 'edit_export_dir')
|
||||
|
||||
edit_render_dir: bpy.props.StringProperty( # type: ignore
|
||||
name="Render Directory",
|
||||
edit_export_dir: bpy.props.StringProperty( # type: ignore
|
||||
name="Edit Export Directory",
|
||||
options={"HIDDEN", "SKIP_SAVE"},
|
||||
description="Directory path to editorial's render folder containing storyboard/animatic renders. Path should be similar to '~/shared-{proj_name}/editorial/export/'",
|
||||
description="Directory path to editorial's export folder containing storyboard/animatic renders. Path should be similar to '~/shared-{proj_name}/editorial/export/'",
|
||||
subtype="DIR_PATH",
|
||||
get=get_edit_render_dir,
|
||||
set=set_edit_render_dir,
|
||||
get=get_edit_export_dir,
|
||||
set=set_edit_export_dir,
|
||||
)
|
||||
|
||||
def set_edit_render_file_pattern(self, input):
|
||||
self['edit_render_file_pattern'] = input
|
||||
def set_edit_export_file_pattern(self, input):
|
||||
self['edit_export_file_pattern'] = input
|
||||
return
|
||||
|
||||
def get_edit_render_file_pattern(
|
||||
def get_edit_export_file_pattern(
|
||||
self,
|
||||
) -> str:
|
||||
active_project = cache.project_active_get()
|
||||
if get_safely_string_prop(self, 'edit_render_file_pattern') == "" and active_project:
|
||||
if get_safely_string_prop(self, 'edit_export_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_render_file_pattern')
|
||||
return get_safely_string_prop(self, 'edit_export_file_pattern')
|
||||
|
||||
edit_render_file_pattern: bpy.props.StringProperty( # type: ignore
|
||||
name="Render File Pattern",
|
||||
edit_export_file_pattern: bpy.props.StringProperty( # type: ignore
|
||||
name="Edit Export File Pattern",
|
||||
options={"HIDDEN", "SKIP_SAVE"},
|
||||
description=(
|
||||
"File pattern for latest editorial render file. "
|
||||
"File pattern for latest editorial export 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_render_file_pattern,
|
||||
set=set_edit_render_file_pattern,
|
||||
get=get_edit_export_file_pattern,
|
||||
set=set_edit_export_file_pattern,
|
||||
)
|
||||
|
||||
edit_render_frame_offset: bpy.props.IntProperty( # type: ignore
|
||||
name="Render Offset",
|
||||
description="Shift Editorial Render by this frame-range after import",
|
||||
edit_export_frame_offset: bpy.props.IntProperty( # type: ignore
|
||||
name="Edit Export Offset",
|
||||
description="Shift Editorial Export by this frame-range after import",
|
||||
default=-101, # HARD CODED FOR GOLD PROJECTS BLENDER FILM
|
||||
)
|
||||
|
||||
@ -491,10 +491,10 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
|
||||
# Editorial Settings
|
||||
box = col.box()
|
||||
box.label(text="Editorial", icon="SEQ_SEQUENCER")
|
||||
box.row().prop(self, "edit_render_dir")
|
||||
box.row().prop(self, "edit_export_dir", text="Export Directory")
|
||||
file_pattern_row = box.row(align=True)
|
||||
file_pattern_row.alert = not self.is_edit_render_pattern_valid
|
||||
file_pattern_row.prop(self, "edit_render_file_pattern")
|
||||
file_pattern_row.alert = not self.is_edit_export_pattern_valid
|
||||
file_pattern_row.prop(self, "edit_export_file_pattern", text="Export 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_render_frame_offset")
|
||||
box.row().prop(self, "edit_export_frame_offset")
|
||||
box.row().prop(self, "shot_builder_show_advanced")
|
||||
if self.shot_builder_show_advanced:
|
||||
start_frame_row = box.row()
|
||||
@ -573,18 +573,18 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
|
||||
return True
|
||||
|
||||
@property
|
||||
def is_edit_render_root_valid(self) -> bool:
|
||||
if self.edit_render_dir.strip() == "":
|
||||
def is_edit_export_root_valid(self) -> bool:
|
||||
if self.edit_export_dir.strip() == "":
|
||||
return False
|
||||
if not Path(self.edit_render_dir).exists():
|
||||
if not Path(self.edit_export_dir).exists():
|
||||
return False
|
||||
return True
|
||||
|
||||
@property
|
||||
def is_edit_render_pattern_valid(self) -> bool:
|
||||
if not self.edit_render_file_pattern.endswith(".mp4"):
|
||||
def is_edit_export_pattern_valid(self) -> bool:
|
||||
if not self.edit_export_file_pattern.endswith(".mp4"):
|
||||
return False
|
||||
if not "###" in self.edit_render_file_pattern:
|
||||
if not "###" in self.edit_export_file_pattern:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -498,14 +498,14 @@ class KITSU_property_group_scene(bpy.types.PropertyGroup):
|
||||
search_options={'SORT'},
|
||||
)
|
||||
|
||||
edit_render_version: bpy.props.StringProperty(name="Version", default="v001")
|
||||
edit_export_version: bpy.props.StringProperty(name="Version", default="v001")
|
||||
|
||||
edit_render_file: bpy.props.StringProperty( # type: ignore
|
||||
name="Edit Render Filepath",
|
||||
description="Output filepath of Edit Render",
|
||||
edit_export_file: bpy.props.StringProperty( # type: ignore
|
||||
name="Edit Export Filepath",
|
||||
description="Output filepath of Edit Export",
|
||||
default="",
|
||||
subtype="FILE_PATH",
|
||||
get=propsdata.get_edit_render_file,
|
||||
get=propsdata.get_edit_export_file,
|
||||
)
|
||||
|
||||
# Thumbnail props.
|
||||
|
@ -168,14 +168,14 @@ def get_playblast_file(self: Any) -> str:
|
||||
return Path(self.playblast_dir).joinpath(file_name).as_posix()
|
||||
|
||||
|
||||
def get_edit_render_file(self: Any) -> str:
|
||||
def get_edit_export_file(self: Any) -> str:
|
||||
addon_prefs = prefs.addon_prefs_get(bpy.context)
|
||||
if not bool(addon_prefs.edit_render_dir):
|
||||
if not bool(addon_prefs.edit_export_dir):
|
||||
return ""
|
||||
version = self.edit_render_version
|
||||
file_pattern = addon_prefs.edit_render_file_pattern
|
||||
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_render_dir).joinpath(file_name).as_posix()
|
||||
return Path(addon_prefs.edit_export_dir).joinpath(file_name).as_posix()
|
||||
|
||||
|
||||
_active_category_cache_init: bool = False
|
||||
|
@ -16,7 +16,7 @@ from .core import (
|
||||
)
|
||||
from ..context import core as context_core
|
||||
|
||||
from ..edit.core import edit_render_import_latest
|
||||
from ..edit.core import edit_export_import_latest
|
||||
from .file_save import save_shot_builder_file
|
||||
from .template import replace_workspace_with_template
|
||||
from .assets import get_shot_assets
|
||||
@ -236,7 +236,7 @@ class KITSU_OT_build_new_shot(bpy.types.Operator):
|
||||
link_task_type_output_collections(shot, task_type)
|
||||
|
||||
if bkglobals.LOAD_EDITORIAL_REF.get(task_type_short_name):
|
||||
edit_render_import_latest(context, shot)
|
||||
edit_export_import_latest(context, shot)
|
||||
|
||||
# Run Hooks
|
||||
hooks_instance = Hooks()
|
||||
|
@ -47,11 +47,11 @@ def draw_error_invalid_playblast_root_dir(
|
||||
).module = __package__
|
||||
|
||||
|
||||
def draw_error_invalid_edit_render_root_dir(
|
||||
def draw_error_invalid_edit_export_root_dir(
|
||||
box: bpy.types.UILayout,
|
||||
) -> bpy.types.UILayout:
|
||||
row = box.row(align=True)
|
||||
row.label(text="Invalid Edit Render Directory")
|
||||
row.label(text="Invalid Edit Export Directory")
|
||||
row.operator("preferences.addon_show", text="Open Addon Preferences").module = __package__
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user