# Import multiple objects using python

I want to import multiple objects from another .blend file using a python script. What is the best way to do this without having to import every single object?

Example of what i want to import:

import bpy

# append all objects starting with 'house'
data_to.objects = [name for name in data_from.objects if name.startswith("house")]

scene = bpy.context.scene
for obj in data_to.objects:
if obj is not None:

• Thanks, it almost works! There is just one problem: When importing a beveled curve (for example like this: prntscr.com/elvbjv) I get this symbol (i think it is for "linked"?): prntscr.com/elvcr7. When i try to edit the Curve Bevel now i get the error "Cannot edit external libdata" and also the animation of the Curve Bevel doesn't show up after importing. – froggyman Mar 19 '17 at 15:45
• Works fine for me, ran a simple test and it appends both curves and bevel objects etc from other blend files. Is Curve.bevel (your picture of which shows SFA) a linked object in your library file – batFINGER Mar 19 '17 at 16:04
• It appended both for me, too. I also just ran a simple test scene but it appended this prntscr.com/elvrr0 instead of this prntscr.com/elvslb. This is a problem because the Animation data doesn't get transferred. All objects were created in the original file. – froggyman Mar 19 '17 at 16:20
• Don't know, works for me and appends (simple test) actions from lib file. Might pay to make a sample lib file. – batFINGER Mar 19 '17 at 16:23
• Think someone else needs to look at this, as for me your sample files do exactly as expected and append both curves. There is no animation data. – batFINGER Mar 19 '17 at 17:04

You need to use append and choose which object you want to import and which type this object is.

Some of the different types are shown below:

Once you know that then you can use the below python script which is found here to import the object you want from another .blend file

blendfile = 'D:/path_to_blend_file/source.blend'
section   = '\\Object\\'
objects    = ['myobj1','myobj2','myobj3','myobj4','myobj5'] ###<-- Add the name of objects you want to append

directory = blendfile + section

for obj in objects:
filename  = obj
bpy.ops.wm.append(filename=filename, directory=directory)

• FYI information directory and filename may be enough. See blender.stackexchange.com/questions/74378/… – lemon Mar 16 '17 at 5:30
• Thank you this helped, i don't know how to effeciently import multiple objects with your script. I edit my question to make it more clear. – froggyman Mar 16 '17 at 16:43
• You can look this post blender.stackexchange.com/questions/17876/… – pistiwique Mar 16 '17 at 19:43
• Thanks but i already tried it and it doesn't work with beveled Curves somehow – froggyman Mar 16 '17 at 19:45
• @froggyman answer updated. You include the object names you want to append in the objects list – Tak Mar 16 '17 at 23:29