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 30 additions and 2 deletions
Showing only changes of commit e2fa4b0c2a - Show all commits

View File

@ -1,14 +1,25 @@
from . import utils, icons, settings, ui, draw_tool, ops
import toml
import bpy
modules = [utils, icons, settings, ui, draw_tool, ops]
def register():
# register modules
for m in modules:
m.register()
# read addon meta-data
manifest = toml.load(f"{utils.get_addon_directory()}/blender_manifest.toml")
utils.addon_version = tuple([int(i) for i in manifest['version'].split('.')])
# Add addon asset library
utils.register_asset_lib()
def unregister():
# un-register modules
for m in reversed(modules):
m.unregister()
# Remove addon asset library
utils.unregister_asset_lib()

View File

@ -18,6 +18,8 @@ linkable_sockets = [
bpy.types.NodeTreeInterfaceSocketInt,
]
asset_lib_name = 'Brushstroke Tools Library'
@persistent
def refresh_preset(dummy):
settings = bpy.context.scene.BSBST_settings
@ -118,6 +120,21 @@ def ensure_resources():
if ng_missing:
import_resources(list(ng_missing))
def register_asset_lib():
asset_libs = bpy.context.preferences.filepaths.asset_libraries
if asset_lib_name in [a.name for a in asset_libs]:
return
lib = asset_libs.new()
lib.name = asset_lib_name
lib.path = get_addon_directory()
def unregister_asset_lib():
asset_libs = bpy.context.preferences.filepaths.asset_libraries
lib = asset_libs.get(asset_lib_name)
if not lib:
return
asset_libs.remove(lib)
def transfer_modifier(modifier_name, target_obj, source_obj):
"""
Core taken from https://projects.blender.org/studio/blender-studio-pipeline