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
3 changed files with 25 additions and 8 deletions
Showing only changes of commit 6fe881e3a6 - Show all commits

View File

@ -11,6 +11,12 @@ import logging
logger = logging.getLogger(__name__)
def save_shot_builder_file(file_path):
file_path = pathlib.Path(file_path)
file_path.mkdir(parents=True, exist_ok=True)
bpy.ops.wm.save_mainfile(filepath=file_path, relative_remap=True)
class SaveFileStep(BuildStep):
def __str__(self) -> str:
return "save file"
@ -18,7 +24,5 @@ class SaveFileStep(BuildStep):
def execute(self, build_context: BuildContext) -> None:
shot = build_context.shot
file_path = pathlib.Path(shot.file_path)
file_path.mkdir(parents=True, exist_ok=True)
save_shot_builder_file(file_path)
logger.info(f"save file {shot.file_path}")
bpy.ops.wm.save_mainfile(filepath=shot.file_path, relative_remap=True)

View File

@ -13,7 +13,7 @@ class ANIM_SETUP_OT_load_latest_editorial(bpy.types.Operator):
def execute(self, context: bpy.types.Context) -> Set[str]:
cache_shot = cache.shot_active_get()
shot = gazu.shot.get_shot(cache_shot.id)
shot = gazu.shot.get_shot(cache_shot.id) #TODO INEFFICENT TO LOAD SHOT TWICE
strips = editorial_export_get_latest(context, shot)
if strips is None:
self.report(

View File

@ -27,6 +27,7 @@ from blender_kitsu.shot_builder.task_type import TaskType
from blender_kitsu import prefs, cache, gazu
from blender_kitsu.shot_builder.anim_setup.core import animation_workspace_delete_others, animation_workspace_vse_area_add
from blender_kitsu.shot_builder.editorial.core import editorial_export_get_latest
from blender_kitsu.shot_builder.builder.save_file import save_shot_builder_file
_production_task_type_items: List[Tuple[str, str, str]] = []
@ -111,6 +112,11 @@ class SHOTBUILDER_OT_NewShotFile(bpy.types.Operator):
description="Task to create the shot file for",
items=production_task_type_items
)
auto_save: bpy.props.BoolProperty(
name="Save after building.",
description="Automatically save build file after 'Shot Builder' is complete.",
default=True,
)
def modal(self, context, event):
@ -123,10 +129,16 @@ class SHOTBUILDER_OT_NewShotFile(bpy.types.Operator):
self._add_vse_area = True
if self._built_shot and self._add_vse_area:
if self.auto_save:
file_path = pathlib.Path(self._file_path)
file_path.mkdir(parents=True, exist_ok=True)
bpy.ops.wm.save_mainfile(filepath=self._file_path, relative_remap=True)
self.report({"INFO"}, f"Created Shot {self.shot_id}")
try:
save_shot_builder_file(file_path)
self.report({"INFO"}, f"Saved Shot{self.shot_id} at {file_path}")
return {'FINISHED'}
except FileExistsError:
self.report({"ERROR"}, f"Cannot create a file/folder when that file/folder already exists {file_path}")
return {'CANCELLED'}
self.report({"INFO"}, f"Built Shot {self.shot_id}, file is not saved!")
return {'FINISHED'}
return {'PASS_THROUGH'}
@ -230,3 +242,4 @@ class SHOTBUILDER_OT_NewShotFile(bpy.types.Operator):
layout.prop(self, "seq_id")
layout.prop(self, "shot_id")
layout.prop(self, "task_type")
layout.prop(self, "auto_save")