Brushstroke Tools: Initial Version #328
@ -35,6 +35,7 @@ class BSBST_preferences(bpy.types.AddonPreferences):
|
|||||||
bl_idname = __package__
|
bl_idname = __package__
|
||||||
|
|
||||||
resource_path: bpy.props.StringProperty(name='Resource Directory', subtype='DIR_PATH', )
|
resource_path: bpy.props.StringProperty(name='Resource Directory', subtype='DIR_PATH', )
|
||||||
|
import_relative_path: bpy.props.BoolProperty(name='Relative Path', default=True )
|
||||||
import_method: bpy.props.EnumProperty(name='Import Method', default='APPEND',
|
import_method: bpy.props.EnumProperty(name='Import Method', default='APPEND',
|
||||||
items= [('APPEND', 'Append', 'Append data-blocks and pack image data as local to this file.', 'APPEND_BLEND', 0),\
|
items= [('APPEND', 'Append', 'Append data-blocks and pack image data as local to this file.', 'APPEND_BLEND', 0),\
|
||||||
('LINK', 'Link', 'Link data-blocks from resource directory.', 'LINK_BLEND', 1),
|
('LINK', 'Link', 'Link data-blocks from resource directory.', 'LINK_BLEND', 1),
|
||||||
@ -45,6 +46,8 @@ class BSBST_preferences(bpy.types.AddonPreferences):
|
|||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.label(text='Brushstrokes Library', icon='BRUSHES_ALL')
|
row.label(text='Brushstrokes Library', icon='BRUSHES_ALL')
|
||||||
layout.prop(self, 'import_method')
|
layout.prop(self, 'import_method')
|
||||||
|
if self.import_method == 'LINK':
|
||||||
|
layout.prop(self, 'import_relative_path')
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
col = row.column()
|
col = row.column()
|
||||||
dir_exists = os.path.isdir(utils.get_resource_directory())
|
dir_exists = os.path.isdir(utils.get_resource_directory())
|
||||||
|
@ -152,11 +152,20 @@ def import_resources(ng_names = ng_list):
|
|||||||
"""
|
"""
|
||||||
Imports the necessary blend data resources required by the addon.
|
Imports the necessary blend data resources required by the addon.
|
||||||
"""
|
"""
|
||||||
|
addon_prefs = bpy.context.preferences.addons[__package__].preferences
|
||||||
|
|
||||||
path = get_resource_directory()
|
path = get_resource_directory()
|
||||||
|
|
||||||
with bpy.data.libraries.load(f'{path}brushstroke_tools-resources.blend', link=False) as (data_src, data_dst):
|
with bpy.data.libraries.load(f'{path}brushstroke_tools-resources.blend', link=addon_prefs.import_method=='LINK', relative=addon_prefs.import_relative_path) as (data_src, data_dst):
|
||||||
data_dst.node_groups = ng_names
|
data_dst.node_groups = ng_names
|
||||||
|
if addon_prefs.import_method=='APPEND':
|
||||||
|
# pack imported resources
|
||||||
|
for img in bpy.data.images:
|
||||||
|
if not img.library_weak_reference:
|
||||||
|
continue
|
||||||
|
if 'brushstroke_tools-resources.blend' in img.library_weak_reference.filepath:
|
||||||
|
img.pack()
|
||||||
|
|
||||||
|
|
||||||
def copy_resources_to_dir(tgt_dir = ''):
|
def copy_resources_to_dir(tgt_dir = ''):
|
||||||
resource_dir = f'{get_addon_directory()}/assets/'
|
resource_dir = f'{get_addon_directory()}/assets/'
|
||||||
|
Loading…
Reference in New Issue
Block a user