finish make library conformation working

This commit is contained in:
“christopheseux”
2022-12-30 23:36:09 +01:00
parent ab72a15a2c
commit 501cb460c8
19 changed files with 319 additions and 303 deletions
+1
View File
@@ -16,6 +16,7 @@ if 'bpy' in locals():
#importlib.reload(build_collection_blends)
#importlib.reload(create_collection_library)
import bpy
def register():
operators.register()
+7 -21
View File
@@ -42,43 +42,29 @@ class ASSETLIB_OT_load_asset(Operator):
print('Load Asset')
lib = get_active_library()
print(lib, lib.data_type)
# dir(asset) : 'asset_data', 'bl_rna', 'id_type', 'local_id', 'name', 'preview_icon_id', 'relative_path', 'rna_type']
# dir(asset.asset_data) : 'active_tag', 'author', 'bl_rna', 'catalog_id', 'catalog_simple_name', 'description', 'rna_type', 'tags']
## get source path
# asset_file_handle = context.asset_file_handle
# if asset_file_handle is None:
# return {'CANCELLED'}
# if asset_file_handle.local_id:
# return {'CANCELLED'}
# asset_library_ref = context.asset_library_ref
# source_directory = bpy.types.AssetHandle.get_full_library_path(
# asset_file_handle, asset_library_ref
# )
asset = context.active_file
if not asset:
self.report({"ERROR"}, 'No asset selected')
return {'CANCELLED'}
active_lib = lib.adapter.get_active_asset_library()
asset_path = asset.asset_data['filepath']
fp = lib.adapter.format_path(asset_path)
asset_path = active_lib.adapter.format_path(asset_path)
name = asset.name
## set mode to object
if context.mode != 'OBJECT':
bpy.ops.object.mode_set(mode='OBJECT')
## get the real direct path with expand_var
print('path expanded: ', fp)
if not Path(fp).exists():
self.report({'ERROR'}, f'Not exists: {fp}')
if not Path(asset_path).exists():
self.report({'ERROR'}, f'Not exists: {asset_path}')
return {'CANCELLED'}
res = load_col(fp, name, link=True, override=True, rig_pattern='*_rig')
print('Load collection', asset_path, name)
res = load_col(asset_path, name, link=True, override=True, rig_pattern='*_rig')
if res:
if res.type == 'ARMATURE':
self.report({'INFO'}, f'Override rig {res.name}')
Binary file not shown.