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 23 additions and 6 deletions
Showing only changes of commit 8bc00a44b2 - Show all commits

View File

@ -6,6 +6,20 @@ from blender_kitsu import prefs
from blender_kitsu import cache from blender_kitsu import cache
def animation_workspace_vse_area_add(self, context:bpy.types.Context):
"""Split smallest 3D View in current workspace"""
for workspace in [workspace for workspace in bpy.data.workspaces if workspace.name == "Animation"]:
context.window.workspace = workspace
context.view_layer.update()
areas = workspace.screens[0].areas
view_3d_areas = sorted([area for area in areas if area.ui_type =="VIEW_3D"], key=lambda x: x.width, reverse=False)
small_view_3d = view_3d_areas[0]
with context.temp_override(window=context.window, area=small_view_3d):
bpy.ops.screen.area_split(direction='HORIZONTAL', factor=0.5)
small_view_3d.ui_type = "SEQUENCE_EDITOR"
small_view_3d.spaces[0].view_type = "PREVIEW"
print(f"splitting viewpoert in workspace {context.workspace.name}") #USING THIS TO DEBUG
def animation_workspace_delete_others(self, context:bpy.types.Context): def animation_workspace_delete_others(self, context:bpy.types.Context):
"""Delete any workspace that is not an animation workspace""" """Delete any workspace that is not an animation workspace"""
for ws in bpy.data.workspaces: for ws in bpy.data.workspaces:

View File

@ -1,6 +1,6 @@
import bpy import bpy
from typing import Set from typing import Set
from blender_kitsu.shot_builder.anim_setup.core import editorial_export_get_latest, animation_workspace_delete_others, split_viewport from blender_kitsu.shot_builder.anim_setup.core import editorial_export_get_latest, animation_workspace_delete_others, animation_workspace_vse_area_add
class ANIM_SETUP_OT_setup_workspaces(bpy.types.Operator): class ANIM_SETUP_OT_setup_workspaces(bpy.types.Operator):
@ -12,13 +12,13 @@ class ANIM_SETUP_OT_setup_workspaces(bpy.types.Operator):
animation_workspace_delete_others(self, context) animation_workspace_delete_others(self, context)
return {"FINISHED"} return {"FINISHED"}
class ANIM_SETUP_OT_split_viewport(bpy.types.Operator): class ANIM_SETUP_OT_animation_workspace_vse_area_add(bpy.types.Operator):
bl_idname = "anim_setup.split_viewport" bl_idname = "anim_setup.animation_workspace_vse_area_add"
bl_label = "Split Viewport" bl_label = "Split Viewport"
bl_description = "Split smallest 3D View in current workspace" bl_description = "Split smallest 3D View in current workspace"
def execute(self, context: bpy.types.Context) -> Set[str]: def execute(self, context: bpy.types.Context) -> Set[str]:
split_viewport(self, context) animation_workspace_vse_area_add(self, context)
return {"FINISHED"} return {"FINISHED"}
class ANIM_SETUP_OT_load_latest_edit(bpy.types.Operator): class ANIM_SETUP_OT_load_latest_edit(bpy.types.Operator):
@ -36,7 +36,7 @@ class ANIM_SETUP_OT_load_latest_edit(bpy.types.Operator):
classes = [ classes = [
ANIM_SETUP_OT_setup_workspaces, ANIM_SETUP_OT_setup_workspaces,
ANIM_SETUP_OT_load_latest_edit, ANIM_SETUP_OT_load_latest_edit,
ANIM_SETUP_OT_split_viewport ANIM_SETUP_OT_animation_workspace_vse_area_add
] ]

View File

@ -24,7 +24,7 @@ from blender_kitsu.shot_builder.project import ensure_loaded_production, get_act
from blender_kitsu.shot_builder.builder import ShotBuilder from blender_kitsu.shot_builder.builder import ShotBuilder
from blender_kitsu.shot_builder.task_type import TaskType from blender_kitsu.shot_builder.task_type import TaskType
from blender_kitsu import prefs, cache from blender_kitsu import prefs, cache
from blender_kitsu.shot_builder.anim_setup.core import editorial_export_get_latest, animation_workspace_delete_others from blender_kitsu.shot_builder.anim_setup.core import editorial_export_get_latest, animation_workspace_delete_others, animation_workspace_vse_area_add
_production_task_type_items: List[Tuple[str, str, str]] = [] _production_task_type_items: List[Tuple[str, str, str]] = []
@ -181,6 +181,9 @@ class SHOTBUILDER_OT_NewShotFile(bpy.types.Operator):
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
# 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'} return {'FINISHED'}
def draw(self, context: bpy.types.Context) -> None: def draw(self, context: bpy.types.Context) -> None: