diff options
Diffstat (limited to 'blenderkit/append_link.py')
-rw-r--r-- | blenderkit/append_link.py | 74 |
1 files changed, 39 insertions, 35 deletions
diff --git a/blenderkit/append_link.py b/blenderkit/append_link.py index 5af63fe1..56b2857d 100644 --- a/blenderkit/append_link.py +++ b/blenderkit/append_link.py @@ -190,43 +190,45 @@ def append_particle_system(file_name, obnames=[], location=(0, 0, 0), link=False def append_objects(file_name, obnames=[], location=(0, 0, 0), link=False, **kwargs): '''append objects into scene individually''' #simplified version of append - scene = bpy.context.scene - sel = utils.selection_get() - bpy.ops.object.select_all(action='DESELECT') - - path = file_name + "\\Collection\\" - object_name = kwargs.get('name') - fc = utils.get_fake_context(bpy.context, area_type='VIEW_3D') - bpy.ops.wm.append(fc,filename=object_name, directory=path) - - - return_obs = [] - for ob in bpy.context.scene.objects: - if ob.select_get(): - return_obs.append(ob) - if not ob.parent: - main_object = ob - ob.location = location - - if kwargs.get('rotation'): - main_object.rotation_euler = kwargs['rotation'] - - if kwargs.get('parent') is not None: - main_object.parent = bpy.data.objects[kwargs['parent']] - main_object.matrix_world.translation = location - - bpy.ops.object.select_all(action='DESELECT') - utils.selection_set(sel) - - return main_object, return_obs - + if kwargs.get('name'): + # by now used for appending into scene + scene = bpy.context.scene + sel = utils.selection_get() + bpy.ops.object.select_all(action='DESELECT') + + path = file_name + "\\Collection\\" + object_name = kwargs.get('name') + fc = utils.get_fake_context(bpy.context, area_type='VIEW_3D') + bpy.ops.wm.append(fc, filename=object_name, directory=path) + + + return_obs = [] + for ob in bpy.context.scene.objects: + if ob.select_get(): + return_obs.append(ob) + if not ob.parent: + main_object = ob + ob.location = location + + if kwargs.get('rotation'): + main_object.rotation_euler = kwargs['rotation'] + + if kwargs.get('parent') is not None: + main_object.parent = bpy.data.objects[kwargs['parent']] + main_object.matrix_world.translation = location + + bpy.ops.object.select_all(action='DESELECT') + utils.selection_set(sel) + + return main_object, return_obs + #this is used for uploads: with bpy.data.libraries.load(file_name, link=link, relative=True) as (data_from, data_to): sobs = [] - for col in data_from.collections: - if col == kwargs.get('name'): - for ob in col.objects: - if ob in obnames or obnames == []: - sobs.append(ob) + # for col in data_from.collections: + # if col == kwargs.get('name'): + for ob in data_from.objects: + if ob in obnames or obnames == []: + sobs.append(ob) data_to.objects = sobs # data_to.objects = data_from.objects#[name for name in data_from.objects if name.startswith("house")] @@ -260,6 +262,8 @@ def append_objects(file_name, obnames=[], location=(0, 0, 0), link=False, **kwar for ob in hidden_objects: ob.hide_viewport = True + print(return_obs) + print(main_object) if kwargs.get('rotation') is not None: main_object.rotation_euler = kwargs['rotation'] |