asset_library/__init__.py

69 lines
1.5 KiB
Python
Raw 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.",
2024-05-27 17:22:45 +02:00
"author": "Christophe Seux",
2022-12-24 15:30:32 +01:00
"version": (2, 0),
2024-05-27 17:22:45 +02:00
"blender": (4, 0, 2),
2022-12-24 15:30:32 +01:00
"warning": "In development, things may change",
2024-05-27 17:22:45 +02:00
"location": "Asset Browser",
"category": "Import-Export",
2022-12-24 15:30:32 +01:00
}
2024-07-04 11:53:58 +02:00
import sys
2022-12-24 15:30:32 +01:00
2024-07-04 11:53:58 +02:00
from . import operators, properties, ui, preferences, data_type
from .core.lib_utils import load_libraries, update_library_path
2022-12-24 15:30:32 +01:00
2024-07-04 11:53:58 +02:00
bl_modules = (
2022-12-24 15:30:32 +01:00
operators,
2024-05-27 17:22:45 +02:00
properties,
ui,
2024-07-04 11:53:58 +02:00
preferences,
data_type
2022-12-24 15:30:32 +01:00
)
2024-05-27 17:22:45 +02:00
# Reload Modules from inside Blender
if "bpy" in locals():
import importlib
2023-01-17 18:05:22 +01:00
2024-05-27 17:22:45 +02:00
for mod in modules:
importlib.reload(mod)
2022-12-24 15:30:32 +01:00
2024-07-04 11:53:58 +02:00
import bpy
def load_handler():
print('load_handler')
load_libraries()
update_library_path()
#set_env_libraries()
#bpy.ops.assetlib.set_paths(all=True)
#if not bpy.app.background:
# bpy.ops.assetlib.bundle(blocking=False, mode='AUTO_BUNDLE')
2022-12-24 15:30:32 +01:00
2024-05-27 17:22:45 +02:00
def register():
"""Register the addon Asset Library for Blender"""
2022-12-24 15:30:32 +01:00
2024-07-04 11:53:58 +02:00
for mod in bl_modules:
2024-05-27 17:22:45 +02:00
mod.register()
2024-07-04 11:53:58 +02:00
bpy.app.timers.register(load_handler, first_interval=1)
2022-12-24 15:30:32 +01:00
2024-05-27 17:22:45 +02:00
def unregister():
"""Unregister the addon Asset Library for Blender"""
2022-12-24 15:30:32 +01:00
2024-07-04 11:53:58 +02:00
for mod in reversed(bl_modules):
2024-05-27 17:22:45 +02:00
mod.unregister()