Blender Kitsu: Refactor Shot Builder #183

Merged
Nick Alberelli merged 55 commits from TinyNick/blender-studio-pipeline:feature/shot-builder-2 into main 2023-12-21 23:58:21 +01:00
2 changed files with 18 additions and 2 deletions
Showing only changes of commit 447cdb4859 - Show all commits

View File

@ -0,0 +1,12 @@
from pathlib import Path
import bpy
def save_shot_builder_file(file_path: str):
"""Save Shot File within Folder of matching name.
Set Shot File to relative Paths."""
if Path(file_path).exists():
raise Exception(f"Cannot Overwrite Existing Shot File {file_path}")
dir_path = Path(file_path).parent
dir_path.mkdir(parents=True, exist_ok=True)
bpy.ops.wm.save_mainfile(filepath=file_path, relative_remap=True)

View File

@ -14,6 +14,7 @@ from .core import (
) )
from .editorial import editorial_export_get_latest from .editorial import editorial_export_get_latest
from .file_save import save_shot_builder_file
active_project = None active_project = None
@ -75,7 +76,7 @@ class KITSU_OT_build_new_shot(bpy.types.Operator):
items=get_tasks_for_shot, items=get_tasks_for_shot,
) )
auto_save: bpy.props.BoolProperty( save_file: bpy.props.BoolProperty(
name="Save after building.", name="Save after building.",
description="Automatically save build file after 'Shot Builder' is complete.", description="Automatically save build file after 'Shot Builder' is complete.",
default=True, default=True,
@ -89,7 +90,7 @@ class KITSU_OT_build_new_shot(bpy.types.Operator):
layout.prop(self, "seq_id") layout.prop(self, "seq_id")
layout.prop(self, "shot_id") layout.prop(self, "shot_id")
layout.prop(self, "task_type") layout.prop(self, "task_type")
layout.prop(self, "auto_save") layout.prop(self, "save_file")
def invoke(self, context: bpy.types.Context, event: bpy.types.Event) -> Set[str]: def invoke(self, context: bpy.types.Context, event: bpy.types.Event) -> Set[str]:
global active_project global active_project
@ -167,6 +168,9 @@ class KITSU_OT_build_new_shot(bpy.types.Operator):
if bkglobals.LOAD_EDITORIAL_REF.get(task_short_name): if bkglobals.LOAD_EDITORIAL_REF.get(task_short_name):
editorial_export_get_latest(context, shot) editorial_export_get_latest(context, shot)
# Save File
if self.save_file:
save_shot_builder_file(file_path=shot_file_path_str)
print("Create shot with the following details") # TODO Remove print("Create shot with the following details") # TODO Remove
print(f"Seq Name: '{seq.name}' Seq ID: '{self.seq_id}'") print(f"Seq Name: '{seq.name}' Seq ID: '{self.seq_id}'")
print(f"Shot Name: '{shot.name}' Shot ID: '{self.shot_id}'") print(f"Shot Name: '{shot.name}' Shot ID: '{self.shot_id}'")