copy metadata

pull/5/head
“christopheseux” 2023-04-25 18:43:04 +02:00
parent ef4f8f527b
commit 5884d278da
4 changed files with 79 additions and 12 deletions

View File

@ -10,7 +10,12 @@ def get_scene_settings():
def get_strip_settings():
scn = bpy.context.scene
return scn.sequence_editor.active_strip.vsetb_strip_settings
strip = bpy.context.active_sequence_strip
if not strip:
return
return strip.vsetb_strip_settings
def get_bl_cmd(blender=None, background=False, focus=True, blendfile=None, script=None, **kargs):
cmd = [str(blender)] if blender else [bpy.app.binary_path]

View File

@ -57,6 +57,34 @@ class VSETB_OT_tracker_connect(Operator):
return {"CANCELLED"}
class VSETB_OT_copy_metadata(Operator):
bl_idname = "vse_toolbox.copy_metadata"
bl_label = "Copy metadata to selected"
bl_description = "Copy Metadata to selected strips"
metadata : StringProperty()
@classmethod
def poll(cls, context):
return context.selected_sequences and context.active_sequence_strip
def execute(self, context):
prefs = get_addon_prefs()
settings = get_scene_settings()
metadata = self.metadata.lower()
active_strip = context.active_sequence_strip
metadata_value = getattr(active_strip.vsetb_strip_settings.metadata, metadata)
for strip in context.selected_sequences:
if strip == context.active_sequence_strip:
continue
setattr(strip.vsetb_strip_settings.metadata, metadata, metadata_value)
return {"FINISHED"}
class VSETB_OT_export_spreadsheet(Operator):
bl_idname = "vse_toolbox.export_spreadsheet"
bl_label = "Export Spreadsheet"
@ -1218,16 +1246,18 @@ class VSETB_OT_paste_casting(Operator):
return {"CANCELLED"}
casting_datas = json.loads(CASTING_BUFFER.read_text())
for casting_item in casting_datas:
for strip in context.selected_sequences:
strip_settings = strip.vsetb_strip_settings
if strip_settings.casting.get(casting_item['name']):
continue
for strip in context.selected_sequences:
strip_settings = strip.vsetb_strip_settings
for casting_data in casting_datas:
item = strip.vsetb_strip_settings.casting.add()
for k, v in casting_item.items():
setattr(item, k, v)
item.name = casting_data['name']
item.id = casting_data['id']
item['_name'] = casting_data['_name']
strip_settings.casting.update()
@ -1376,7 +1406,8 @@ classes = (
VSETB_OT_tracker_connect,
VSETB_OT_set_stamps,
VSETB_OT_upload_to_tracker,
VSETB_OT_show_waveform
VSETB_OT_show_waveform,
VSETB_OT_copy_metadata
)
def register():

View File

@ -272,12 +272,13 @@ class VSETB_PT_metadata(VSETB_main, Panel):
if not project:
return
row = layout.row()
layout.prop(strip_settings, 'description', text='DESCRIPTION')
#col = layout.column()
for metadata_type in project.metadata_types:
if metadata_type.entity_type == 'SHOT':
row = layout.row(align=True)
row = layout.row(align=False)
metadata_key = metadata_type.field_name
if metadata_type.choices:
metadata_value = getattr(strip_settings.metadata, metadata_key)
@ -294,6 +295,25 @@ class VSETB_PT_metadata(VSETB_main, Panel):
else:
row.prop(strip_settings.metadata, metadata_key, text=metadata_key.upper())
#row.operator('vse_toolbox.copy_metadata', icon='PASTEDOWN', text='', emboss=False).metadata = metadata_key
def context_menu_prop(self, context):
if not hasattr(context, 'button_prop') or context.space_data.type != 'SEQUENCE_EDITOR':
return
settings = get_strip_settings()
if not settings:
return
button_prop = context.button_prop
if button_prop not in settings.metadata.bl_rna.properties.values():
return
layout = self.layout
layout.separator()
layout.operator('vse_toolbox.copy_metadata', icon='PASTEDOWN', text='Copy metadata to selected').metadata = button_prop.name
classes = (
VSETB_PT_main,
VSETB_PT_imports,
@ -307,7 +327,11 @@ classes = (
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.UI_MT_button_context_menu.append(context_menu_prop)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)
bpy.utils.unregister_class(cls)
bpy.types.UI_MT_button_context_menu.remove(context_menu_prop)

View File

@ -62,6 +62,7 @@ def get_tracker_items(self, context):
class CollectionPropertyGroup(PropertyGroup):
def __iter__(self):
return (v for v in self.values())
def props(self):
return [p for p in self.bl_rna.properties if p.identifier not in ('rna_type', 'name')]
@ -118,6 +119,12 @@ class AssetCasting(PropertyGroup):
project = settings.active_project
return project.assets.get(self.id)
def to_dict(self):
return {'id': self.id,
'instance': self.instance,
'name': self.asset.name if self.asset else None,
'_name': self.get('_name')
}
class SpreadsheetCell(PropertyGroup):
export_name : StringProperty()