add template
parent
1ff1b37adb
commit
87614f9895
|
@ -36,6 +36,9 @@ if 'bpy' in locals():
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
|
print('Register update script handler')
|
||||||
|
bpy.app.handlers.frame_change_post.append(update_text_strips)
|
||||||
|
|
||||||
if bpy.app.background:
|
if bpy.app.background:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -43,10 +46,12 @@ def register():
|
||||||
module.register()
|
module.register()
|
||||||
|
|
||||||
bpy.app.handlers.frame_change_post.append(set_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():
|
||||||
|
bpy.app.handlers.frame_change_post.remove(update_text_strips)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
bpy.utils.previews.remove(ASSET_PREVIEWS)
|
bpy.utils.previews.remove(ASSET_PREVIEWS)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -58,8 +63,6 @@ def unregister():
|
||||||
return
|
return
|
||||||
|
|
||||||
bpy.app.handlers.frame_change_post.remove(set_active_strip)
|
bpy.app.handlers.frame_change_post.remove(set_active_strip)
|
||||||
bpy.app.handlers.frame_change_post.remove(update_text_strips)
|
|
||||||
|
|
||||||
for module in reversed(modules):
|
for module in reversed(modules):
|
||||||
module.unregister()
|
module.unregister()
|
||||||
|
|
||||||
|
|
|
@ -141,3 +141,12 @@ def open_file(filepath, env=None, select=False):
|
||||||
cmd += [str(filepath)]
|
cmd += [str(filepath)]
|
||||||
|
|
||||||
subprocess.Popen(cmd, env=env)
|
subprocess.Popen(cmd, env=env)
|
||||||
|
|
||||||
|
def parse(string, template):
|
||||||
|
template = re.sub(r'{index:(.+?)}', r'(?P<index>.+)', template)
|
||||||
|
reg = re.sub(r'{(.+?)}', r'(?P<_\1>.+)', template)
|
||||||
|
|
||||||
|
values = list(re.search(reg, string).groups())
|
||||||
|
keys = re.findall(r'{(.+?)}', template) + ['index']
|
||||||
|
|
||||||
|
return dict(zip(keys, values))
|
||||||
|
|
|
@ -4,7 +4,7 @@ from bpy.types import Operator
|
||||||
from bpy.props import (BoolProperty, StringProperty)
|
from bpy.props import (BoolProperty, StringProperty)
|
||||||
|
|
||||||
from vse_toolbox.sequencer_utils import (get_strips, rename_strips, set_channels,
|
from vse_toolbox.sequencer_utils import (get_strips, rename_strips, set_channels,
|
||||||
get_channel_index, new_text_strip)
|
get_channel_index, new_text_strip, get_strip_at)
|
||||||
|
|
||||||
from vse_toolbox.bl_utils import get_scene_settings
|
from vse_toolbox.bl_utils import get_scene_settings
|
||||||
|
|
||||||
|
@ -212,17 +212,105 @@ class VSETB_OT_set_stamps(Operator):
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class VSETB_OT_previous_shot(Operator):
|
||||||
|
bl_idname = "vse_toolbox.previous_shot"
|
||||||
|
bl_label = "Jump to Previous Shot"
|
||||||
|
bl_description = "Jump to Previous Shot"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
strips = get_strips('Shots')
|
||||||
|
if not strips:
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
active_strip = get_strip_at('Shots')
|
||||||
|
if active_strip is strips[0]:
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
active_strip_index = strips.index(active_strip)
|
||||||
|
next_shot = strips[active_strip_index - 1]
|
||||||
|
context.scene.frame_set(next_shot.frame_final_start)
|
||||||
|
|
||||||
|
bpy.ops.sequencer.select_all(action="DESELECT")
|
||||||
|
next_shot.select = True
|
||||||
|
context.scene.sequence_editor.active_strip = next_shot
|
||||||
|
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class VSETB_OT_next_shot(Operator):
|
||||||
|
bl_idname = "vse_toolbox.next_shot"
|
||||||
|
bl_label = "Jump to Next Shot"
|
||||||
|
bl_description = "Jump to Next Shot"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
|
||||||
|
strips = get_strips('Shots')
|
||||||
|
if not strips:
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
active_strip = get_strip_at('Shots')
|
||||||
|
if active_strip is strips[-1]:
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
active_strip_index = strips.index(active_strip)
|
||||||
|
next_shot = strips[active_strip_index + 1]
|
||||||
|
context.scene.frame_set(next_shot.frame_final_start)
|
||||||
|
|
||||||
|
bpy.ops.sequencer.select_all(action="DESELECT")
|
||||||
|
next_shot.select = True
|
||||||
|
context.scene.sequence_editor.active_strip = next_shot
|
||||||
|
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
addon_keymaps = []
|
||||||
|
def register_keymaps():
|
||||||
|
addon = bpy.context.window_manager.keyconfigs.addon
|
||||||
|
|
||||||
|
if not addon:
|
||||||
|
return
|
||||||
|
|
||||||
|
#print('VSE Toolbox Keymaps Register')
|
||||||
|
|
||||||
|
km = addon.keymaps.new(name="Sequencer", space_type="SEQUENCE_EDITOR")
|
||||||
|
|
||||||
|
kmi = km.keymap_items.new('vse_toolbox.previous_shot', type='LEFT_ARROW', value='PRESS', ctrl=True)
|
||||||
|
addon_keymaps.append((km, kmi))
|
||||||
|
|
||||||
|
kmi = km.keymap_items.new('vse_toolbox.next_shot', type='RIGHT_ARROW', value='PRESS', ctrl=True)
|
||||||
|
addon_keymaps.append((km, kmi))
|
||||||
|
|
||||||
|
|
||||||
|
def unregister_keymaps():
|
||||||
|
#print('unregister_keymaps', addon_keymaps)
|
||||||
|
for km, kmi in addon_keymaps:
|
||||||
|
if kmi in list(km.keymap_items):
|
||||||
|
km.keymap_items.remove(kmi)
|
||||||
|
|
||||||
|
addon_keymaps.clear()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
VSETB_OT_rename,
|
VSETB_OT_rename,
|
||||||
VSETB_OT_set_sequencer,
|
VSETB_OT_set_sequencer,
|
||||||
VSETB_OT_set_stamps,
|
VSETB_OT_set_stamps,
|
||||||
VSETB_OT_show_waveform,
|
VSETB_OT_show_waveform,
|
||||||
|
VSETB_OT_previous_shot,
|
||||||
|
VSETB_OT_next_shot
|
||||||
)
|
)
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
for cls in classes:
|
for cls in classes:
|
||||||
bpy.utils.register_class(cls)
|
bpy.utils.register_class(cls)
|
||||||
|
|
||||||
|
register_keymaps()
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
for cls in reversed(classes):
|
for cls in reversed(classes):
|
||||||
bpy.utils.unregister_class(cls)
|
bpy.utils.unregister_class(cls)
|
||||||
|
|
||||||
|
unregister_keymaps()
|
||||||
|
|
|
@ -286,6 +286,7 @@ class VSETB_OT_upload_to_tracker(Operator):
|
||||||
col.separator()
|
col.separator()
|
||||||
col.prop(self, 'casting', text='Casting')
|
col.prop(self, 'casting', text='Casting')
|
||||||
col.prop(self, 'custom_data', text='Custom Data')
|
col.prop(self, 'custom_data', text='Custom Data')
|
||||||
|
col.prop(self, 'set_main_preview', text='Set Main Preview')
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
#self.report({'ERROR'}, f'Export not implemented yet.')
|
#self.report({'ERROR'}, f'Export not implemented yet.')
|
||||||
|
@ -345,6 +346,7 @@ class VSETB_OT_upload_to_tracker(Operator):
|
||||||
if status or preview:
|
if status or preview:
|
||||||
tracker.new_comment(task, comment=self.comment, status=status, preview=preview, set_main_preview=self.set_main_preview)
|
tracker.new_comment(task, comment=self.comment, status=status, preview=preview, set_main_preview=self.set_main_preview)
|
||||||
|
|
||||||
|
|
||||||
if self.custom_data:
|
if self.custom_data:
|
||||||
metadata = strip.vsetb_strip_settings.metadata.to_dict()
|
metadata = strip.vsetb_strip_settings.metadata.to_dict()
|
||||||
description = strip.vsetb_strip_settings.description
|
description = strip.vsetb_strip_settings.description
|
||||||
|
|
|
@ -8,7 +8,7 @@ import bpy
|
||||||
from bpy.app.handlers import persistent
|
from bpy.app.handlers import persistent
|
||||||
|
|
||||||
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.file_utils import install_module
|
from vse_toolbox.file_utils import install_module, parse
|
||||||
from vse_toolbox.constants import SOUND_SUFFIXES
|
from vse_toolbox.constants import SOUND_SUFFIXES
|
||||||
#import multiprocessing
|
#import multiprocessing
|
||||||
#from multiprocessing.pool import ThreadPool
|
#from multiprocessing.pool import ThreadPool
|
||||||
|
@ -130,8 +130,21 @@ def set_channels():
|
||||||
|
|
||||||
def get_strip_render_path(strip, template):
|
def get_strip_render_path(strip, template):
|
||||||
scn = bpy.context.scene
|
scn = bpy.context.scene
|
||||||
|
settings = get_scene_settings()
|
||||||
|
project = settings.active_project
|
||||||
|
|
||||||
suffix = Path(scn.render.frame_path()).suffix
|
suffix = Path(scn.render.frame_path()).suffix
|
||||||
render_path = template.format(strip_name=strip.name, ext=suffix[1:])
|
|
||||||
|
strip_data = parse(strip.name, template=project.shot_template)
|
||||||
|
|
||||||
|
print(strip_data)
|
||||||
|
|
||||||
|
index = int(strip_data['index'])
|
||||||
|
|
||||||
|
sequence = get_strip_sequence_name(strip)
|
||||||
|
render_path = template.format(episode=project.episode_name, sequence=sequence,
|
||||||
|
strip=strip.name, index=index, ext=suffix[1:])
|
||||||
|
|
||||||
return Path(os.path.abspath(bpy.path.abspath(render_path)))
|
return Path(os.path.abspath(bpy.path.abspath(render_path)))
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
@ -392,6 +405,9 @@ def set_active_strip(scene):
|
||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
def update_text_strips(scene):
|
def update_text_strips(scene):
|
||||||
|
|
||||||
|
print("update_text_strips")
|
||||||
|
|
||||||
scn = bpy.context.scene
|
scn = bpy.context.scene
|
||||||
if not scn.sequence_editor:
|
if not scn.sequence_editor:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue