Brushstroke Tools: Initial Version #328
@ -266,9 +266,27 @@ def import_brushstroke_material():
|
||||
addon_prefs = bpy.context.preferences.addons[__package__].preferences
|
||||
|
||||
mats_pre = set(bpy.data.materials)
|
||||
ng_pre = set(bpy.data.node_groups)
|
||||
with bpy.data.libraries.load(path, link=addon_prefs.import_method=='LINK', relative=addon_prefs.import_relative_path) as (data_src, data_dst):
|
||||
data_dst.materials = [name]
|
||||
mats_new = list(set(bpy.data.materials) - mats_pre)
|
||||
|
||||
# de-duplicate imported node-groups
|
||||
ng_new = list(set(bpy.data.node_groups) - ng_pre)
|
||||
ng_remove = []
|
||||
for ng in ng_new:
|
||||
ng_name_elements = ng.name.split('.')
|
||||
if len(ng_name_elements) == 1:
|
||||
continue
|
||||
root_ng = bpy.data.node_groups.get('.'.join(ng_name_elements[:-1]))
|
||||
if not root_ng:
|
||||
continue
|
||||
ng.user_remap(root_ng)
|
||||
ng_remove += [ng]
|
||||
for ng in reversed(ng_remove):
|
||||
bpy.data.node_groups.remove(ng)
|
||||
|
||||
# return imported material
|
||||
if mats_new:
|
||||
return mats_new[0]
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user