load env prefs
parent
566e734a1a
commit
8f7cff2db0
|
@ -29,7 +29,7 @@ from vse_toolbox.sequencer_utils import (clean_sequencer, get_strips, set_active
|
||||||
get_channel_index, new_text_strip, get_strip_render_path, get_strip_sequence_name)
|
get_channel_index, new_text_strip, get_strip_render_path, get_strip_sequence_name)
|
||||||
|
|
||||||
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, open_file)
|
from vse_toolbox.file_utils import (install_module, norm_name, norm_str, open_file, read_file)
|
||||||
|
|
||||||
|
|
||||||
class VSETB_OT_tracker_connect(Operator):
|
class VSETB_OT_tracker_connect(Operator):
|
||||||
|
@ -643,11 +643,10 @@ class VSETB_OT_load_projects(Operator):
|
||||||
project.set_spreadsheet()
|
project.set_spreadsheet()
|
||||||
|
|
||||||
for project in settings.projects:
|
for project in settings.projects:
|
||||||
#print(project.name, project.name.replace(' ', '_').upper(), old_project_name)
|
|
||||||
if project.name.replace(' ', '_').upper() == old_project_name:
|
if project.name.replace(' ', '_').upper() == old_project_name:
|
||||||
|
|
||||||
#print('Restore Project Name')
|
|
||||||
settings.project_name = project.name
|
settings.project_name = project.name
|
||||||
|
|
||||||
|
load_settings()
|
||||||
#else:
|
#else:
|
||||||
# print('Could Not restore Project Name')
|
# print('Could Not restore Project Name')
|
||||||
|
|
||||||
|
@ -737,7 +736,8 @@ class VSETB_OT_rename(Operator):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return True
|
settings = get_scene_settings()
|
||||||
|
return settings.active_project
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
scn = context.scene
|
scn = context.scene
|
||||||
|
@ -746,32 +746,45 @@ class VSETB_OT_rename(Operator):
|
||||||
return context.window_manager.invoke_props_dialog(self)
|
return context.window_manager.invoke_props_dialog(self)
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
scn = context.scene
|
scn = context.scene
|
||||||
settings = get_scene_settings()
|
settings = get_scene_settings()
|
||||||
|
project = settings.active_project
|
||||||
|
|
||||||
layout = self.layout
|
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
col.use_property_split = True
|
col.use_property_split = True
|
||||||
|
col.use_property_decorate = False
|
||||||
|
|
||||||
if self.channel_name == 'Shots':
|
if self.channel_name == 'Shots':
|
||||||
col.prop(settings, 'shot_template')
|
col.prop(project, 'shot_template', text='Shot Name')
|
||||||
col.prop(settings, 'shot_start_number')
|
col.prop(project, 'shot_start_number', text='Start Number')
|
||||||
col.prop(settings, 'reset_by_sequence')
|
col.prop(project, 'shot_increment', text='Increment')
|
||||||
elif self.channel_name == 'Shots':
|
col.prop(project, 'reset_by_sequence')
|
||||||
col.prop(settings, 'sequence_template')
|
elif self.channel_name == 'Sequences':
|
||||||
col.prop(settings, 'sequence_start_number')
|
col.prop(project, 'sequence_template' ,text='Sequence Name')
|
||||||
|
col.prop(project, 'sequence_start_number', text='Start Number')
|
||||||
|
col.prop(project, 'sequence_increment', text='Increment')
|
||||||
|
|
||||||
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)
|
settings = get_scene_settings()
|
||||||
strips = get_strips(channel=self.channel_name, selected_only=self.selected_only)
|
project = settings.active_project
|
||||||
|
|
||||||
rename_strips(
|
strips = get_strips(channel=self.channel_name, selected_only=self.selected_only)
|
||||||
strips, self.template,
|
if self.channel_name == 'Shots':
|
||||||
increment=self.increment, start_number=self.start_number,
|
rename_strips(strips,
|
||||||
by_sequence=self.by_sequence
|
template=project.shot_template,
|
||||||
)
|
increment=project.shot_increment, start_number=project.shot_start_number,
|
||||||
|
by_sequence=project.reset_by_sequence
|
||||||
|
)
|
||||||
|
|
||||||
|
if self.channel_name == 'Sequences':
|
||||||
|
rename_strips(strips,
|
||||||
|
template=project.sequence_template,
|
||||||
|
increment=project.sequence_increment, start_number=project.sequence_start_number
|
||||||
|
)
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
@ -1279,6 +1292,63 @@ class VSETB_OT_set_stamps(Operator):
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
def load_settings():
|
||||||
|
prefs = get_addon_prefs()
|
||||||
|
settings = get_scene_settings()
|
||||||
|
project = settings.active_project
|
||||||
|
|
||||||
|
prefs_config_file = prefs.config_path
|
||||||
|
|
||||||
|
if not prefs_config_file:
|
||||||
|
return
|
||||||
|
|
||||||
|
prefs_datas = read_file(os.path.expandvars(prefs_config_file))
|
||||||
|
|
||||||
|
prefs_datas['trackers'] = prefs_datas.get('trackers')
|
||||||
|
prefs_datas['spreadsheet'] = prefs_datas.get('spreadsheet')
|
||||||
|
|
||||||
|
#print(prefs_datas)
|
||||||
|
trackers = prefs_datas.pop('trackers')
|
||||||
|
spreadsheet = prefs_datas.pop('spreadsheet')
|
||||||
|
|
||||||
|
project_name = prefs_datas.get('project_name')
|
||||||
|
if project_name:
|
||||||
|
settings.project_name = project_name
|
||||||
|
|
||||||
|
# Project Properties
|
||||||
|
for k, v in prefs_datas.items():
|
||||||
|
try:
|
||||||
|
setattr(project, k, v)
|
||||||
|
except Exception:
|
||||||
|
print(f'Could not set property {k} with value {v} to project {settings.project_name}')
|
||||||
|
|
||||||
|
if spreadsheet.get('cells'):
|
||||||
|
#project.spreadsheet.clear()
|
||||||
|
|
||||||
|
for i, cell_data in enumerate(spreadsheet['cells']):
|
||||||
|
if not 'name' in cell_data:
|
||||||
|
print(f'cell_data {cell_data} need to have a attribute name')
|
||||||
|
continue
|
||||||
|
|
||||||
|
cell = project.spreadsheet.get(cell_data['name'])
|
||||||
|
|
||||||
|
if not cell:
|
||||||
|
print(f"cell {cell_data['name']} not in spreadsheet")
|
||||||
|
continue
|
||||||
|
|
||||||
|
project.spreadsheet.move(list(project.spreadsheet).index(cell), i)
|
||||||
|
|
||||||
|
for prop_name in ('export_name', 'enabled'):
|
||||||
|
if prop_name in cell_data:
|
||||||
|
setattr(cell, prop_name, cell_data[prop_name])
|
||||||
|
|
||||||
|
if spreadsheet.get('options'):
|
||||||
|
for k, v in spreadsheet['options'].items():
|
||||||
|
try:
|
||||||
|
setattr(project.spreadsheet_options, k, v)
|
||||||
|
except Exception:
|
||||||
|
print(f'Could not set option {k} with value {v} to spreadsheet')
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
VSETB_OT_auto_select_files,
|
VSETB_OT_auto_select_files,
|
||||||
VSETB_OT_casting_add,
|
VSETB_OT_casting_add,
|
||||||
|
|
12
panels.py
12
panels.py
|
@ -91,7 +91,6 @@ class VSETB_PT_sequencer(VSETB_main, Panel):
|
||||||
project = settings.active_project
|
project = settings.active_project
|
||||||
|
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
|
|
||||||
col.operator('vse_toolbox.set_sequencer', text='Set-Up Sequencer', icon='SEQ_SEQUENCER')
|
col.operator('vse_toolbox.set_sequencer', text='Set-Up Sequencer', icon='SEQ_SEQUENCER')
|
||||||
|
|
||||||
#row = col.row()
|
#row = col.row()
|
||||||
|
@ -119,16 +118,7 @@ class VSETB_PT_sequencer(VSETB_main, Panel):
|
||||||
row.enabled = False
|
row.enabled = False
|
||||||
|
|
||||||
op = row.operator('vse_toolbox.strips_rename', text=f'Rename {channel_name} ( {label} )', icon='SORTALPHA')
|
op = row.operator('vse_toolbox.strips_rename', text=f'Rename {channel_name} ( {label} )', icon='SORTALPHA')
|
||||||
if project:
|
op.channel_name = channel_name
|
||||||
op.channel_name = channel_name
|
|
||||||
if channel_name == 'Shots':
|
|
||||||
op.start_number = project.shot_start_number
|
|
||||||
op.template = project.shot_template
|
|
||||||
op.increment = project.shot_increment
|
|
||||||
else:
|
|
||||||
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')
|
col.operator('vse_toolbox.set_stamps', text='Set Stamps', icon='COLOR')
|
||||||
|
|
||||||
|
|
|
@ -144,10 +144,6 @@ def register():
|
||||||
load_trackers()
|
load_trackers()
|
||||||
prefs = get_addon_prefs()
|
prefs = get_addon_prefs()
|
||||||
|
|
||||||
#tracker_name = os.getenv('TRACKER_NAME')
|
|
||||||
#if tracker_name is not None:
|
|
||||||
# prefs['tracker_name'] = os.path.expandvars(norm_str(tracker_name, format=str.upper))
|
|
||||||
|
|
||||||
config_path = os.getenv('VSE_TOOLBOX_CONFIG')
|
config_path = os.getenv('VSE_TOOLBOX_CONFIG')
|
||||||
if config_path:
|
if config_path:
|
||||||
prefs['config_path'] = os.path.expandvars(config_path)
|
prefs['config_path'] = os.path.expandvars(config_path)
|
||||||
|
|
|
@ -436,17 +436,6 @@ classes = (
|
||||||
from bpy.app.handlers import persistent
|
from bpy.app.handlers import persistent
|
||||||
|
|
||||||
|
|
||||||
def load_settings():
|
|
||||||
prefs = get_addon_prefs()
|
|
||||||
prefs_config_file = prefs.config_path
|
|
||||||
|
|
||||||
if not prefs_config_file:
|
|
||||||
return
|
|
||||||
|
|
||||||
prefs_datas = read_file(os.path.expandvars(prefs_config_file))
|
|
||||||
|
|
||||||
#for cell in prefs_datas.get('spreadsheet', {}).get('cells', []):
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
|
|
Loading…
Reference in New Issue