vse_toolbox/ui/properties.py

574 lines
18 KiB
Python
Raw Normal View History

2023-03-14 13:38:04 +01:00
# SPDX-License-Identifier: GPL-2.0-or-later
import bpy
import os
2023-04-22 15:42:38 +02:00
from pathlib import Path
2023-03-14 13:38:04 +01:00
from bpy.props import (
BoolProperty,
CollectionProperty,
EnumProperty,
IntProperty,
PointerProperty,
StringProperty,
)
2023-03-16 18:32:17 +01:00
from bpy.types import PropertyGroup, UIList
2023-03-14 13:38:04 +01:00
from pprint import pprint as pp
2023-03-21 18:33:29 +01:00
from vse_toolbox.bl_utils import get_addon_prefs, get_scene_settings
2023-04-22 15:42:38 +02:00
from vse_toolbox.constants import ASSET_PREVIEWS, TRACKERS, PREVIEWS_DIR
2023-03-14 13:38:04 +01:00
from vse_toolbox.file_utils import norm_str
2023-03-17 20:03:38 +01:00
2023-03-14 13:38:04 +01:00
def get_episodes_items(self, context):
2023-03-21 18:33:29 +01:00
settings = get_scene_settings()
2023-03-14 13:38:04 +01:00
project = settings.active_project
if not project:
2023-04-20 18:16:34 +02:00
return [('/', '/', '', 0)]
2023-03-14 13:38:04 +01:00
episodes = project.episodes
if not episodes:
2023-04-20 18:16:34 +02:00
return [('/', '/', '', 0)]
2023-03-14 13:38:04 +01:00
return [(e, e, '', i) for i, e in enumerate(episodes.keys())]
def get_project_items(self, context):
if not self.projects:
2023-04-20 18:16:34 +02:00
return [('/', '/', '', 0)]
2023-03-14 13:38:04 +01:00
return [(p, p, '', i) for i, p in enumerate(self.projects.keys())]
2023-04-14 18:55:00 +02:00
def on_project_updated(self, context):
2023-03-21 18:33:29 +01:00
settings = get_scene_settings()
2023-03-14 13:38:04 +01:00
settings['episodes'] = 0
2023-04-14 18:55:00 +02:00
2023-04-20 00:12:39 +02:00
#print('Update active Project')
2023-04-14 18:55:00 +02:00
bpy.ops.vse_toolbox.load_assets()
2023-04-14 19:02:50 +02:00
if settings.active_project:
settings.active_project.set_strip_metadata()
2023-03-14 13:38:04 +01:00
2023-04-20 00:12:39 +02:00
os.environ['TRACKER_PROJECT_ID'] = settings.active_project.id
2023-04-24 18:51:26 +02:00
def on_episode_updated(self, context):
settings = get_scene_settings()
2023-04-20 00:12:39 +02:00
os.environ['TRACKER_EPISODE_ID'] = settings.active_episode.id
2023-03-14 13:38:04 +01:00
def get_tracker_items(self, context):
2023-04-20 00:12:39 +02:00
return [(norm_str(a.__name__, format=str.upper), a.__name__, "", i) for i, a in enumerate(TRACKERS)]
2023-03-14 13:38:04 +01:00
2023-04-14 18:55:00 +02:00
2023-04-21 21:44:05 +02:00
class CollectionPropertyGroup(PropertyGroup):
def __iter__(self):
return (v for v in self.values())
2023-04-25 18:43:04 +02:00
2023-04-21 21:44:05 +02:00
def props(self):
return [p for p in self.bl_rna.properties if p.identifier not in ('rna_type', 'name')]
def keys(self):
return [k for k in self.bl_rna.properties.keys() if k not in ('rna_type', 'name')]
def values(self):
return [getattr(self, k) for k in self.keys()]
def items(self):
return self.to_dict().items()
def to_dict(self, use_name=True):
if use_name:
return {p.name: getattr(self, p.identifier) for p in self.props()}
else:
return {k: getattr(self, k) for k in self.keys()}
2023-04-22 15:42:38 +02:00
def get_preview_items(self, context):
if self.icon_id:
return [(self.preview, self.tracker_name, '', self.icon_id, 0)]
return []
2023-04-23 13:07:33 +02:00
2023-03-17 20:03:38 +01:00
class Asset(PropertyGroup):
2023-03-20 19:05:22 +01:00
name : StringProperty(default='')
2023-03-17 20:03:38 +01:00
id : StringProperty(default='')
2023-03-17 22:54:48 +01:00
norm_name : StringProperty(default='')
2023-03-17 20:03:38 +01:00
asset_type : StringProperty(default='')
2023-03-20 19:05:22 +01:00
tracker_name : StringProperty(default='')
preview : StringProperty(default='')
2023-04-22 15:42:38 +02:00
previews : EnumProperty(items=get_preview_items)
2023-03-21 18:33:29 +01:00
@property
def label(self):
2023-04-23 13:07:33 +02:00
return f"{self.asset_type} / {self.tracker_name}"
2023-03-17 20:03:38 +01:00
2023-03-21 18:33:29 +01:00
@property
def icon_id(self):
ico = ASSET_PREVIEWS.get(self.preview)
if ico:
return ico.icon_id
2023-03-17 20:03:38 +01:00
2023-03-21 10:22:17 +01:00
2023-03-21 18:33:29 +01:00
class AssetCasting(PropertyGroup):
id : StringProperty(default='')
2023-03-21 10:22:17 +01:00
instance : IntProperty(default=1)
2023-03-21 18:33:29 +01:00
@property
def asset(self):
settings = get_scene_settings()
project = settings.active_project
return project.assets.get(self.id)
2023-04-25 18:43:04 +02:00
def to_dict(self):
return {'id': self.id,
'instance': self.instance,
'name': self.asset.name if self.asset else None,
'_name': self.get('_name')
}
2023-04-21 21:44:05 +02:00
2023-04-04 12:21:45 +02:00
2023-04-14 18:55:00 +02:00
class AssetType(PropertyGroup):
__annotations__ = {}
2023-03-23 17:33:49 +01:00
2023-04-14 18:55:00 +02:00
class MetadataType(PropertyGroup):
2023-04-23 13:07:33 +02:00
#choices = []
choices : CollectionProperty(type=PropertyGroup)#EnumProperty(items=lambda s, c: [(c, c.replace(' ', '_').upper(), '') for c in s['choices']])
2023-04-22 15:42:38 +02:00
field_name : StringProperty()
entity_type : StringProperty()
2023-03-23 17:33:49 +01:00
2023-04-20 00:12:39 +02:00
class TaskType(PropertyGroup):
__annotations__ = {}
class TaskStatus(PropertyGroup):
__annotations__ = {}
2023-04-21 21:44:05 +02:00
class Metadata(CollectionPropertyGroup):
2023-04-14 18:55:00 +02:00
__annotations__ = {}
2023-03-23 17:33:49 +01:00
2023-03-21 10:22:17 +01:00
class Episode(PropertyGroup):
id : StringProperty(default='')
@property
def active(self):
2023-03-21 18:33:29 +01:00
settings = get_scene_settings()
2023-03-21 10:22:17 +01:00
return self.get(settings.project_name)
2023-03-17 20:03:38 +01:00
2023-04-22 21:12:21 +02:00
2023-05-04 18:45:17 +02:00
class SpreadsheetExportCell(PropertyGroup):
2023-05-02 18:38:16 +02:00
export_name : StringProperty()
enabled : BoolProperty(default=True)
field_name : StringProperty()
type : EnumProperty(items=[(t, t, "") for t in ('METADATA', 'SHOT', 'ASSET_TYPE')])
#sort : BoolProperty(default=True)
2023-05-04 18:45:17 +02:00
def get_cell_items(self, context):
settings = get_scene_settings()
project = settings.active_project
2023-05-05 09:46:50 +02:00
return [(cell, cell, '') for cell in project.get_cell_types().keys()]
2023-05-04 18:45:17 +02:00
class SpreadsheetImportCell(PropertyGroup):
enabled : BoolProperty(default=True)
import_name : EnumProperty(items=get_cell_items)
2023-05-05 09:46:50 +02:00
#type : EnumProperty(items=[(t, t, "") for t in ('METADATA', 'SHOT', 'ASSET_TYPE')])
2023-05-04 18:45:17 +02:00
2023-04-22 21:12:21 +02:00
def get_custom_name_items(self, context):
settings = get_scene_settings()
project = settings.active_project
return [(m.field_name, m.name, '') for m in project.metadata_types if m.entity_type=='ASSET']
2023-05-02 20:46:45 +02:00
class SpreadsheetExport(PropertyGroup):
2023-05-04 14:55:53 +02:00
use_custom_cells: BoolProperty(default=False)
2023-04-22 21:12:21 +02:00
format : EnumProperty(items=[(i, i, '') for i in ('CSV', 'XLSX')])
separator : StringProperty(default='\\n')
delimiter : StringProperty(default=';')
export_path : StringProperty(default='//export')
use_custom_name : BoolProperty(default=False)
custom_name : EnumProperty(items=get_custom_name_items,
description='Use a custom name for asset using a metadata value')
open_folder : BoolProperty(default=False)
show_settings : BoolProperty(default=False)
2023-05-04 18:45:17 +02:00
cells: CollectionProperty(type=SpreadsheetExportCell)
2023-05-02 18:38:16 +02:00
cell_index : IntProperty(name='Spreadsheet Index', default=0)
2023-03-17 20:03:38 +01:00
2023-04-25 15:30:05 +02:00
2023-05-02 20:46:45 +02:00
class SpreadsheetImport(PropertyGroup):
2023-05-05 09:46:50 +02:00
#use_custom_cells: BoolProperty(default=False)
2023-05-02 20:46:45 +02:00
separator : StringProperty(default='\\n')
delimiter : StringProperty(default=';')
use_custom_name : BoolProperty(default=False)
custom_name : EnumProperty(items=get_custom_name_items,
description='Use a custom name for asset using a metadata value')
2023-05-04 18:45:17 +02:00
cells: CollectionProperty(type=SpreadsheetImportCell)
2023-05-02 20:46:45 +02:00
cell_index : IntProperty(name='Spreadsheet Index', default=0)
2023-05-04 18:45:17 +02:00
import_casting: BoolProperty(default=True)
import_custom_data: BoolProperty(default=True)
update_edit: BoolProperty(default=True)
2023-05-02 20:46:45 +02:00
2023-03-14 13:38:04 +01:00
class Project(PropertyGroup):
id : StringProperty(default='')
2023-04-14 18:55:00 +02:00
shot_start_number : IntProperty(name="Shot Start Number", default=10, min=0)
sequence_start_number : IntProperty(name="Sequence Start Number", default=10, min=0)
2023-04-25 10:29:02 +02:00
reset_by_sequence : BoolProperty(
name="Reset By Sequence",
description="Reset Start Number for each sequence",
default=False
)
2023-03-14 13:38:04 +01:00
sequence_increment : IntProperty(
name="Sequence Increment", default=10, min=0, step=10)
shot_increment : IntProperty(
name="Shot Increment", default=10, min=0, step=10)
sequence_template : StringProperty(
name="Sequence Name", default="sq{index:03d}")
episode_template : StringProperty(
2023-04-14 18:55:00 +02:00
name="Episode Name", default="ep{index:03d}")
2023-03-14 13:38:04 +01:00
shot_template : StringProperty(
2023-04-14 18:55:00 +02:00
name="Shot Name", default="{sequence}_sh{index:04d}")
2023-03-14 13:38:04 +01:00
2023-04-20 00:12:39 +02:00
render_template : StringProperty(
name="Render Name", default="//render/{strip_name}.{ext}")
episode_name : EnumProperty(items=get_episodes_items, update=on_episode_updated)
2023-03-14 13:38:04 +01:00
episodes : CollectionProperty(type=Episode)
2023-03-17 20:03:38 +01:00
assets : CollectionProperty(type=Asset)
2023-04-14 18:55:00 +02:00
asset_types : CollectionProperty(type=AssetType)
metadata_types : CollectionProperty(type=MetadataType)
2023-04-20 00:12:39 +02:00
task_types : CollectionProperty(type=TaskType)
task_statuses : CollectionProperty(type=TaskStatus)
2023-05-02 20:46:45 +02:00
spreadsheet_import: PointerProperty(type=SpreadsheetImport)
spreadsheet_export: PointerProperty(type=SpreadsheetExport)
2023-04-21 21:44:05 +02:00
2023-04-14 18:55:00 +02:00
type : StringProperty()
2023-05-05 09:46:50 +02:00
def get_cell_types(self):
2023-05-04 18:45:17 +02:00
settings = get_scene_settings()
project = settings.active_project
2023-05-05 09:46:50 +02:00
cell_types = {}
2023-05-08 18:25:04 +02:00
cell_names = ['Sequence', 'Shot', 'Nb Frames', 'Description']
2023-05-04 18:45:17 +02:00
if project.type == 'TVSHOW':
cell_names.insert(0, 'Episode')
2023-05-05 09:46:50 +02:00
cell_types = {cell_name: 'SHOT' for cell_name in cell_names}
2023-05-04 18:45:17 +02:00
for metadata_type in project.metadata_types:
if metadata_type['entity_type'] == "SHOT":
2023-05-05 09:46:50 +02:00
cell_types[metadata_type.name] = 'METADATA'
2023-05-04 18:45:17 +02:00
for asset_type in project.asset_types:
2023-05-05 09:46:50 +02:00
cell_types[asset_type.name] = 'ASSET_TYPE'
2023-05-04 18:45:17 +02:00
2023-05-05 09:46:50 +02:00
return cell_types
2023-05-04 18:45:17 +02:00
2023-04-21 21:44:05 +02:00
def set_spreadsheet(self):
2023-05-02 20:46:45 +02:00
2023-05-08 18:25:04 +02:00
cell_names = ['Sequence', 'Shot', 'Nb Frames', 'Description']
2023-04-21 21:44:05 +02:00
if self.type == 'TVSHOW':
cell_names.insert(0, 'Episode')
2023-05-04 18:45:17 +02:00
# Export SpreadSheet
spreadsheet = self.spreadsheet_export
2023-04-21 21:44:05 +02:00
for cell_name in cell_names:
2023-05-02 20:46:45 +02:00
cell = spreadsheet.cells.add()
2023-04-21 21:44:05 +02:00
cell.name = cell_name
2023-04-22 15:42:38 +02:00
cell.export_name = 'Name' if cell_name == 'Shot' else cell_name
2023-04-21 21:44:05 +02:00
cell.field_name = cell_name.upper()
2023-04-22 15:42:38 +02:00
cell.type = "SHOT"
2023-04-21 21:44:05 +02:00
for metadata_type in self.metadata_types:
2023-04-22 15:42:38 +02:00
if not metadata_type['entity_type'] == "SHOT":
continue
2023-05-02 20:46:45 +02:00
cell = spreadsheet.cells.add()
2023-04-21 21:44:05 +02:00
cell.name = metadata_type.name
cell.export_name = metadata_type.name
cell.field_name = metadata_type.field_name
2023-04-22 15:42:38 +02:00
cell.type = "METADATA"
for asset_type in self.asset_types:
2023-05-02 20:46:45 +02:00
cell = spreadsheet.cells.add()
2023-04-22 15:42:38 +02:00
cell.name = asset_type.name
cell.export_name = asset_type.name
cell.field_name = asset_type.name.upper()
cell.type = "ASSET_TYPE"
2023-04-21 21:44:05 +02:00
2023-04-14 19:02:50 +02:00
def set_strip_metadata(self):
# Clear Metadatas
for attr in list(Metadata.__annotations__.keys()):
if hasattr(Metadata, attr):
delattr(Metadata, attr)
del Metadata.__annotations__[attr]
2023-04-14 18:55:00 +02:00
for metadata_type in self.metadata_types:
2023-04-24 18:51:26 +02:00
if not metadata_type.entity_type == "SHOT":
2023-04-22 15:42:38 +02:00
continue
2023-04-21 21:44:05 +02:00
field_name = metadata_type.field_name
name = metadata_type.name
2023-04-23 13:07:33 +02:00
#if metadata_type.get('choices'):
# prop = #bpy.props.EnumProperty(items=[(c, c, '') for c in ['/'] + metadata_type['choices']], name=name)
#else:
# prop = #bpy.props.StringProperty(name=name)
prop = bpy.props.StringProperty(name=name)
2023-04-14 18:55:00 +02:00
2023-04-21 21:44:05 +02:00
Metadata.__annotations__[field_name] = prop
setattr(Metadata, field_name, prop)
2023-03-14 13:38:04 +01:00
2023-03-17 20:03:38 +01:00
class VSETB_UL_casting(UIList):
2023-03-16 18:32:17 +01:00
2023-03-20 19:05:22 +01:00
order_by_type : BoolProperty(default=False)
2023-03-16 18:32:17 +01:00
2023-03-17 20:03:38 +01:00
def draw_item(self, context, layout, data, item, icon, active_data,
active_propname, index):
2023-03-16 18:32:17 +01:00
2023-03-21 18:33:29 +01:00
settings = get_scene_settings()
2023-03-17 20:03:38 +01:00
project = settings.active_project
2023-03-23 17:33:49 +01:00
2023-03-21 18:33:29 +01:00
asset = item.asset
if asset is None:
2023-04-14 18:55:00 +02:00
layout.label(text=f'Asset not Found ({item.get("_name", "...")})')
2023-03-23 17:33:49 +01:00
return
2023-03-21 18:33:29 +01:00
icon_id = asset.icon_id
params = {'icon_value': icon_id} if icon_id else {'icon': 'BLANK1'}
2023-03-20 19:05:22 +01:00
2023-03-17 20:03:38 +01:00
# Make sure your code supports all 3 layout types
if self.layout_type in {'DEFAULT', 'COMPACT'}:
2023-03-20 19:05:22 +01:00
layout.label(**params)
2023-03-21 10:22:17 +01:00
split = layout.split(factor=0.6)
2023-03-21 18:33:29 +01:00
split.label(text=f"{asset.norm_name.title()}")
split.label(text=f"{asset.asset_type.title()}")
2023-04-22 15:42:38 +02:00
sub = layout.row(align=True)
sub.alignment = 'RIGHT'
sub.prop(item, 'instance', text='')
2023-03-17 20:03:38 +01:00
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
layout.label(text="")
2023-03-16 18:32:17 +01:00
2023-03-17 22:54:48 +01:00
def draw_filter(self, context, layout):
row = layout.row()
subrow = row.row(align=True)
subrow.prop(self, "filter_name", text="")
subrow.prop(self, "use_filter_invert", text="", icon='ARROW_LEFTRIGHT')
subrow.separator()
subrow.prop(self, "order_by_type", text="Order by Type", icon='MESH_DATA')
2023-03-16 18:32:17 +01:00
2023-03-17 22:54:48 +01:00
def filter_items(self, context, data, propname):
"""Filter and order items in the list."""
helper_funcs = bpy.types.UI_UL_list
filtered = []
ordered = []
items = getattr(data, propname)
# Filtering by name
if self.filter_name:
filtered = helper_funcs.filter_items_by_name(self.filter_name, self.bitflag_filter_item, items, "name",
reverse=self.use_filter_sort_alpha)
# Order by types
if self.order_by_type:
2023-03-21 18:33:29 +01:00
_sort = [(idx, casting_item) for idx, casting_item in enumerate(items)]
2023-03-17 22:54:48 +01:00
sort_items = helper_funcs.sort_items_helper
2023-03-21 18:33:29 +01:00
ordered = sort_items(_sort, lambda x: x[1].asset.label)
2023-03-17 22:54:48 +01:00
return filtered, ordered
2023-04-21 21:44:05 +02:00
2023-05-04 18:45:17 +02:00
class VSETB_UL_spreadsheet_import(UIList):
2023-04-21 21:44:05 +02:00
def draw_item(self, context, layout, data, item, icon, active_data,
active_propname, index):
settings = get_scene_settings()
project = settings.active_project
layout.use_property_split = True
layout.use_property_decorate = False
2023-05-05 09:46:50 +02:00
item_type = project.get_cell_types()[item.import_name]
enabled = True
if item_type == 'METADATA' and not project.spreadsheet_import.import_custom_data:
enabled = False
elif item_type == 'ASSET_TYPE' and not project.spreadsheet_import.import_casting:
enabled = False
2023-05-08 18:25:04 +02:00
elif item.import_name == 'Nb Frames' and not project.spreadsheet_import.update_edit:
2023-05-05 09:46:50 +02:00
enabled = False
layout.enabled = enabled
2023-04-21 21:44:05 +02:00
row = layout.row(align=True)
row.alignment = 'LEFT'
row.prop(item, 'enabled', text='')
2023-05-05 09:46:50 +02:00
row = layout.row(align=True)
row.enabled = item.enabled
row.label(text=item.name)
row.prop(item, 'import_name', text='')
2023-04-21 21:44:05 +02:00
2023-05-04 18:45:17 +02:00
class VSETB_UL_spreadsheet_export(UIList):
def draw_item(self, context, layout, data, item, icon, active_data,
active_propname, index):
settings = get_scene_settings()
project = settings.active_project
layout.use_property_split = True
layout.use_property_decorate = False
row = layout.row(align=True)
row.alignment = 'LEFT'
row.prop(item, 'enabled', text='')
layout.label(text=item.name)
layout.prop(item, 'export_name', text='')
2023-04-21 21:44:05 +02:00
2023-03-17 22:54:48 +01:00
2023-03-21 18:33:29 +01:00
class VSETB_PGT_scene_settings(PropertyGroup):
2023-03-14 13:38:04 +01:00
projects : CollectionProperty(type=Project)
2023-04-14 18:55:00 +02:00
project_name : EnumProperty(items=get_project_items, update=on_project_updated)
2023-03-14 13:38:04 +01:00
tracker_name : EnumProperty(items=get_tracker_items)
2023-03-23 17:33:49 +01:00
toogle_prefs : BoolProperty(
description='Toogle VSE ToolBox Preferences', default=True)
2023-03-17 20:03:38 +01:00
auto_select_strip : BoolProperty(
name='Auto Select Strip',description='Auto select strip', default=True)
2023-03-23 17:33:49 +01:00
2023-03-16 18:32:17 +01:00
channel : EnumProperty(
2023-03-14 13:38:04 +01:00
items=[
('AUDIO', 'Audio', '', 0),
('MOVIE', 'Movie', '', 1),
('SHOTS', 'Shots', '', 2),
('SEQUENCES', 'Sequences', '', 3),
2023-04-14 18:55:00 +02:00
('STAMPS', 'Sequences', '', 4),
2023-03-14 13:38:04 +01:00
]
)
sequence_channel_name : StringProperty(
name="Sequences Channel Name", default="Sequences")
2023-03-23 17:33:49 +01:00
2023-03-14 13:38:04 +01:00
shot_channel_name : StringProperty(
name="Shot Channel Name", default="Shots")
@property
def active_project(self):
2023-03-21 18:33:29 +01:00
settings = get_scene_settings()
2023-03-14 13:38:04 +01:00
return settings.projects.get(settings.project_name)
@property
def active_episode(self):
project = self.active_project
if project:
return project.episodes.get(project.episode_name)
2023-04-14 18:55:00 +02:00
2023-03-14 13:38:04 +01:00
2023-03-21 18:33:29 +01:00
class VSETB_PGT_strip_settings(PropertyGroup):
casting : CollectionProperty(type=AssetCasting)
casting_index : IntProperty(name='Casting Index', default=0)
source_name : StringProperty(name='')
2023-04-14 18:55:00 +02:00
metadata : PointerProperty(type=Metadata)
2023-04-21 21:44:05 +02:00
description : StringProperty()
2023-03-23 17:33:49 +01:00
2023-05-09 18:25:41 +02:00
@property
def active_casting(self):
2023-05-11 11:12:23 +02:00
try:
self.casting[self.casting_index]
except KeyError:
return
2023-03-16 18:32:17 +01:00
2023-04-24 18:51:26 +02:00
classes = (
2023-03-17 20:03:38 +01:00
Asset,
2023-03-23 17:33:49 +01:00
AssetCasting,
2023-05-04 18:45:17 +02:00
SpreadsheetImportCell,
SpreadsheetExportCell,
2023-04-14 18:55:00 +02:00
AssetType,
2023-04-20 00:12:39 +02:00
TaskStatus,
2023-03-14 13:38:04 +01:00
Episode,
2023-04-14 18:55:00 +02:00
Metadata,
MetadataType,
2023-04-20 00:12:39 +02:00
TaskType,
2023-05-02 20:46:45 +02:00
SpreadsheetImport,
SpreadsheetExport,
2023-03-14 13:38:04 +01:00
Project,
2023-05-04 18:45:17 +02:00
VSETB_UL_spreadsheet_import,
VSETB_UL_spreadsheet_export,
2023-03-17 20:03:38 +01:00
VSETB_UL_casting,
2023-03-21 18:33:29 +01:00
VSETB_PGT_scene_settings,
VSETB_PGT_strip_settings,
2023-03-14 13:38:04 +01:00
)
2023-04-14 18:55:00 +02:00
from bpy.app.handlers import persistent
2023-04-24 18:51:26 +02:00
2023-04-14 18:55:00 +02:00
@persistent
def load_handler(dummy):
settings = get_scene_settings()
2023-04-22 15:42:38 +02:00
project = settings.active_project
if project:
project.set_strip_metadata()
2023-04-21 21:44:05 +02:00
#settings.active_project.set_spreadsheet()
2023-04-20 00:12:39 +02:00
os.environ['TRACKER_PROJECT_ID'] = settings.active_project.id
2023-04-14 18:55:00 +02:00
2023-04-22 15:42:38 +02:00
for asset in project.assets:
preview_id = asset.preview
preview_path = Path(PREVIEWS_DIR / project.id / preview_id).with_suffix('.png')
if preview_path.exists() and preview_id not in ASSET_PREVIEWS:
ASSET_PREVIEWS.load(preview_id, preview_path.as_posix(), 'IMAGE', True)
2023-04-23 13:07:33 +02:00
2023-04-22 15:42:38 +02:00
2023-03-14 13:38:04 +01:00
def register():
for cls in classes:
bpy.utils.register_class(cls)
2023-03-21 18:33:29 +01:00
bpy.types.Scene.vsetb_settings = PointerProperty(type=VSETB_PGT_scene_settings)
bpy.types.Sequence.vsetb_strip_settings = PointerProperty(type=VSETB_PGT_strip_settings)
2023-04-14 18:55:00 +02:00
#load_metadata_types()
bpy.app.handlers.load_post.append(load_handler)
2023-03-14 13:38:04 +01:00
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)
2023-03-21 18:33:29 +01:00
del bpy.types.Sequence.vsetb_strip_settings
del bpy.types.Scene.vsetb_settings
2023-04-14 18:55:00 +02:00
bpy.app.handlers.load_post.remove(load_handler)