Clean-up add set stamps
parent
c00041005f
commit
08885f8c59
23
__init__.py
23
__init__.py
|
@ -22,10 +22,10 @@ from vse_toolbox import preferences
|
||||||
from vse_toolbox import properties
|
from vse_toolbox import properties
|
||||||
from vse_toolbox import operators
|
from vse_toolbox import operators
|
||||||
from vse_toolbox.constants import ASSET_PREVIEWS
|
from vse_toolbox.constants import ASSET_PREVIEWS
|
||||||
from vse_toolbox.sequencer_utils import get_active_strip
|
from vse_toolbox.sequencer_utils import set_active_strip, update_text_strips
|
||||||
|
|
||||||
|
|
||||||
mods = (
|
modules = (
|
||||||
properties,
|
properties,
|
||||||
preferences,
|
preferences,
|
||||||
operators,
|
operators,
|
||||||
|
@ -34,8 +34,8 @@ mods = (
|
||||||
|
|
||||||
if 'bpy' in locals():
|
if 'bpy' in locals():
|
||||||
import importlib
|
import importlib
|
||||||
for mod in mods:
|
for module in modules:
|
||||||
importlib.reload(mod)
|
importlib.reload(module)
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
|
@ -43,10 +43,11 @@ def register():
|
||||||
if bpy.app.background:
|
if bpy.app.background:
|
||||||
return
|
return
|
||||||
|
|
||||||
for mod in mods:
|
for module in modules:
|
||||||
mod.register()
|
module.register()
|
||||||
|
|
||||||
bpy.app.handlers.frame_change_post.append(get_active_strip)
|
bpy.app.handlers.frame_change_post.append(set_active_strip)
|
||||||
|
bpy.app.handlers.frame_change_post.append(update_text_strips)
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
|
|
||||||
|
@ -60,9 +61,11 @@ def unregister():
|
||||||
if bpy.app.background:
|
if bpy.app.background:
|
||||||
return
|
return
|
||||||
|
|
||||||
bpy.app.handlers.frame_change_post.remove(get_active_strip)
|
bpy.app.handlers.frame_change_post.remove(set_active_strip)
|
||||||
for mod in reversed(mods):
|
bpy.app.handlers.frame_change_post.remove(set_active_strip)
|
||||||
mod.unregister()
|
|
||||||
|
for module in reversed(modules):
|
||||||
|
module.unregister()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
register()
|
register()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import appdirs
|
from vse_toolbox import appdirs
|
||||||
import bpy
|
import bpy
|
||||||
import bpy.utils.previews
|
import bpy.utils.previews
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -32,19 +32,21 @@ from vse_toolbox.constants import (
|
||||||
)
|
)
|
||||||
from vse_toolbox.sequencer_utils import (
|
from vse_toolbox.sequencer_utils import (
|
||||||
clean_sequencer,
|
clean_sequencer,
|
||||||
get_shot_sequence,
|
|
||||||
get_strips,
|
get_strips,
|
||||||
get_active_strip,
|
set_active_strip,
|
||||||
import_edit,
|
import_edit,
|
||||||
import_movie,
|
import_movie,
|
||||||
import_sound,
|
import_sound,
|
||||||
rename_strips,
|
rename_strips,
|
||||||
render_strips,
|
render_strips,
|
||||||
set_channels,
|
set_channels,
|
||||||
|
get_channel_index,
|
||||||
|
new_text_strip
|
||||||
)
|
)
|
||||||
from vse_toolbox.bl_utils import get_addon_prefs, get_scene_settings, get_strip_settings
|
from vse_toolbox.bl_utils import get_addon_prefs, get_scene_settings, get_strip_settings
|
||||||
from vse_toolbox.file_utils import install_module, norm_name, norm_str
|
from vse_toolbox.file_utils import install_module, norm_name, norm_str
|
||||||
|
|
||||||
|
|
||||||
class VSETB_OT_tracker_connect(Operator):
|
class VSETB_OT_tracker_connect(Operator):
|
||||||
bl_idname = "vse_toolbox.tracker_connect"
|
bl_idname = "vse_toolbox.tracker_connect"
|
||||||
bl_label = "Connect to Tracker"
|
bl_label = "Connect to Tracker"
|
||||||
|
@ -71,7 +73,7 @@ class VSETB_OT_tracker_connect(Operator):
|
||||||
|
|
||||||
|
|
||||||
class VSETB_OT_export_csv(Operator):
|
class VSETB_OT_export_csv(Operator):
|
||||||
bl_idname = "sequencer.export_csv"
|
bl_idname = "vse_toolbox.export_csv"
|
||||||
bl_label = "Set Scene"
|
bl_label = "Set Scene"
|
||||||
bl_description = "Set Scene for Breakdown"
|
bl_description = "Set Scene for Breakdown"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
@ -132,7 +134,7 @@ class VSETB_OT_auto_select_files(Operator):
|
||||||
|
|
||||||
|
|
||||||
class VSETB_OT_import_files(Operator):
|
class VSETB_OT_import_files(Operator):
|
||||||
bl_idname = "sequencer.import_files"
|
bl_idname = "vse_toolbox.import_files"
|
||||||
bl_label = "Import"
|
bl_label = "Import"
|
||||||
bl_description = "Import Edit"
|
bl_description = "Import Edit"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
@ -316,23 +318,29 @@ class VSETB_OT_load_projects(Operator):
|
||||||
|
|
||||||
for project_data in tracker.get_projects():
|
for project_data in tracker.get_projects():
|
||||||
project = settings.projects.add()
|
project = settings.projects.add()
|
||||||
|
project.type = project_data['production_type']
|
||||||
project.name = project_data['name']
|
project.name = project_data['name']
|
||||||
project.id = project_data['id']
|
project.id = project_data['id']
|
||||||
|
|
||||||
|
if project.type == 'TV Show':
|
||||||
for episode_data in tracker.get_episodes(project_data):
|
for episode_data in tracker.get_episodes(project_data):
|
||||||
episode = project.episodes.add()
|
episode = project.episodes.add()
|
||||||
episode.name = episode_data['name']
|
episode.name = episode_data['name']
|
||||||
episode.id = episode_data['id']
|
episode.id = episode_data['id']
|
||||||
|
|
||||||
for metadata_data in tracker.get_shots_metadata(project_data):
|
for metadata_data in tracker.get_shots_metadata(project_data):
|
||||||
|
#print(metadata_data)
|
||||||
metadata_type = project.metadata_types.add()
|
metadata_type = project.metadata_types.add()
|
||||||
metadata_type.name = metadata_data
|
metadata_type.name = metadata_data['field_name']
|
||||||
|
metadata_type['choices'] = metadata_data['choices']
|
||||||
|
|
||||||
for asset_type_data in tracker.get_asset_types(project_data):
|
for asset_type_data in tracker.get_asset_types(project_data):
|
||||||
asset_type = project.asset_types.add()
|
asset_type = project.asset_types.add()
|
||||||
asset_type.name = asset_type_data['name']
|
asset_type.name = asset_type_data['name']
|
||||||
|
|
||||||
# settings.load_metadata_types()
|
project.set_strip_metadata()
|
||||||
|
|
||||||
|
bpy.ops.vse_toolbox.load_assets()
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
@ -395,7 +403,7 @@ class VSETB_OT_reload_addon(Operator):
|
||||||
|
|
||||||
|
|
||||||
class VSETB_OT_rename(Operator):
|
class VSETB_OT_rename(Operator):
|
||||||
bl_idname = "sequencer.strips_rename"
|
bl_idname = "vse_toolbox.strips_rename"
|
||||||
bl_label = "Rename Strips"
|
bl_label = "Rename Strips"
|
||||||
bl_description = "Rename Strips"
|
bl_description = "Rename Strips"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
@ -403,7 +411,7 @@ class VSETB_OT_rename(Operator):
|
||||||
template : StringProperty(name="Strip Template Name", default="")
|
template : StringProperty(name="Strip Template Name", default="")
|
||||||
increment : IntProperty(name="Name Increment", default=0)
|
increment : IntProperty(name="Name Increment", default=0)
|
||||||
channel_name : StringProperty(name="Channel Name", default="")
|
channel_name : StringProperty(name="Channel Name", default="")
|
||||||
selected_only : BoolProperty(name="Selected Only", default=False)
|
#selected_only : BoolProperty(name="Selected Only", default=False)
|
||||||
start_number : IntProperty(name="Start Number", default=0, min=0)
|
start_number : IntProperty(name="Start Number", default=0, min=0)
|
||||||
by_sequence : BoolProperty(
|
by_sequence : BoolProperty(
|
||||||
name="Reset By Sequence",
|
name="Reset By Sequence",
|
||||||
|
@ -432,11 +440,12 @@ class VSETB_OT_rename(Operator):
|
||||||
col.prop(self, 'start_number')
|
col.prop(self, 'start_number')
|
||||||
if self.channel_name == 'Shots':
|
if self.channel_name == 'Shots':
|
||||||
col.prop(self, 'by_sequence')
|
col.prop(self, 'by_sequence')
|
||||||
col.prop(self, 'selected_only')
|
#col.prop(self, 'selected_only')
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
scn = context.scene
|
scn = context.scene
|
||||||
strips = get_strips(channel=self.channel_name, selected_only=self.selected_only)
|
#strips = get_strips(channel=self.channel_name, selected_only=self.selected_only)
|
||||||
|
strips = get_strips(channel=self.channel_name, selected_only=True)
|
||||||
|
|
||||||
rename_strips(
|
rename_strips(
|
||||||
strips, self.template,
|
strips, self.template,
|
||||||
|
@ -448,7 +457,7 @@ class VSETB_OT_rename(Operator):
|
||||||
|
|
||||||
|
|
||||||
class VSETB_OT_render(Operator):
|
class VSETB_OT_render(Operator):
|
||||||
bl_idname = "sequencer.strips_render"
|
bl_idname = "vse_toolbox.strips_render"
|
||||||
bl_label = "Render Shots Strips"
|
bl_label = "Render Shots Strips"
|
||||||
bl_description = "Render Shots Strips"
|
bl_description = "Render Shots Strips"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
@ -486,10 +495,10 @@ class VSETB_OT_render(Operator):
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class VSETB_OT_set_scene(Operator):
|
class VSETB_OT_set_sequencer(Operator):
|
||||||
bl_idname = "vse_toolbox.set_scene"
|
bl_idname = "vse_toolbox.set_sequencer"
|
||||||
bl_label = "Set Scene"
|
bl_label = "Set Sequencer"
|
||||||
bl_description = "Set Scene for Breakdown"
|
bl_description = "Set resolution, frame end and channel names"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -519,6 +528,7 @@ def get_asset_items(self, context):
|
||||||
|
|
||||||
return [(a.id, a.label, '', i) for i, a in enumerate(project.assets)]
|
return [(a.id, a.label, '', i) for i, a in enumerate(project.assets)]
|
||||||
|
|
||||||
|
|
||||||
class VSETB_OT_casting_add(Operator):
|
class VSETB_OT_casting_add(Operator):
|
||||||
bl_idname = "vse_toolbox.casting_add"
|
bl_idname = "vse_toolbox.casting_add"
|
||||||
bl_label = "Casting Add"
|
bl_label = "Casting Add"
|
||||||
|
@ -557,6 +567,8 @@ class VSETB_OT_casting_add(Operator):
|
||||||
item.name = asset.name
|
item.name = asset.name
|
||||||
item.id = project.assets[self.asset_name].id
|
item.id = project.assets[self.asset_name].id
|
||||||
|
|
||||||
|
item['_name'] = asset.label
|
||||||
|
|
||||||
strip_settings.casting.update()
|
strip_settings.casting.update()
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
@ -586,7 +598,8 @@ class VSETB_OT_casting_remove(Operator):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
item = strip_settings.casting[strip_settings.casting_index]
|
item = strip_settings.casting[strip_settings.casting_index]
|
||||||
info = f"Item {item.asset.label} removed from casting"
|
label = item.asset.label if item.asset.label else 'Empty'
|
||||||
|
info = f"Item {label} removed from casting"
|
||||||
strip_settings.casting.remove(idx)
|
strip_settings.casting.remove(idx)
|
||||||
|
|
||||||
if strip_settings.casting_index == 0:
|
if strip_settings.casting_index == 0:
|
||||||
|
@ -648,7 +661,7 @@ class VSETB_OT_casting_move(Operator):
|
||||||
|
|
||||||
|
|
||||||
class VSETB_OT_copy_casting(Operator):
|
class VSETB_OT_copy_casting(Operator):
|
||||||
bl_idname = "sequencer.copy_casting"
|
bl_idname = "vse_toolbox.copy_casting"
|
||||||
bl_label = "Casting Actions"
|
bl_label = "Casting Actions"
|
||||||
bl_description = "Copy Casting from active strip"
|
bl_description = "Copy Casting from active strip"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
@ -674,7 +687,7 @@ class VSETB_OT_copy_casting(Operator):
|
||||||
|
|
||||||
|
|
||||||
class VSETB_OT_paste_casting(Operator):
|
class VSETB_OT_paste_casting(Operator):
|
||||||
bl_idname = "sequencer.paste_casting"
|
bl_idname = "vse_toolbox.paste_casting"
|
||||||
bl_label = "Casting Actions"
|
bl_label = "Casting Actions"
|
||||||
bl_description = "Copy Casting from active strip"
|
bl_description = "Copy Casting from active strip"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
@ -709,7 +722,71 @@ class VSETB_OT_paste_casting(Operator):
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
classes=(
|
|
||||||
|
class VSETB_OT_set_stamps(Operator):
|
||||||
|
bl_idname = "vse_toolbox.set_stamps"
|
||||||
|
bl_label = "Set Stamps"
|
||||||
|
bl_description = "Set Stamps on Video"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
scn = context.scene
|
||||||
|
settings = get_scene_settings()
|
||||||
|
#strip_settings = get_strip_settings()
|
||||||
|
channel_index = get_channel_index('Stamps')
|
||||||
|
|
||||||
|
for strip in get_strips('Stamps'):
|
||||||
|
if strip.type == 'META':
|
||||||
|
scn.sequence_editor.sequences.remove(strip)
|
||||||
|
|
||||||
|
bpy.ops.sequencer.select_all(action='DESELECT')
|
||||||
|
|
||||||
|
# Project Name
|
||||||
|
project_strip_stamp = new_text_strip(
|
||||||
|
'project_name_stamp', channel=1, start=scn.frame_start, end=scn.frame_end,
|
||||||
|
text=settings.active_project.name, font_size=24,
|
||||||
|
x=0.01, y=0.01, align_x='LEFT', align_y='BOTTOM', select=True,
|
||||||
|
box_color=(0, 0, 0, 0.5), box_margin=0.005,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Shot Name
|
||||||
|
shot_strip_stamp = new_text_strip(
|
||||||
|
f'shot_name_stamp', channel=2, start=scn.frame_start, end=scn.frame_end,
|
||||||
|
text='{active_shot_name}', font_size=24,
|
||||||
|
y=0.01, align_y='BOTTOM', select=True,
|
||||||
|
box_color=(0, 0, 0, 0.5), box_margin=0.005,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Frame Range
|
||||||
|
frame_strip_stamp = new_text_strip(
|
||||||
|
'frame_range_stamp', channel=3, start=scn.frame_start, end=scn.frame_end,
|
||||||
|
text='{active_shot_frame} / {active_shot_duration}', font_size=24,
|
||||||
|
x=0.99, y=0.01, align_x='RIGHT', align_y='BOTTOM', select=True,
|
||||||
|
box_color=(0, 0, 0, 0.5), box_margin=0.005,
|
||||||
|
)
|
||||||
|
|
||||||
|
# for shot_strip in get_strips('Shots'):
|
||||||
|
# # Shot Name
|
||||||
|
# shot_strip_stamp = new_text_strip(
|
||||||
|
# f'{shot_strip.name}_stamp', channel=3, start=shot_strip.frame_final_start, end=shot_strip.frame_final_end,
|
||||||
|
# text=shot_strip.name, font_size=24,
|
||||||
|
# y=0.01, align_y='BOTTOM', select=True,
|
||||||
|
# box_color=(0, 0, 0, 0.35), box_margin=0.005,
|
||||||
|
# )
|
||||||
|
|
||||||
|
bpy.ops.sequencer.meta_make()
|
||||||
|
stamps_strip = context.active_sequence_strip
|
||||||
|
stamps_strip.name = 'Stamps'
|
||||||
|
stamps_strip.channel = channel_index
|
||||||
|
|
||||||
|
#stamps_strip = scn.sequence_editor.sequences.new_meta('Stamps', scn.frame_start, scn.frame_end)
|
||||||
|
#stamps_strip.channel = get_channel_index('Stamps')
|
||||||
|
scn.frame_set(scn.frame_current) # For update stamps
|
||||||
|
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
classes = (
|
||||||
VSETB_OT_auto_select_files,
|
VSETB_OT_auto_select_files,
|
||||||
VSETB_OT_casting_add,
|
VSETB_OT_casting_add,
|
||||||
VSETB_OT_casting_remove,
|
VSETB_OT_casting_remove,
|
||||||
|
@ -724,8 +801,9 @@ classes=(
|
||||||
VSETB_OT_reload_addon,
|
VSETB_OT_reload_addon,
|
||||||
VSETB_OT_rename,
|
VSETB_OT_rename,
|
||||||
VSETB_OT_render,
|
VSETB_OT_render,
|
||||||
VSETB_OT_set_scene,
|
VSETB_OT_set_sequencer,
|
||||||
VSETB_OT_tracker_connect,
|
VSETB_OT_tracker_connect,
|
||||||
|
VSETB_OT_set_stamps
|
||||||
)
|
)
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
|
|
178
panels.py
178
panels.py
|
@ -3,9 +3,10 @@
|
||||||
import bpy
|
import bpy
|
||||||
from bpy.types import Panel
|
from bpy.types import Panel
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from vse_toolbox.bl_utils import get_addon_prefs, get_scene_settings, get_strip_settings
|
from vse_toolbox.bl_utils import (get_addon_prefs, get_scene_settings, get_strip_settings)
|
||||||
from vse_toolbox.constants import ASSET_PREVIEWS
|
from vse_toolbox.constants import ASSET_PREVIEWS
|
||||||
from vse_toolbox.sequencer_utils import get_active_strip
|
from vse_toolbox.sequencer_utils import (set_active_strip, get_channel_name)
|
||||||
|
|
||||||
|
|
||||||
class VSETB_main:
|
class VSETB_main:
|
||||||
bl_space_type = "SEQUENCE_EDITOR"
|
bl_space_type = "SEQUENCE_EDITOR"
|
||||||
|
@ -16,10 +17,8 @@ class VSETB_main:
|
||||||
|
|
||||||
class VSETB_PT_main(VSETB_main, Panel):
|
class VSETB_PT_main(VSETB_main, Panel):
|
||||||
|
|
||||||
def draw_header(self, context):
|
def draw_header_preset(self, context):
|
||||||
layout = self.layout
|
self.layout.operator('vse_toolbox.load_projects', icon='FILE_REFRESH', text='', emboss=False)
|
||||||
row = layout.row()
|
|
||||||
row.operator('vse_toolbox.load_projects', icon='FILE_REFRESH', text='')
|
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
wm = context.window_manager
|
wm = context.window_manager
|
||||||
|
@ -32,11 +31,20 @@ class VSETB_PT_main(VSETB_main, Panel):
|
||||||
|
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
row = col.row(align=True)
|
|
||||||
|
|
||||||
row.operator('vse_toolbox.set_scene', text='Set Scene', icon='SCENE_DATA')
|
col.prop(settings, 'project_name', text='Project')
|
||||||
row.prop(settings, 'toogle_prefs', text='', icon='PREFERENCES', toggle=True)
|
|
||||||
|
|
||||||
|
if project:
|
||||||
|
if project.type == 'TV Shows':
|
||||||
|
col.prop(project, 'episode_name', text='Episodes')
|
||||||
|
|
||||||
|
#col.separator()
|
||||||
|
|
||||||
|
#row = col.row(align=True)
|
||||||
|
|
||||||
|
#row.prop(settings, 'toogle_prefs', text='', icon='PREFERENCES', toggle=True)
|
||||||
|
|
||||||
|
'''
|
||||||
if settings.toogle_prefs:
|
if settings.toogle_prefs:
|
||||||
box = col.box()
|
box = col.box()
|
||||||
col = box.column(align=True)
|
col = box.column(align=True)
|
||||||
|
@ -46,66 +54,124 @@ class VSETB_PT_main(VSETB_main, Panel):
|
||||||
col.prop(settings, 'project_name', text='Projects')
|
col.prop(settings, 'project_name', text='Projects')
|
||||||
|
|
||||||
if project:
|
if project:
|
||||||
if project.episodes:
|
if project.type == 'TV Shows':
|
||||||
col.prop(project, 'episode_name', text='Episodes')
|
col.prop(project, 'episode_name', text='Episodes')
|
||||||
|
|
||||||
col.prop(project, 'shot_template')
|
#col.prop(project, 'sequence_template')
|
||||||
|
#col.prop(project, 'shot_template')
|
||||||
# col.separator()
|
# col.separator()
|
||||||
# col.operator('vse_toolbox.new_episode', text='Add Episode', icon='IMPORT')
|
# col.operator('vse_toolbox.new_episode', text='Add Episode', icon='IMPORT')
|
||||||
|
'''
|
||||||
|
|
||||||
col = layout.column()
|
# Rename
|
||||||
row = col.row(align=True)
|
|
||||||
row.operator('sequencer.import_files', text='Import', icon='IMPORT')
|
|
||||||
# TODO FAIRE DES VRAIS OPS
|
|
||||||
row.operator('sequencer.export_csv', text='Export', icon='EXPORT')
|
|
||||||
op = col.operator('sequencer.strips_render', text='Render Strips', icon='RENDER_ANIMATION')
|
|
||||||
|
|
||||||
|
|
||||||
class VSETB_PT_rename(VSETB_main, Panel):
|
class VSETB_PT_sequencer(VSETB_main, Panel):
|
||||||
bl_label = "Rename Strips"
|
bl_label = "Sequencer"
|
||||||
bl_parent_id = "VSETB_PT_main"
|
bl_parent_id = "VSETB_PT_main"
|
||||||
|
|
||||||
|
def draw_header_preset(self, context):
|
||||||
|
settings = get_scene_settings()
|
||||||
|
ico = ("RESTRICT_SELECT_OFF" if settings.auto_select_strip else "RESTRICT_SELECT_ON")
|
||||||
|
self.layout.prop(settings, "auto_select_strip", text="", icon=ico)
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
prefs = get_addon_prefs()
|
prefs = get_addon_prefs()
|
||||||
|
layout = self.layout
|
||||||
settings = get_scene_settings()
|
settings = get_scene_settings()
|
||||||
project = settings.active_project
|
project = settings.active_project
|
||||||
|
|
||||||
if not project:
|
|
||||||
return
|
|
||||||
|
|
||||||
episode = project.episode_name
|
|
||||||
|
|
||||||
layout = self.layout
|
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
|
|
||||||
col.use_property_split = True
|
col.operator('vse_toolbox.set_sequencer', text='Set-Up Sequencer', icon='SEQ_SEQUENCER')
|
||||||
|
|
||||||
row = col.row()
|
#row = col.row()
|
||||||
shot_increment = project.shot_increment
|
episode = project.episode_name
|
||||||
shot_template = project.shot_template.format(
|
sequence_label = project.sequence_template.format(episode=episode, index=project.sequence_start_number)
|
||||||
episode=episode, index=0 * shot_increment)
|
shot_label = project.shot_template.format(episode=episode, sequence=sequence_label, index=project.shot_start_number)
|
||||||
|
|
||||||
row.separator()
|
#row.separator()
|
||||||
|
|
||||||
op = row.operator('sequencer.strips_rename', text='Rename Shots', icon='SORTALPHA')
|
strip = context.active_sequence_strip
|
||||||
op.channel_name = 'Shots'
|
channel_name = get_channel_name(strip) or ''
|
||||||
|
if channel_name == 'Shots':
|
||||||
|
label = shot_label
|
||||||
|
elif channel_name == 'Sequences':
|
||||||
|
label = sequence_label
|
||||||
|
else:
|
||||||
|
label = 'Not Supported'
|
||||||
|
|
||||||
|
row = col.row(align=True)
|
||||||
|
if label == 'Not Supported':
|
||||||
|
row.enabled = False
|
||||||
|
|
||||||
|
op = row.operator('vse_toolbox.strips_rename', text=f'Rename {channel_name} ( {label} )', icon='SORTALPHA')
|
||||||
|
op.channel_name = channel_name
|
||||||
|
if channel_name == 'Shots':
|
||||||
|
op.start_number = project.shot_start_number
|
||||||
op.template = project.shot_template
|
op.template = project.shot_template
|
||||||
op.increment = project.shot_increment
|
op.increment = project.shot_increment
|
||||||
op.start_number = 10
|
else:
|
||||||
row.label(text=f'{shot_template}')
|
op.start_number = project.sequence_start_number
|
||||||
|
op.template = project.sequence_template
|
||||||
|
op.increment =project.sequence_increment
|
||||||
|
|
||||||
|
col.operator('vse_toolbox.set_stamps', text='Set Stamps', icon='COLOR')
|
||||||
|
|
||||||
|
|
||||||
|
class VSETB_PT_imports(VSETB_main, Panel):
|
||||||
|
bl_label = "Imports"
|
||||||
|
bl_parent_id = "VSETB_PT_main"
|
||||||
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
|
def draw_header_preset(self, context):
|
||||||
|
self.layout.operator('vse_toolbox.import_files', icon='IMPORT', text='', emboss=False)
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
prefs = get_addon_prefs()
|
||||||
|
layout = self.layout
|
||||||
|
settings = get_scene_settings()
|
||||||
|
project = settings.active_project
|
||||||
|
|
||||||
|
col = layout.column()
|
||||||
|
#row = col.row(align=True)
|
||||||
|
col.operator('vse_toolbox.import_files', text='Import', icon='IMPORT')
|
||||||
|
|
||||||
|
|
||||||
|
class VSETB_PT_exports(VSETB_main, Panel):
|
||||||
|
bl_label = "Exports"
|
||||||
|
bl_parent_id = "VSETB_PT_main"
|
||||||
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
|
def draw_header_preset(self, context):
|
||||||
|
self.layout.operator('vse_toolbox.export_csv', icon='EXPORT', text='', emboss=False)
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
prefs = get_addon_prefs()
|
||||||
|
layout = self.layout
|
||||||
|
settings = get_scene_settings()
|
||||||
|
project = settings.active_project
|
||||||
|
|
||||||
|
# TODO FAIRE DES VRAIS OPS
|
||||||
|
layout.operator('vse_toolbox.strips_render', text='Render Strips', icon='SEQUENCE')
|
||||||
|
layout.operator('vse_toolbox.export_csv', text='Export', icon='EXPORT')
|
||||||
|
|
||||||
|
|
||||||
class VSETB_PT_casting(VSETB_main, Panel):
|
class VSETB_PT_casting(VSETB_main, Panel):
|
||||||
bl_label = "Shot Casting"
|
bl_label = "Casting"
|
||||||
bl_parent_id = "VSETB_PT_main"
|
bl_parent_id = "VSETB_PT_main"
|
||||||
|
|
||||||
|
def draw_header_preset(self, context):
|
||||||
|
active_strip = context.scene.sequence_editor.active_strip
|
||||||
|
self.layout.label(text=active_strip.name)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
strip = context.scene.sequence_editor.active_strip
|
||||||
|
return strip and get_channel_name(strip) == 'Shots'
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
scn = context.scene
|
|
||||||
active_strip = scn.sequence_editor.active_strip
|
|
||||||
|
|
||||||
if not active_strip:
|
|
||||||
return
|
|
||||||
|
|
||||||
settings = get_scene_settings()
|
settings = get_scene_settings()
|
||||||
strip_settings = get_strip_settings()
|
strip_settings = get_strip_settings()
|
||||||
|
@ -117,19 +183,9 @@ class VSETB_PT_casting(VSETB_main, Panel):
|
||||||
|
|
||||||
if not project.assets:
|
if not project.assets:
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.label(text='No Assets found. Load Assets first.')
|
row.label(text='No Assets in this Project')
|
||||||
else:
|
else:
|
||||||
row = layout.row(align=True)
|
|
||||||
row.label(text=f'Assets for {project.name} successfully loaded.')
|
|
||||||
|
|
||||||
row.operator('vse_toolbox.load_assets', icon='FILE_REFRESH', text='')
|
|
||||||
|
|
||||||
row = layout.row()
|
|
||||||
ico = ("RESTRICT_SELECT_OFF" if settings.auto_select_strip else "RESTRICT_SELECT_ON")
|
|
||||||
row.prop(settings, "auto_select_strip", icon=ico)
|
|
||||||
|
|
||||||
row = layout.row()
|
|
||||||
row.label(text=f"Current Shot: {Path(active_strip.name).stem}")
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
col = row.column()
|
col = row.column()
|
||||||
col.template_list("VSETB_UL_casting", "shot_casting", strip_settings, "casting", strip_settings, "casting_index", rows=6)
|
col.template_list("VSETB_UL_casting", "shot_casting", strip_settings, "casting", strip_settings, "casting_index", rows=6)
|
||||||
|
@ -150,14 +206,14 @@ class VSETB_PT_casting(VSETB_main, Panel):
|
||||||
col_tool.operator('vse_toolbox.casting_move', icon='TRIA_UP', text="").action = 'UP'
|
col_tool.operator('vse_toolbox.casting_move', icon='TRIA_UP', text="").action = 'UP'
|
||||||
col_tool.operator('vse_toolbox.casting_move', icon='TRIA_DOWN', text="").action = 'DOWN'
|
col_tool.operator('vse_toolbox.casting_move', icon='TRIA_DOWN', text="").action = 'DOWN'
|
||||||
col_tool.separator()
|
col_tool.separator()
|
||||||
col_tool.operator('sequencer.copy_casting', icon='COPYDOWN', text="")
|
col_tool.operator('vse_toolbox.copy_casting', icon='COPYDOWN', text="")
|
||||||
col_tool.operator('sequencer.paste_casting', icon='PASTEDOWN', text="")
|
col_tool.operator('vse_toolbox.paste_casting', icon='PASTEDOWN', text="")
|
||||||
|
|
||||||
|
|
||||||
class VSETB_PT_metadata(VSETB_main, Panel):
|
class VSETB_PT_metadata(VSETB_main, Panel):
|
||||||
bl_label = "Shot Metadata"
|
bl_label = "Shot Metadata"
|
||||||
bl_parent_id = "VSETB_PT_casting"
|
bl_parent_id = "VSETB_PT_casting"
|
||||||
bl_options = {"DEFAULT_CLOSED"}
|
#bl_options = {"DEFAULT_CLOSED"}
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
@ -175,15 +231,17 @@ class VSETB_PT_metadata(VSETB_main, Panel):
|
||||||
if not project:
|
if not project:
|
||||||
return
|
return
|
||||||
|
|
||||||
col = layout.column()
|
#col = layout.column()
|
||||||
for key in strip_settings.metadata.keys():
|
for key in strip_settings.metadata.__annotations__.keys():
|
||||||
col.prop(strip_settings.metadata, key)
|
layout.prop(strip_settings.metadata, key, text=key.upper())
|
||||||
|
|
||||||
classes=(
|
classes = (
|
||||||
VSETB_PT_main,
|
VSETB_PT_main,
|
||||||
VSETB_PT_rename,
|
VSETB_PT_imports,
|
||||||
|
VSETB_PT_sequencer,
|
||||||
VSETB_PT_casting,
|
VSETB_PT_casting,
|
||||||
VSETB_PT_metadata,
|
VSETB_PT_metadata,
|
||||||
|
VSETB_PT_exports,
|
||||||
)
|
)
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
|
|
105
properties.py
105
properties.py
|
@ -37,13 +37,18 @@ def get_project_items(self, context):
|
||||||
|
|
||||||
return [(p, p, '', i) for i, p in enumerate(self.projects.keys())]
|
return [(p, p, '', i) for i, p in enumerate(self.projects.keys())]
|
||||||
|
|
||||||
def update_episodes(self, context):
|
def on_project_updated(self, context):
|
||||||
settings = get_scene_settings()
|
settings = get_scene_settings()
|
||||||
settings['episodes'] = 0
|
settings['episodes'] = 0
|
||||||
|
|
||||||
|
print('Update active Project')
|
||||||
|
|
||||||
|
bpy.ops.vse_toolbox.load_assets()
|
||||||
|
|
||||||
def get_tracker_items(self, context):
|
def get_tracker_items(self, context):
|
||||||
return [(norm_str(a.name, format=str.upper), a.name, "", i) for i, a in enumerate(TRACKERS)]
|
return [(norm_str(a.name, format=str.upper), a.name, "", i) for i, a in enumerate(TRACKERS)]
|
||||||
|
|
||||||
|
|
||||||
class Asset(PropertyGroup):
|
class Asset(PropertyGroup):
|
||||||
name : StringProperty(default='')
|
name : StringProperty(default='')
|
||||||
id : StringProperty(default='')
|
id : StringProperty(default='')
|
||||||
|
@ -79,25 +84,19 @@ class AssetCasting(PropertyGroup):
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return {k: v for k,v in self.items()}
|
return {k: v for k,v in self.items()}
|
||||||
|
|
||||||
class AssetTypes(PropertyGroup):
|
|
||||||
choices : EnumProperty(items=[('NONE', 'None', '', 0)])
|
class AssetType(PropertyGroup):
|
||||||
|
__annotations__ = {}
|
||||||
|
|
||||||
|
|
||||||
class MetaDataTypes(PropertyGroup):
|
class MetadataType(PropertyGroup):
|
||||||
choices : EnumProperty(items=[('NONE', 'None', '', 0)])
|
choices = []
|
||||||
|
choice : EnumProperty(items=lambda s, c: [(c, c.replace(' ', '_').upper(), '') for c in s['choices']])
|
||||||
|
|
||||||
|
|
||||||
class MetaData(PropertyGroup):
|
class Metadata(PropertyGroup):
|
||||||
|
__annotations__ = {}
|
||||||
|
|
||||||
notes : StringProperty()
|
|
||||||
ambiance : StringProperty()
|
|
||||||
fx_compo : StringProperty()
|
|
||||||
|
|
||||||
def __iter__(self):
|
|
||||||
return (getattr(self, k) for k in self.keys())
|
|
||||||
|
|
||||||
def keys(self):
|
|
||||||
return (p for p in self.bl_rna.properties.keys() if p not in ('rna_type', 'name'))
|
|
||||||
|
|
||||||
class Episode(PropertyGroup):
|
class Episode(PropertyGroup):
|
||||||
id : StringProperty(default='')
|
id : StringProperty(default='')
|
||||||
|
@ -111,6 +110,9 @@ class Episode(PropertyGroup):
|
||||||
class Project(PropertyGroup):
|
class Project(PropertyGroup):
|
||||||
id : StringProperty(default='')
|
id : StringProperty(default='')
|
||||||
|
|
||||||
|
shot_start_number : IntProperty(name="Shot Start Number", default=10, min=0)
|
||||||
|
sequence_start_number : IntProperty(name="Sequence Start Number", default=10, min=0)
|
||||||
|
|
||||||
sequence_increment : IntProperty(
|
sequence_increment : IntProperty(
|
||||||
name="Sequence Increment", default=10, min=0, step=10)
|
name="Sequence Increment", default=10, min=0, step=10)
|
||||||
|
|
||||||
|
@ -121,16 +123,28 @@ class Project(PropertyGroup):
|
||||||
name="Sequence Name", default="sq{index:03d}")
|
name="Sequence Name", default="sq{index:03d}")
|
||||||
|
|
||||||
episode_template : StringProperty(
|
episode_template : StringProperty(
|
||||||
name="Episode Name", default="e{index:03d}")
|
name="Episode Name", default="ep{index:03d}")
|
||||||
|
|
||||||
shot_template : StringProperty(
|
shot_template : StringProperty(
|
||||||
name="Shot Name", default="{episode}s{index:04d}")
|
name="Shot Name", default="{sequence}_sh{index:04d}")
|
||||||
|
|
||||||
episode_name : EnumProperty(items=get_episodes_items)
|
episode_name : EnumProperty(items=get_episodes_items)
|
||||||
episodes : CollectionProperty(type=Episode)
|
episodes : CollectionProperty(type=Episode)
|
||||||
assets : CollectionProperty(type=Asset)
|
assets : CollectionProperty(type=Asset)
|
||||||
asset_types : CollectionProperty(type=AssetTypes)
|
asset_types : CollectionProperty(type=AssetType)
|
||||||
metadata_types : CollectionProperty(type=MetaDataTypes)
|
metadata_types : CollectionProperty(type=MetadataType)
|
||||||
|
type : StringProperty()
|
||||||
|
|
||||||
|
def set_strip_metadata(self):
|
||||||
|
for metadata_type in self.metadata_types:
|
||||||
|
prop_name = metadata_type.name
|
||||||
|
if metadata_type['choices']:
|
||||||
|
prop = bpy.props.EnumProperty(items=[(c, c.replace(' ', '_').upper(), '') for c in metadata_type['choices']])
|
||||||
|
else:
|
||||||
|
prop = bpy.props.StringProperty()
|
||||||
|
|
||||||
|
Metadata.__annotations__[prop_name] = prop
|
||||||
|
setattr(Metadata, prop_name, prop)
|
||||||
|
|
||||||
|
|
||||||
class VSETB_UL_casting(UIList):
|
class VSETB_UL_casting(UIList):
|
||||||
|
@ -146,7 +160,7 @@ class VSETB_UL_casting(UIList):
|
||||||
asset = item.asset
|
asset = item.asset
|
||||||
if asset is None:
|
if asset is None:
|
||||||
#TODO deal if asset was removed
|
#TODO deal if asset was removed
|
||||||
layout.label(text='Load Assets')
|
layout.label(text=f'Asset not Found ({item.get("_name", "...")})')
|
||||||
return
|
return
|
||||||
|
|
||||||
icon_id = asset.icon_id
|
icon_id = asset.icon_id
|
||||||
|
@ -199,7 +213,7 @@ class VSETB_UL_casting(UIList):
|
||||||
class VSETB_PGT_scene_settings(PropertyGroup):
|
class VSETB_PGT_scene_settings(PropertyGroup):
|
||||||
|
|
||||||
projects : CollectionProperty(type=Project)
|
projects : CollectionProperty(type=Project)
|
||||||
project_name : EnumProperty(items=get_project_items, update=update_episodes)
|
project_name : EnumProperty(items=get_project_items, update=on_project_updated)
|
||||||
tracker_name : EnumProperty(items=get_tracker_items)
|
tracker_name : EnumProperty(items=get_tracker_items)
|
||||||
|
|
||||||
toogle_prefs : BoolProperty(
|
toogle_prefs : BoolProperty(
|
||||||
|
@ -214,6 +228,7 @@ class VSETB_PGT_scene_settings(PropertyGroup):
|
||||||
('MOVIE', 'Movie', '', 1),
|
('MOVIE', 'Movie', '', 1),
|
||||||
('SHOTS', 'Shots', '', 2),
|
('SHOTS', 'Shots', '', 2),
|
||||||
('SEQUENCES', 'Sequences', '', 3),
|
('SEQUENCES', 'Sequences', '', 3),
|
||||||
|
('STAMPS', 'Sequences', '', 4),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -233,46 +248,22 @@ class VSETB_PGT_scene_settings(PropertyGroup):
|
||||||
project = self.active_project
|
project = self.active_project
|
||||||
if project:
|
if project:
|
||||||
return project.episodes.get(project.episode_name)
|
return project.episodes.get(project.episode_name)
|
||||||
"""
|
|
||||||
def load_metadata_types(self):
|
|
||||||
settings = get_scene_settings()
|
|
||||||
print('settings: ', settings)
|
|
||||||
|
|
||||||
for project in settings.projects:
|
|
||||||
print('project: ', project)
|
|
||||||
|
|
||||||
metadata_props = {'__annotations__': {key : StringProperty() for key in project.metadata_types.keys()}}
|
|
||||||
MetadataProps = type(f"{project.name}_MetaData", (PropertyGroup,), metadata_props)
|
|
||||||
bpy.utils.register_class(MetadataProps)
|
|
||||||
|
|
||||||
setattr(VSETB_PGT_strip_settings, 'metadata', PointerProperty(type=MetadataProps))
|
|
||||||
|
|
||||||
# if "__annotations__" not in MetaData.__dict__:
|
|
||||||
# setattr(MetaData, "__annotations__", {})
|
|
||||||
|
|
||||||
# for metadata_type in project.metadata_types:
|
|
||||||
# print('metadata_type: ', metadata_type)
|
|
||||||
# MetaData.__annotations__[metadata_type.name] = StringProperty()
|
|
||||||
|
|
||||||
# bpy.utils.unregister_class(MetaData)
|
|
||||||
# bpy.utils.register_class(MetaData)
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
class VSETB_PGT_strip_settings(PropertyGroup):
|
class VSETB_PGT_strip_settings(PropertyGroup):
|
||||||
casting : CollectionProperty(type=AssetCasting)
|
casting : CollectionProperty(type=AssetCasting)
|
||||||
casting_index : IntProperty(name='Casting Index', default=0)
|
casting_index : IntProperty(name='Casting Index', default=0)
|
||||||
source_name : StringProperty(name='')
|
source_name : StringProperty(name='')
|
||||||
metadata : PointerProperty(type=MetaData)
|
metadata : PointerProperty(type=Metadata)
|
||||||
|
|
||||||
|
|
||||||
classes=(
|
classes=(
|
||||||
Asset,
|
Asset,
|
||||||
AssetCasting,
|
AssetCasting,
|
||||||
AssetTypes,
|
AssetType,
|
||||||
Episode,
|
Episode,
|
||||||
MetaData,
|
Metadata,
|
||||||
MetaDataTypes,
|
MetadataType,
|
||||||
Project,
|
Project,
|
||||||
VSETB_UL_casting,
|
VSETB_UL_casting,
|
||||||
VSETB_PGT_scene_settings,
|
VSETB_PGT_scene_settings,
|
||||||
|
@ -280,6 +271,16 @@ classes=(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
from bpy.app.handlers import persistent
|
||||||
|
|
||||||
|
@persistent
|
||||||
|
def load_handler(dummy):
|
||||||
|
settings = get_scene_settings()
|
||||||
|
if settings.active_project:
|
||||||
|
settings.active_project.set_strip_metadata()
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
for cls in classes:
|
for cls in classes:
|
||||||
bpy.utils.register_class(cls)
|
bpy.utils.register_class(cls)
|
||||||
|
@ -287,7 +288,9 @@ def register():
|
||||||
bpy.types.Scene.vsetb_settings = PointerProperty(type=VSETB_PGT_scene_settings)
|
bpy.types.Scene.vsetb_settings = PointerProperty(type=VSETB_PGT_scene_settings)
|
||||||
bpy.types.Sequence.vsetb_strip_settings = PointerProperty(type=VSETB_PGT_strip_settings)
|
bpy.types.Sequence.vsetb_strip_settings = PointerProperty(type=VSETB_PGT_strip_settings)
|
||||||
|
|
||||||
# load_metadata_types()
|
#load_metadata_types()
|
||||||
|
bpy.app.handlers.load_post.append(load_handler)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
for cls in reversed(classes):
|
for cls in reversed(classes):
|
||||||
|
@ -295,3 +298,5 @@ def unregister():
|
||||||
|
|
||||||
del bpy.types.Sequence.vsetb_strip_settings
|
del bpy.types.Sequence.vsetb_strip_settings
|
||||||
del bpy.types.Scene.vsetb_settings
|
del bpy.types.Scene.vsetb_settings
|
||||||
|
|
||||||
|
bpy.app.handlers.load_post.remove(load_handler)
|
||||||
|
|
|
@ -12,7 +12,12 @@ from vse_toolbox.bl_utils import get_addon_prefs, get_scene_settings
|
||||||
from vse_toolbox.file_utils import install_module, norm_str
|
from vse_toolbox.file_utils import install_module, norm_str
|
||||||
from vse_toolbox.resources.trackers.tracker import Tracker
|
from vse_toolbox.resources.trackers.tracker import Tracker
|
||||||
|
|
||||||
gazu = install_module('gazu')
|
try:
|
||||||
|
gazu = install_module('gazu')
|
||||||
|
except Exception as e:
|
||||||
|
print('Could not install gazu')
|
||||||
|
print(e)
|
||||||
|
|
||||||
|
|
||||||
class Kitsu(Tracker):
|
class Kitsu(Tracker):
|
||||||
name = "Kitsu"
|
name = "Kitsu"
|
||||||
|
@ -51,14 +56,13 @@ class Kitsu(Tracker):
|
||||||
return assets
|
return assets
|
||||||
|
|
||||||
def get_shots_metadata(self, project):
|
def get_shots_metadata(self, project):
|
||||||
metadata = []
|
metadatas = []
|
||||||
for md in gazu.project.all_metadata_descriptors(project):
|
|
||||||
asset_type = md.get('asset_type')
|
|
||||||
field_name = md.get('field_name')
|
|
||||||
if asset_type and asset_type.lower() == 'shot' and field_name:
|
|
||||||
metadata.append(field_name)
|
|
||||||
|
|
||||||
return metadata
|
for metadata in gazu.project.all_metadata_descriptors(project):
|
||||||
|
if metadata['entity_type'] == 'Shot' and metadata['name']:
|
||||||
|
metadatas.append(metadata)
|
||||||
|
|
||||||
|
return metadatas
|
||||||
|
|
||||||
def download_preview(self, preview_id, filepath):
|
def download_preview(self, preview_id, filepath):
|
||||||
if isinstance(filepath, str):
|
if isinstance(filepath, str):
|
||||||
|
|
|
@ -8,12 +8,39 @@ from pathlib import Path
|
||||||
from vse_toolbox.bl_utils import get_scene_settings, get_strip_settings
|
from vse_toolbox.bl_utils import get_scene_settings, get_strip_settings
|
||||||
from vse_toolbox.constants import SOUND_SUFFIXES
|
from vse_toolbox.constants import SOUND_SUFFIXES
|
||||||
|
|
||||||
|
def new_text_strip(name='Text', channel=0, start=0, end=50, text='Text', font_size=48,
|
||||||
|
x=0.5, y=0.5, align_x='CENTER', align_y='CENTER', select=False,
|
||||||
|
box_color=None, box_margin=0.005):
|
||||||
|
|
||||||
|
sequences = bpy.context.scene.sequence_editor.sequences
|
||||||
|
strip = sequences.new_effect(name, 'TEXT', channel, frame_start=start, frame_end=end)
|
||||||
|
strip.select = select
|
||||||
|
strip.text = text
|
||||||
|
strip.location.x = x
|
||||||
|
strip.location.y = y
|
||||||
|
strip.align_y = align_y
|
||||||
|
strip.align_x = align_x
|
||||||
|
strip.channel = channel
|
||||||
|
strip.font_size = font_size
|
||||||
|
|
||||||
|
if box_color:
|
||||||
|
strip.use_box = True
|
||||||
|
strip.box_color = box_color
|
||||||
|
strip.box_margin = box_margin
|
||||||
|
|
||||||
|
return strip
|
||||||
|
|
||||||
|
def is_strip_at(strip, frame=None):
|
||||||
|
if frame is None:
|
||||||
|
frame = bpy.context.scene.frame_current
|
||||||
|
|
||||||
|
return (strip.frame_final_start <= frame < strip.frame_final_end)
|
||||||
|
|
||||||
def get_strips(channel=0, selected_only=False):
|
def get_strips(channel=0, selected_only=False):
|
||||||
scn = bpy.context.scene
|
scn = bpy.context.scene
|
||||||
|
|
||||||
if isinstance(channel, str):
|
if isinstance(channel, str):
|
||||||
channel = get_channel(channel)
|
channel = get_channel_index(channel)
|
||||||
|
|
||||||
strips = [s for s in scn.sequence_editor.sequences_all if s.channel==channel]
|
strips = [s for s in scn.sequence_editor.sequences_all if s.channel==channel]
|
||||||
|
|
||||||
|
@ -22,7 +49,11 @@ def get_strips(channel=0, selected_only=False):
|
||||||
|
|
||||||
return sorted(strips, key=lambda x : x.frame_final_start)
|
return sorted(strips, key=lambda x : x.frame_final_start)
|
||||||
|
|
||||||
def get_channel(name):
|
def get_strip_at(channel=0, frame=None):
|
||||||
|
strips = get_strips(channel=channel)
|
||||||
|
return next((s for s in strips if is_strip_at(s, frame)), None)
|
||||||
|
|
||||||
|
def get_channel_index(name):
|
||||||
scn = bpy.context.scene
|
scn = bpy.context.scene
|
||||||
|
|
||||||
channel_id = 0
|
channel_id = 0
|
||||||
|
@ -32,9 +63,19 @@ def get_channel(name):
|
||||||
|
|
||||||
return channel_id
|
return channel_id
|
||||||
|
|
||||||
def get_shot_sequence(shot):
|
def get_channel_name(strip):
|
||||||
sequences = get_strips(channel='Sequences')
|
if not strip:
|
||||||
return next((s.name for s in sequences if s.frame_final_start<=shot.frame_final_start<s.frame_final_end), '')
|
return
|
||||||
|
|
||||||
|
scn = bpy.context.scene
|
||||||
|
return scn.sequence_editor.channels[strip.channel].name
|
||||||
|
|
||||||
|
def get_strip_sequence_name(strip):
|
||||||
|
sequence_strip = get_strip_at(channel='Sequences', frame=strip.frame_final_start)
|
||||||
|
if sequence_strip:
|
||||||
|
return sequence_strip.name
|
||||||
|
else:
|
||||||
|
return 'NoSequence'
|
||||||
|
|
||||||
def rename_strips(
|
def rename_strips(
|
||||||
strips, template, increment=10, start_number=0, by_sequence=False):
|
strips, template, increment=10, start_number=0, by_sequence=False):
|
||||||
|
@ -42,20 +83,23 @@ def rename_strips(
|
||||||
settings = get_scene_settings()
|
settings = get_scene_settings()
|
||||||
|
|
||||||
project = settings.active_project
|
project = settings.active_project
|
||||||
episode = settings.active_episode
|
episode_name = ''
|
||||||
|
if settings.active_episode:
|
||||||
|
episode_name = episode.name
|
||||||
|
|
||||||
previous_sequence = None
|
prev_sequence_name = None
|
||||||
strip_number = 0
|
strip_number = 0
|
||||||
|
|
||||||
for strip in strips:
|
for strip in strips:
|
||||||
sequence = get_shot_sequence(strip)
|
sequence_name = get_strip_sequence_name(strip)
|
||||||
|
|
||||||
if (by_sequence and previous_sequence and
|
if (by_sequence and prev_sequence_name and
|
||||||
sequence and sequence != previous_sequence):
|
sequence_name and sequence != prev_sequence_name):
|
||||||
strip_number = 0
|
strip_number = 0
|
||||||
|
|
||||||
name = template.format(
|
name = template.format(
|
||||||
episode=episode.name,
|
sequence=sequence_name,
|
||||||
|
episode=episode_name,
|
||||||
index=strip_number*increment+start_number
|
index=strip_number*increment+start_number
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -66,7 +110,7 @@ def rename_strips(
|
||||||
print(f'Renaming {strip.name} -> {name}')
|
print(f'Renaming {strip.name} -> {name}')
|
||||||
strip.name = name
|
strip.name = name
|
||||||
|
|
||||||
previous_sequence = sequence
|
prev_sequence_name = sequence_name
|
||||||
strip_number += 1
|
strip_number += 1
|
||||||
|
|
||||||
def set_channels():
|
def set_channels():
|
||||||
|
@ -126,10 +170,10 @@ def import_edit(filepath, adapter="cmx_3600", clean_sequencer=False):
|
||||||
|
|
||||||
# FIXME Exclude Audio for now
|
# FIXME Exclude Audio for now
|
||||||
if any(child.name.lower().endswith(ext) for ext in SOUND_SUFFIXES):
|
if any(child.name.lower().endswith(ext) for ext in SOUND_SUFFIXES):
|
||||||
channel = get_channel('Audio')
|
channel = get_channel_index('Audio')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
channel = get_channel('Shots')
|
channel = get_channel_index('Shots')
|
||||||
frame_start = otio.opentime.to_frames(
|
frame_start = otio.opentime.to_frames(
|
||||||
child.range_in_parent().start_time)
|
child.range_in_parent().start_time)
|
||||||
|
|
||||||
|
@ -164,7 +208,7 @@ def import_movie(filepath):
|
||||||
strip = scn.sequence_editor.sequences.new_movie(
|
strip = scn.sequence_editor.sequences.new_movie(
|
||||||
name=filepath.stem,
|
name=filepath.stem,
|
||||||
filepath=str(filepath),
|
filepath=str(filepath),
|
||||||
channel=get_channel('Movie'),
|
channel=get_channel_index('Movie'),
|
||||||
frame_start=scn.frame_start
|
frame_start=scn.frame_start
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -187,7 +231,7 @@ def import_sound(filepath):
|
||||||
strip = scn.sequence_editor.sequences.new_sound(
|
strip = scn.sequence_editor.sequences.new_sound(
|
||||||
name=filepath.stem,
|
name=filepath.stem,
|
||||||
filepath=str(filepath),
|
filepath=str(filepath),
|
||||||
channel=get_channel('Audio'),
|
channel=get_channel_index('Audio'),
|
||||||
frame_start=scn.frame_start
|
frame_start=scn.frame_start
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -212,30 +256,52 @@ def clean_sequencer(edit=False, movie=False, sound=False):
|
||||||
scn.sequence_editor.sequences.remove(sequence)
|
scn.sequence_editor.sequences.remove(sequence)
|
||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
def get_active_strip(scene):
|
def set_active_strip(scene):
|
||||||
scn = bpy.context.scene
|
#scn = bpy.context.scene
|
||||||
settings = get_scene_settings()
|
settings = get_scene_settings()
|
||||||
|
|
||||||
if settings.auto_select_strip == False:
|
if not settings.auto_select_strip:
|
||||||
return
|
return
|
||||||
|
|
||||||
screen = bpy.context.screen
|
|
||||||
|
|
||||||
bpy.ops.sequencer.select_all(action="DESELECT")
|
bpy.ops.sequencer.select_all(action="DESELECT")
|
||||||
|
#scene.sequence_editor.active_strip = None
|
||||||
|
|
||||||
strip = None
|
shot_strip = get_strip_at('Shots')
|
||||||
frame_current = scn.frame_current
|
if shot_strip:
|
||||||
|
shot_strip.select = True
|
||||||
|
scene.sequence_editor.active_strip = shot_strip
|
||||||
|
|
||||||
strips = bpy.context.sequences
|
@persistent
|
||||||
strips = sorted(strips,key=lambda x: (x.channel, x.frame_final_start))
|
def update_text_strips(scene):
|
||||||
|
#scn = bpy.context.scene
|
||||||
|
format_data = {
|
||||||
|
'scene': scene,
|
||||||
|
'active_shot_name': 'None',
|
||||||
|
'active_shot_frame': 0,
|
||||||
|
'active_shot_duration': 0,
|
||||||
|
'active_shot_start': 0,
|
||||||
|
'active_shot_end': 0
|
||||||
|
}
|
||||||
|
|
||||||
for strip in strips:
|
shot_strip = get_strip_at('Shots', frame=scene.frame_current)
|
||||||
#FIXME Pas propre de mettre le channel name en dur
|
if shot_strip:
|
||||||
if strip.channel != get_channel('Shots') or 0:
|
format_data.update({
|
||||||
|
'active_shot_name': shot_strip.name,
|
||||||
|
'active_shot_duration': shot_strip.frame_final_duration,
|
||||||
|
'active_shot_frame': scene.frame_current - shot_strip.frame_final_start + 1,
|
||||||
|
'active_shot_start': shot_strip.frame_final_start,
|
||||||
|
'active_shot_end': shot_strip.frame_final_end,
|
||||||
|
})
|
||||||
|
|
||||||
|
for strip in scene.sequence_editor.sequences_all:
|
||||||
|
if not strip.type == 'TEXT':
|
||||||
continue
|
continue
|
||||||
if (not strip.lock
|
|
||||||
and strip.frame_final_end >= frame_current
|
|
||||||
and strip.frame_final_start <= frame_current):
|
|
||||||
|
|
||||||
strip.select = True
|
if not is_strip_at(strip):
|
||||||
scn.sequence_editor.active_strip = strip
|
continue
|
||||||
|
|
||||||
|
if '{' in strip.text:
|
||||||
|
strip['text_pattern'] = strip.text
|
||||||
|
|
||||||
|
if 'text_pattern' in strip.keys():
|
||||||
|
strip.text = strip['text_pattern'].format(**format_data)
|
Loading…
Reference in New Issue