I'm writing an addon to parse a directory (and its sub-dirs) to write an XML file which describe the tree-structure of the assets contained in that directory.
At the moment, my standalone script works pretty well.

The fact is, I need to add some info to the XML, like the dependencies (linked libraries) of each .blend file the script found.

I found a way to do this (outside blender), with the module "pyblenderfile" : http://code.google.com/p/pyblenderfile/

The principle of this module is to open a .blend and get all its data. But it's pretty long and often buggy on large .blend files. Especially since it's included in a for ... loop!

So I wonder if there is a utility function or method into Blender API, to access other .blend files data (without having to wm.open() them) ?


There's no data API for the .blend file format.

However, it sounds like you're trying to make a tool similar to Blender-Aid (code is here). Perhaps that's better place to start.

Note that blendfile.py from Blender-Aid can be used as a standalone blend file reader.

| improve this answer | |

Yes, you can load in blend file data without opening the blend file using the library API.

Though this is intended for linking in data, you can use it to get data-blocks from a blend file. However it may not be a solution for you since you can only list the data-block names.

Optionally you could link the data, then remove it if you wanted to find out more about the data-blocks.

Note, I realize that blendfile.py may prove a better solution regarding the use case described in the question, but adding this answer for completeness, others who read this question may find the library method useful.

| improve this answer | |
  • $\begingroup$ Thanks @ideasman42, the blendfile.py script did the job pretty well (I had a little issue with "string length" while reading blocks, but I found a workaround and everything works perfect) $\endgroup$ – Polosson Aug 17 '13 at 13:30
  • $\begingroup$ @Polosson, I noticed string length needed changes too, would be good to get these updated committed back to the original repo. $\endgroup$ – ideasman42 Aug 17 '13 at 13:35
  • $\begingroup$ well, I made a very small modif in the blendfile.py... Just increased the range (line 122), up to 1250. It prevent the use of FindBlendFileBlocksWithCode(), then block.Get() to raise the list index out of range exception, but it return some strange strings, like link1.blendnk1.blend, instead of link1.blend. So my workaround was to split the string to only get the first :.blend string! Not very neat but it works. :D $\endgroup$ – Polosson Aug 18 '13 at 14:11
  • $\begingroup$ I've since made an updated blendfile.py, with quite a few changes/optimizations - linked in the answer. $\endgroup$ – ideasman42 Aug 5 '15 at 23:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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