I want to append an element from another Blend file by a script. I found the Blender operator bpy.ops.wm.append which should do what I want. However, the API documentation is a bit unclear:

filepath  – File Path, Path to file
directory – Directory, Directory of the file
filename  – File Name, Name of the file

So what exactly is expected here?


After trying out the interface for a while, i finally found the values that seem to satisfy the API. Here is a code snippet:

blendfile = "D:/path/to/the/repository.blend"
section   = "\\Action\\"
object    = "myaction"

filepath  = blendfile + section + object
directory = blendfile + section
filename  = object


Hint: The directroy string must be terminated with a trailing "\\". If you do not do that, then you always get an error "not a library". I also found that you only need to supply filename and directory, which makes some sense:

bpy.ops.wm.append(filename=filename, directory=directory) # works

However this does not work, no idea why:

bpy.ops.wm.append(filepath=filepath) # does not work (why that?) 
| improve this answer | |
  • $\begingroup$ Is there a way to append multiple objects at once? I tried giving filename as '*', '', without filename argument. But nothing seems to work. $\endgroup$ – Anurag Mar 21 '16 at 13:31
  • $\begingroup$ Just a small addition. I am using this in Blender 2.76b. section = "/Action/" works for me while "\\Action\\". The latter does not throw any error but just doesn't append anything $\endgroup$ – Sum-Al Jun 17 '16 at 7:29
  • $\begingroup$ @anurag Yes, we can append multiple objects at once. You need to group them together in the source blender file, append the group in the new Blender file and then unlink the group. $\endgroup$ – Sum-Al Jun 22 '16 at 13:42
  • $\begingroup$ +1 for (filename=filename, directory=directory) # works and (filepath=filepath) # does not work (why that?) $\endgroup$ – Sibbs Gambling Dec 27 '16 at 20:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.