Move Anim_Setup
module into Blender_Kitsu
#5
@ -11,6 +11,12 @@ import logging
|
|||||||
logger = logging.getLogger(__name__)
|
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):
|
class SaveFileStep(BuildStep):
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return "save file"
|
return "save file"
|
||||||
@ -18,7 +24,5 @@ class SaveFileStep(BuildStep):
|
|||||||
def execute(self, build_context: BuildContext) -> None:
|
def execute(self, build_context: BuildContext) -> None:
|
||||||
shot = build_context.shot
|
shot = build_context.shot
|
||||||
file_path = pathlib.Path(shot.file_path)
|
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}")
|
logger.info(f"save file {shot.file_path}")
|
||||||
bpy.ops.wm.save_mainfile(filepath=shot.file_path, relative_remap=True)
|
|
||||||
|
@ -13,7 +13,7 @@ class ANIM_SETUP_OT_load_latest_editorial(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context: bpy.types.Context) -> Set[str]:
|
def execute(self, context: bpy.types.Context) -> Set[str]:
|
||||||
cache_shot = cache.shot_active_get()
|
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)
|
strips = editorial_export_get_latest(context, shot)
|
||||||
if strips is None:
|
if strips is None:
|
||||||
self.report(
|
self.report(
|
||||||
|
@ -27,6 +27,7 @@ from blender_kitsu.shot_builder.task_type import TaskType
|
|||||||
from blender_kitsu import prefs, cache, gazu
|
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.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.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]] = []
|
_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",
|
description="Task to create the shot file for",
|
||||||
items=production_task_type_items
|
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):
|
def modal(self, context, event):
|
||||||
|
|
||||||
@ -123,10 +129,16 @@ class SHOTBUILDER_OT_NewShotFile(bpy.types.Operator):
|
|||||||
self._add_vse_area = True
|
self._add_vse_area = True
|
||||||
|
|
||||||
if self._built_shot and self._add_vse_area:
|
if self._built_shot and self._add_vse_area:
|
||||||
file_path = pathlib.Path(self._file_path)
|
if self.auto_save:
|
||||||
file_path.mkdir(parents=True, exist_ok=True)
|
file_path = pathlib.Path(self._file_path)
|
||||||
bpy.ops.wm.save_mainfile(filepath=self._file_path, relative_remap=True)
|
try:
|
||||||
self.report({"INFO"}, f"Created Shot {self.shot_id}")
|
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 {'FINISHED'}
|
||||||
|
|
||||||
return {'PASS_THROUGH'}
|
return {'PASS_THROUGH'}
|
||||||
@ -230,3 +242,4 @@ class SHOTBUILDER_OT_NewShotFile(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")
|
||||||
|
Loading…
Reference in New Issue
Block a user