Move Anim_Setup
module into Blender_Kitsu
#5
@ -74,6 +74,10 @@ class SHOTBUILDER_OT_NewShotFile(bpy.types.Operator):
|
||||
bl_idname = "shotbuilder.new_shot_file"
|
||||
bl_label = "New Production Shot File"
|
||||
|
||||
_timer = None
|
||||
_built_shot = False
|
||||
_add_vse_area = False
|
||||
|
||||
production_root: bpy.props.StringProperty( # type: ignore
|
||||
name="Production Root",
|
||||
description="Root of the production",
|
||||
@ -104,6 +108,16 @@ class SHOTBUILDER_OT_NewShotFile(bpy.types.Operator):
|
||||
items=production_task_type_items
|
||||
)
|
||||
|
||||
def modal(self, context, event):
|
||||
if event.type == 'TIMER' and not self._add_vse_area:
|
||||
# Show Storyboard/Animatic from VSE
|
||||
"""Running as Modal Event because functions within execute() function like
|
||||
animation_workspace_delete_others() changed UI context that needs to be refreshed.
|
||||
https://docs.blender.org/api/current/info_gotcha.html#no-updates-after-changing-ui-context"""
|
||||
animation_workspace_vse_area_add(self, context)
|
||||
self._add_vse_area = True
|
||||
return {'PASS_THROUGH'}
|
||||
|
||||
def invoke(self, context: bpy.types.Context, event: bpy.types.Event) -> Set[str]:
|
||||
addon_prefs = prefs.addon_prefs_get(bpy.context)
|
||||
project = cache.project_active_get()
|
||||
@ -152,39 +166,42 @@ class SHOTBUILDER_OT_NewShotFile(bpy.types.Operator):
|
||||
return cast(Set[str], context.window_manager.invoke_props_dialog(self, width=400))
|
||||
|
||||
def execute(self, context: bpy.types.Context) -> Set[str]:
|
||||
if not self.production_root:
|
||||
self.report(
|
||||
{'ERROR'}, "Shot builder can only be started from the File menu. Shortcuts like CTRL-N don't work")
|
||||
return {'CANCELLED'}
|
||||
addon_prefs = bpy.context.preferences.addons["blender_kitsu"].preferences
|
||||
ensure_loaded_production(context)
|
||||
production = get_active_production()
|
||||
shot_builder = ShotBuilder(
|
||||
context=context, production=production, shot_name=self.shot_id, task_type=TaskType(self.task_type))
|
||||
shot_builder.create_build_steps()
|
||||
shot_builder.build()
|
||||
#Load EDIT
|
||||
bpy.ops.kitsu.con_detect_context() #TODO CONFIRM AND CHECK IF OVERRIDE IS NEEDED
|
||||
editorial_export_get_latest(self, context)
|
||||
# Load Anim Workspace
|
||||
animation_workspace_delete_others(self, context)
|
||||
shot = cache.shot_active_get()
|
||||
wm = context.window_manager
|
||||
self._timer = wm.event_timer_add(0.1, window=context.window)
|
||||
wm.modal_handler_add(self)
|
||||
if not self._built_shot:
|
||||
if not self.production_root:
|
||||
self.report(
|
||||
{'ERROR'}, "Shot builder can only be started from the File menu. Shortcuts like CTRL-N don't work")
|
||||
return {'CANCELLED'}
|
||||
addon_prefs = bpy.context.preferences.addons["blender_kitsu"].preferences
|
||||
ensure_loaded_production(context)
|
||||
production = get_active_production()
|
||||
shot_builder = ShotBuilder(
|
||||
context=context, production=production, shot_name=self.shot_id, task_type=TaskType(self.task_type))
|
||||
shot_builder.create_build_steps()
|
||||
shot_builder.build()
|
||||
#Load EDIT
|
||||
bpy.ops.kitsu.con_detect_context() #TODO CONFIRM AND CHECK IF OVERRIDE IS NEEDED
|
||||
editorial_export_get_latest(self, context)
|
||||
# Load Anim Workspace
|
||||
animation_workspace_delete_others(self, context)
|
||||
shot = cache.shot_active_get()
|
||||
|
||||
# Initilize armatures
|
||||
for obj in [obj for obj in bpy.data.objects if obj.type == "ARMATURE"]:
|
||||
base_name = obj.name.split(addon_prefs.shot_builder_armature_prefix)[-1]
|
||||
new_action = bpy.data.actions.new(f"{addon_prefs.shot_builder_action_prefix}{base_name}.{shot.name}.v001")
|
||||
new_action.use_fake_user = True
|
||||
obj.animation_data.action = new_action
|
||||
|
||||
# Set Shot Frame Range
|
||||
context.scene.frame_start = addon_prefs.shot_builder_frame_offset
|
||||
context.scene.frame_end = shot.nb_frames + addon_prefs.shot_builder_frame_offset
|
||||
|
||||
# Show Storyboard/Animatic from VSE
|
||||
#animation_workspace_vse_area_add(self, context) # TODO FIX BECAUSE THIS DOESN"T RUN https://docs.blender.org/api/current/info_gotcha.html#no-updates-after-changing-ui-context
|
||||
|
||||
return {'FINISHED'}
|
||||
# Initilize armatures
|
||||
for obj in [obj for obj in bpy.data.objects if obj.type == "ARMATURE"]:
|
||||
base_name = obj.name.split(addon_prefs.shot_builder_armature_prefix)[-1]
|
||||
new_action = bpy.data.actions.new(f"{addon_prefs.shot_builder_action_prefix}{base_name}.{shot.name}.v001")
|
||||
new_action.use_fake_user = True
|
||||
obj.animation_data.action = new_action
|
||||
|
||||
# Set Shot Frame Range
|
||||
context.scene.frame_start = addon_prefs.shot_builder_frame_offset
|
||||
context.scene.frame_end = shot.nb_frames + addon_prefs.shot_builder_frame_offset
|
||||
self._built_shot = True
|
||||
return {'RUNNING_MODAL'}
|
||||
if self._built_shot and self._add_vse_area:
|
||||
return {'FINISHED'}
|
||||
|
||||
def draw(self, context: bpy.types.Context) -> None:
|
||||
layout = self.layout
|
||||
|
Loading…
Reference in New Issue
Block a user