finish make library conformation working
This commit is contained in:
+4
-12
@@ -13,6 +13,7 @@ from bpy_extras import asset_utils
|
||||
from asset_library.constants import RESOURCES_DIR
|
||||
#from asset_library.common.file_utils import no
|
||||
from os.path import abspath
|
||||
import subprocess
|
||||
|
||||
|
||||
class attr_set():
|
||||
@@ -328,13 +329,10 @@ def split_path(path) :
|
||||
|
||||
|
||||
|
||||
def load_datablocks(src, names=None, type='objects', link=True, expr=None) -> list:
|
||||
def load_datablocks(src, names=None, type='objects', link=True, expr=None, assets_only=False) -> list:
|
||||
return_list = not isinstance(names, str)
|
||||
names = names or []
|
||||
|
||||
if type.isupper():
|
||||
type = f'{type.lower()}s'
|
||||
|
||||
if not isinstance(names, (list, tuple)):
|
||||
names = [names]
|
||||
|
||||
@@ -342,7 +340,7 @@ def load_datablocks(src, names=None, type='objects', link=True, expr=None) -> li
|
||||
pattern = expr
|
||||
expr = lambda x : fnmatch(x, pattern)
|
||||
|
||||
with bpy.data.libraries.load(str(src), link=link) as (data_from, data_to):
|
||||
with bpy.data.libraries.load(str(src), link=link,assets_only=assets_only) as (data_from, data_to):
|
||||
datablocks = getattr(data_from, type)
|
||||
if expr:
|
||||
names += [i for i in datablocks if expr(i)]
|
||||
@@ -384,14 +382,8 @@ def load_col(filepath, name, link=True, override=True, rig_pattern=None, context
|
||||
# return data_to.collections[0]
|
||||
context = context or bpy.context
|
||||
|
||||
collections = load_datablocks(filepath, name, link=link, type='collections')
|
||||
if not collections:
|
||||
print(f'No collection "{name}" found in: {filepath}')
|
||||
return
|
||||
col = load_datablocks(filepath, name, link=link, type='collections')
|
||||
|
||||
col = collections[0]
|
||||
print('collection:', col.name)
|
||||
|
||||
## create instance object
|
||||
inst = bpy.data.objects.new(col.name, None)
|
||||
inst.instance_collection = col
|
||||
|
||||
+1
-1
@@ -180,7 +180,7 @@ def get_asset_source(replace_local=False):
|
||||
source_path = re.sub(actionlib_dir_local, actionlib_dir, source_path)
|
||||
|
||||
return source_path
|
||||
""""
|
||||
"""
|
||||
'''
|
||||
def get_catalog_path(filepath=None):
|
||||
filepath = filepath or bpy.data.filepath
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user