diff options
author | Vilém Duha <vilda.novak@gmail.com> | 2019-09-04 15:39:22 +0300 |
---|---|---|
committer | Vilém Duha <vilda.novak@gmail.com> | 2019-09-10 17:55:31 +0300 |
commit | 16299222c41de0bd77335cd0e97656edeb2090c3 (patch) | |
tree | 34d19c059c4c6f90008c63147a753f644d634524 /blenderkit/append_link.py | |
parent | 5f3c703ea4b0f4651e4f28e682a91382a90a5596 (diff) |
BlenderKit: switch update functions to independent timers.
-seems to improve performance, and fixes assets not appending while asset bar is off.
Diffstat (limited to 'blenderkit/append_link.py')
-rw-r--r-- | blenderkit/append_link.py | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/blenderkit/append_link.py b/blenderkit/append_link.py index efbd1492..61808af7 100644 --- a/blenderkit/append_link.py +++ b/blenderkit/append_link.py @@ -87,13 +87,37 @@ def append_scene(file_name, scenename=None, link=False, fake_user=False): def link_group(file_name, obnames=[], location=(0, 0, 0), link=False, **kwargs): '''link an instanced group - model type asset''' sel = utils.selection_get() - bpy.ops.wm.link(directory=file_name + "/Collection/", filename=kwargs['name'], link=link, instance_collections=True, - autoselect=True) - main_object = bpy.context.active_object + with bpy.data.libraries.load(file_name, link=link, relative=True) as (data_from, data_to): + scols = [] + for col in data_from.collections: + print('linking this ', col) + if col == kwargs['name']: + data_to.collections = [col] + + rotation = (0,0,0) if kwargs.get('rotation') is not None: - main_object.rotation_euler = kwargs['rotation'] - main_object.location = location + rotation = kwargs['rotation'] + + + bpy.ops.object.empty_add(type='PLAIN_AXES', location=location, rotation = rotation) + main_object = bpy.context.view_layer.objects.active + main_object.instance_type = 'COLLECTION' + for col in bpy.data.collections: + print(col.name, col.library, file_name) + if col.library is not None: + if col.library.filepath == file_name: + main_object.instance_collection = col + break; + + + # bpy.ops.wm.link(directory=file_name + "/Collection/", filename=kwargs['name'], link=link, instance_collections=True, + # autoselect=True) + # main_object = bpy.context.view_layer.objects.active + # if kwargs.get('rotation') is not None: + # main_object.rotation_euler = kwargs['rotation'] + # main_object.location = location + utils.selection_set(sel) return main_object, [] |