export background

This commit is contained in:
“christopheseux”
2023-05-19 11:51:05 +02:00
parent 48dddb1905
commit beb85721a9
10 changed files with 416 additions and 120 deletions
+35 -9
View File
@@ -2,7 +2,7 @@
import json
import bpy
from bpy.types import PropertyGroup, Operator
from bpy.types import Context, Event, PropertyGroup, Operator
from bpy.props import (CollectionProperty, EnumProperty, StringProperty)
from vse_toolbox.constants import CASTING_BUFFER
@@ -249,15 +249,27 @@ class VSETB_OT_copy_casting(Operator):
class VSETB_OT_paste_casting(Operator):
bl_idname = "vse_toolbox.paste_casting"
bl_label = "Paste Casting"
bl_description = "Paste Casting to active strip"
bl_description = "Paste Casting to active strip (ctrl|shift: Add, alt:Remove)"
bl_options = {"REGISTER", "UNDO"}
mode : EnumProperty(items=[(m, m.title(), '') for m in ('REPLACE', 'ADD', 'REMOVE')])
@classmethod
def poll(cls, context):
active_strip = context.scene.sequence_editor.active_strip
if active_strip:
return True
def invoke(self, context, event):
self.mode = 'REPLACE'
if event.ctrl or event.shift:
self.mode = 'ADD'
elif event.alt:
self.mode = 'REMOVE'
return self.execute(context)
def execute(self, context):
scn = context.scene
strip_settings = get_strip_settings()
@@ -267,19 +279,33 @@ class VSETB_OT_paste_casting(Operator):
return {"CANCELLED"}
casting_datas = json.loads(CASTING_BUFFER.read_text())
casting_ids = set(c['id'] for c in casting_datas)
for strip in context.selected_sequences:
strip_settings = strip.vsetb_strip_settings
strip.vsetb_strip_settings.casting.clear()
if self.mode == 'REPLACE':
strip.vsetb_strip_settings.casting.clear()
for casting_data in casting_datas:
item = strip.vsetb_strip_settings.casting.add()
if self.mode == 'REMOVE':
for asset_casting in strip_settings.casting:
index = list(strip_settings.casting).index(asset_casting)
if asset_casting.id in casting_ids:
strip_settings.casting.remove(index)
item.name = casting_data['name']
item.id = casting_data['id']
item['_name'] = casting_data['_name']
if strip_settings.casting_index != 0:
strip_settings.casting_index -= 1
strip_settings.casting.update()
else:
item = strip.vsetb_strip_settings.casting.add()
item.name = casting_data['name']
item.id = casting_data['id']
item['_name'] = casting_data['_name']
strip_settings.casting.update()
return {"FINISHED"}