Blender Kitsu: Add Operator to Import Playblasts into Edit #274
@ -2210,6 +2210,15 @@ def get_used_channels(self: Any, context: bpy.types.Context, edit_text: str = ""
|
||||
return [f"{channel}" for channel in aval_channels]
|
||||
|
||||
|
||||
def get_shot_task_types_enum_list(self, context: bpy.types.Context) -> List[Tuple[str, str, str]]:
|
||||
active_project = cache.project_active_get()
|
||||
return [
|
||||
(t.id, t.name, "")
|
||||
for t in TaskType.all_shot_task_types()
|
||||
if t.id in active_project.task_types
|
||||
]
|
||||
|
||||
|
||||
class KITSU_OT_shot_import_playblast(bpy.types.Operator):
|
||||
bl_idname = "kitsu.import_playblast"
|
||||
bl_label = "Import Playblast"
|
||||
@ -2223,6 +2232,12 @@ class KITSU_OT_shot_import_playblast(bpy.types.Operator):
|
||||
search_options={'SORT'},
|
||||
)
|
||||
|
||||
task_type: bpy.props.EnumProperty( # type: ignore
|
||||
name="Task Type",
|
||||
description="Choose a task type to import playblasts for",
|
||||
items=get_shot_task_types_enum_list,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context: bpy.types.Context) -> bool:
|
||||
sqe = context.scene.sequence_editor
|
||||
@ -2250,15 +2265,16 @@ class KITSU_OT_shot_import_playblast(bpy.types.Operator):
|
||||
def draw(self, context: bpy.types.Context) -> None:
|
||||
layout = self.layout
|
||||
layout.prop(self, "channel_selection")
|
||||
layout.prop(self, "task_type")
|
||||
|
||||
def execute(self, context: Context) -> Set[str] | Set[int]:
|
||||
succeeded: Set[str] = set()
|
||||
failed: Set[str] = set()
|
||||
sequences = context.scene.sequence_editor.sequences
|
||||
for metadata_strip in context.selected_sequences:
|
||||
task_type_short_name = "anim" # TODO make variable
|
||||
# TODO add try except if ID is not valid, do same for shot as image sequence.
|
||||
shot = Shot.by_id(metadata_strip.kitsu.shot_id)
|
||||
task_type_short_name = TaskType.by_id(self.task_type).get_short_name()
|
||||
filepath = shot.get_latest_playblast_file(context, task_type_short_name)
|
||||
if filepath:
|
||||
playblast = sequences.new_movie(
|
||||
@ -2274,7 +2290,7 @@ class KITSU_OT_shot_import_playblast(bpy.types.Operator):
|
||||
else:
|
||||
failed.add(metadata_strip.name)
|
||||
|
||||
self.report({"INFO"}, "Completed!")
|
||||
self.report({"INFO"}, "Completed!") # TODO add report if failure
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user