Brushstroke Tools: Initial Version #328
@ -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()
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user