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_idname = "shotbuilder.new_shot_file"
|
||||||
bl_label = "New Production Shot File"
|
bl_label = "New Production Shot File"
|
||||||
|
|
||||||
|
_timer = None
|
||||||
|
_built_shot = False
|
||||||
|
_add_vse_area = False
|
||||||
|
|
||||||
production_root: bpy.props.StringProperty( # type: ignore
|
production_root: bpy.props.StringProperty( # type: ignore
|
||||||
name="Production Root",
|
name="Production Root",
|
||||||
description="Root of the production",
|
description="Root of the production",
|
||||||
@ -104,6 +108,16 @@ class SHOTBUILDER_OT_NewShotFile(bpy.types.Operator):
|
|||||||
items=production_task_type_items
|
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]:
|
def invoke(self, context: bpy.types.Context, event: bpy.types.Event) -> Set[str]:
|
||||||
addon_prefs = prefs.addon_prefs_get(bpy.context)
|
addon_prefs = prefs.addon_prefs_get(bpy.context)
|
||||||
project = cache.project_active_get()
|
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))
|
return cast(Set[str], context.window_manager.invoke_props_dialog(self, width=400))
|
||||||
|
|
||||||
def execute(self, context: bpy.types.Context) -> Set[str]:
|
def execute(self, context: bpy.types.Context) -> Set[str]:
|
||||||
if not self.production_root:
|
wm = context.window_manager
|
||||||
self.report(
|
self._timer = wm.event_timer_add(0.1, window=context.window)
|
||||||
{'ERROR'}, "Shot builder can only be started from the File menu. Shortcuts like CTRL-N don't work")
|
wm.modal_handler_add(self)
|
||||||
return {'CANCELLED'}
|
if not self._built_shot:
|
||||||
addon_prefs = bpy.context.preferences.addons["blender_kitsu"].preferences
|
if not self.production_root:
|
||||||
ensure_loaded_production(context)
|
self.report(
|
||||||
production = get_active_production()
|
{'ERROR'}, "Shot builder can only be started from the File menu. Shortcuts like CTRL-N don't work")
|
||||||
shot_builder = ShotBuilder(
|
return {'CANCELLED'}
|
||||||
context=context, production=production, shot_name=self.shot_id, task_type=TaskType(self.task_type))
|
addon_prefs = bpy.context.preferences.addons["blender_kitsu"].preferences
|
||||||
shot_builder.create_build_steps()
|
ensure_loaded_production(context)
|
||||||
shot_builder.build()
|
production = get_active_production()
|
||||||
#Load EDIT
|
shot_builder = ShotBuilder(
|
||||||
bpy.ops.kitsu.con_detect_context() #TODO CONFIRM AND CHECK IF OVERRIDE IS NEEDED
|
context=context, production=production, shot_name=self.shot_id, task_type=TaskType(self.task_type))
|
||||||
editorial_export_get_latest(self, context)
|
shot_builder.create_build_steps()
|
||||||
# Load Anim Workspace
|
shot_builder.build()
|
||||||
animation_workspace_delete_others(self, context)
|
#Load EDIT
|
||||||
shot = cache.shot_active_get()
|
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
|
# Initilize armatures
|
||||||
for obj in [obj for obj in bpy.data.objects if obj.type == "ARMATURE"]:
|
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]
|
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 = bpy.data.actions.new(f"{addon_prefs.shot_builder_action_prefix}{base_name}.{shot.name}.v001")
|
||||||
new_action.use_fake_user = True
|
new_action.use_fake_user = True
|
||||||
obj.animation_data.action = new_action
|
obj.animation_data.action = new_action
|
||||||
|
|
||||||
# Set Shot Frame Range
|
# Set Shot Frame Range
|
||||||
context.scene.frame_start = addon_prefs.shot_builder_frame_offset
|
context.scene.frame_start = addon_prefs.shot_builder_frame_offset
|
||||||
context.scene.frame_end = shot.nb_frames + addon_prefs.shot_builder_frame_offset
|
context.scene.frame_end = shot.nb_frames + addon_prefs.shot_builder_frame_offset
|
||||||
|
self._built_shot = True
|
||||||
# Show Storyboard/Animatic from VSE
|
return {'RUNNING_MODAL'}
|
||||||
#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
|
if self._built_shot and self._add_vse_area:
|
||||||
|
return {'FINISHED'}
|
||||||
return {'FINISHED'}
|
|
||||||
|
|
||||||
def draw(self, context: bpy.types.Context) -> None:
|
def draw(self, context: bpy.types.Context) -> None:
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
Loading…
Reference in New Issue
Block a user