A suggestion re file paths.
Make an addon preferences class, with a subtype DIR_PATH for folders, FILE_PATH for files. This will show up in a panel under the registration screen.
class GDALAddonPreferences(AddonPreferences):
bl_idname = "GDAL_tools"
base_folder = StringProperty(
name="GDAL Tools Path",
subtype='DIR_PATH',
)
gimp_binary = StringProperty(
name="Gimp File Path",
subtype='FILE_PATH',
description="Path to Gimp Executable",
)
def draw(self, context):
layout = self.layout
layout.label(text="GDAL Tools", icon='WORLD')
layout.prop(self, "base_folder")
layout.prop(self, "gimp_binary")
When the file is set up as an addon you can retrieve the path with.
Dir = os.path.dirname(__file__)
path = os.path.join(Dir, 'settings.xml')
The default of the folder stringprop can be set using this.
Another thought is setting up a filebrowser to select the files, here you could associate which collection you want to link/append from which file. Below is a simple filebrowser script that lists the selected files on the Panel.
import bpy
# ExportHelper is a helper class, defines filename and
# invoke() function which calls the file selector.
from bpy.props import StringProperty, BoolProperty, EnumProperty, CollectionProperty
from bpy.types import Operator
from bpy_extras.io_utils import ImportHelper
class SetLibraryFile(Operator, ImportHelper):
"""This appears in the tooltip of the operator and in the generated docs"""
bl_idname = "export_test.some_data" # important since its how bpy.ops.import_test.some_data is constructed
bl_label = "Set Library File"
files = CollectionProperty(type=bpy.types.OperatorFileListElement,
options={'HIDDEN',
'SKIP_SAVE'})
directory = StringProperty(maxlen=1024, subtype='DIR_PATH',
options={'HIDDEN', 'SKIP_SAVE'})
''' filter for blend files only'''
filter_blender = BoolProperty(default=True, options={'HIDDEN'})
'''
filter_glob = StringProperty(
default="*.txt",
options={'HIDDEN'},
)
'''
# List of operator properties, the attributes will be assigned
# to the class instance from the operator settings before calling.
use_setting = BoolProperty(
name="Example Boolean",
description="Example Tooltip",
default=True,
)
type = EnumProperty(
name="Example Enum",
description="Choose between two items",
items=(('OPT_A', "First Option", "Description one"),
('OPT_B', "Second Option", "Description two")),
default='OPT_A',
)
def draw(self, context):
layout = self.layout
row = layout.row()
row.operator("file.select_all_toggle")
for file in self.files:
row = layout.row()
row.label(file.name)
def invoke(self, context, event):
wm = context.window_manager
wm.fileselect_add(self)
print("FILE SELECTOR INVOKED...................")
return {'RUNNING_MODAL'}
def execute(self, context):
return {'FINISHED'}
def register():
bpy.utils.register_class(SetLibraryFile)
def unregister():
bpy.utils.unregister_class(SetLibraryFile)
if __name__ == "__main__":
register()
# test call
bpy.ops.export_test.some_data('INVOKE_DEFAULT')