Is there a non-blender API for producing blend files?
I don't know of how to export directly to Blender (seems overly complicated), but you could import PLY/STL/etc files, and then script all the additional features you want.

In my case, I was free to choose the original CAD program, so I chose to build directly in Blender via the PyModule. I work with Blender completely separate from the GUI, and rely only on an external python3 and the bpy module. The bpy module is easy to make.. and you can keep it largely separate from your existing blender install (I run from source folder).

Just run this command (make sure you don't have a $HOME/src):

git clone http://git.blender.org/blender.git &amp;&amp; cd blender &amp;&amp; git submodule update --init --recursive &amp;&amp; git submodule foreach git checkout master &amp;&amp; git submodule foreach git pull --rebase origin master &amp;&amp; build_files/build_environment/install_deps.sh --with-all --skip-osl &amp;&amp; sudo make bpy &amp;&amp; cd .. &amp;&amp; rm -rf blender &amp;&amp; sudo rm -rf build_linux_bpy &amp;&amp; rm -rf $HOME/src # this gets bpy python module


I also found this: https://code.google.com/p/pyblenderfile/
but, honestly, I don't see much benefit. Its not developed enough to allow importing everything, so I found a better way of doing the same thing using the bpy module.

What I do is this:

-- build stuff in blender (I do it via python, without ever starting the official application)

import bpy
#build stuff
bpy.ops.wm.save_as_mainfile(filepath="./objects8.blend")


-- import the model

import bpy
bpy.ops.wm.open_mainfile(filepath="./objects8.blend")


Works great for me. I have some issues recreating stuff you can do in the GUI, but its mostly because Blender has terrible documentation for code (imo). Still, you can do sweet stuff since you call all the equivalent commands directly in python and it executes using the bpy module.