asset_library/__init__.py

104 lines
2.2 KiB
Python
Raw Permalink Normal View History

2022-12-24 15:30:32 +01:00
# SPDX-License-Identifier: GPL-2.0-or-later
"""
Extending features of the Asset Browser for a studio use.
"""
bl_info = {
"name": "Asset Library",
"description": "Asset Library based on the Asset Browser.",
"author": "Sybren A. Stüvel, Clement Ducarteron, Christophe Seux, Samuel Bernou",
"version": (2, 0),
"blender": (3, 3, 0),
"warning": "In development, things may change",
"location": "Asset Browser -> Animations, and 3D Viewport -> Animation panel",
"category": "Animation",
}
#from typing import List, Tuple
from asset_library import pose
from asset_library import action
from asset_library import collection
from asset_library import file
2023-01-17 18:05:22 +01:00
from asset_library import (gui, keymaps, preferences, operators)
2022-12-24 15:30:32 +01:00
from asset_library import constants
2023-01-17 18:05:22 +01:00
#from asset_library.common.library_type import LibraryType
2022-12-24 15:30:32 +01:00
from asset_library.common.bl_utils import get_addon_prefs
from asset_library.common.functions import set_env_libraries
from asset_library.common.template import Template
import re
if 'bpy' in locals():
print("Reload Addon Asset Library")
import importlib
2023-01-17 18:05:22 +01:00
importlib.reload(constants)
2022-12-24 15:30:32 +01:00
importlib.reload(gui)
importlib.reload(keymaps)
2023-01-17 18:05:22 +01:00
importlib.reload(preferences)
2022-12-24 15:30:32 +01:00
importlib.reload(operators)
importlib.reload(constants)
importlib.reload(action)
importlib.reload(file)
importlib.reload(collection)
2022-12-24 15:30:32 +01:00
import bpy
import os
#addon_keymaps: List[Tuple[bpy.types.KeyMap, bpy.types.KeyMapItem]] = []
bl_modules = (
operators,
pose,
action,
collection,
file,
keymaps,
gui,
2023-01-17 18:05:22 +01:00
preferences
2022-12-24 15:30:32 +01:00
)
def load_handler():
print('load_handler')
set_env_libraries()
bpy.ops.assetlib.set_paths(all=True)
2023-01-17 18:05:22 +01:00
if not bpy.app.background:
bpy.ops.assetlib.bundle(blocking=False, mode='AUTO_BUNDLE')
2022-12-24 15:30:32 +01:00
def register() -> None:
2023-01-17 18:05:22 +01:00
2022-12-24 15:30:32 +01:00
for m in bl_modules:
m.register()
#prefs = get_addon_prefs()
bpy.app.timers.register(load_handler, first_interval=1)
def unregister() -> None:
2023-01-17 18:05:22 +01:00
prefs = get_addon_prefs()
bpy.utils.previews.remove(prefs.previews)
2022-12-24 15:30:32 +01:00
for m in reversed(bl_modules):
m.unregister()
2023-01-17 18:05:22 +01:00