Python to append to external blend file

Anybody know how I would go about appending object data from a running script into an external .blend file? This would be similar to the menu interface for Appending but done to other files.

I would really like a method or object class that could manipulate the blender file format. This way I could read in the blend file and check settings before appending to it.

Any ideas?

Thanks in advance!


I’ve been looking at the blender source code a bit and looked into the python directory to read through the API. In Library.c there appears to be functions to open an external .blend file (this closes the existing one) and also a Load function to append information to the currently opened .blend file. I didn’t see a Save function.

Once I open another .blend I imagine I loose anything that was in my existing .blend (the one that I started with) Although perhaps it is in memory. So maybe this would work:

  1. Get the name of my .blend file
  2. Open target blend file
  3. Append/Load the info from the blend file from step 1
  4. Save (somehow)
  5. Reopen the original blend file

A bit hokey. Does anybody know if this will work or am I going about this all wrong :slight_smile:


Ok, It appears you can do this:


And probably but not tested:

Ok, so it’s not pretty :slight_smile: But it does technically work. Any ideas on how to make this nicer?