Brushstroke Tools: Initial Version #328

Merged
Simon Thommes merged 229 commits from SimonThommes/blender-studio-tools:brushstroke_tools-initial-version into main 2024-11-06 15:03:47 +01:00
2 changed files with 4 additions and 2 deletions
Showing only changes of commit 794f714b76 - Show all commits

View File

@ -573,7 +573,7 @@ def set_brushstrokes_animated(bs_ob, animated):
if animated: if animated:
if not mod: if not mod:
mod = ob.modifiers.new('Animation', 'NODES') mod = ob.modifiers.new('Animation', 'NODES')
mod.node_group = bpy.data.node_groups['.brushstroke_tools.animation'] mod.node_group = utils.ensure_node_group('.brushstroke_tools.animation')
mod_info = ob.modifier_info.get(mod.name) mod_info = ob.modifier_info.get(mod.name)
if not mod_info: if not mod_info:

View File

@ -304,12 +304,14 @@ def import_brushstroke_material():
else: else:
return bpy.data.materials.get(name) return bpy.data.materials.get(name)
def ensure_node_group(name, path): def ensure_node_group(name, path=''):
ng = bpy.data.node_groups.get(name) ng = bpy.data.node_groups.get(name)
if ng: if ng:
return ng return ng
addon_prefs = bpy.context.preferences.addons[__package__].preferences addon_prefs = bpy.context.preferences.addons[__package__].preferences
if not path:
path=f'{get_resource_directory()}/brushstroke_tools-resources.blend'
with bpy.data.libraries.load(path, link=addon_prefs.import_method=='LINK', relative=addon_prefs.import_relative_path) as (data_src, data_dst): 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.node_groups = [name] data_dst.node_groups = [name]