exists any python code to read blender file format?

My immediate need is to find and read text datablocks to make sure a file don’t contain any python before loading with libLoad (a ‘safe’ load that can load whole scenes).

But reading text can be great for config to (why don’t we have access to the texts in the api?).

Another thing is to create mesh datablocks to get around some limitations in the api.

But reading text would be enough for now.

So, do there exists any python code to read blender file format?

Or do it have to be invented from scratch?

I don’t think there is, but if there’s text in a blend file, then you might be able to load it in as a raw file object, and do a text search (non-text data would be useless compiled code). However, I’m not sure if this will work.

I think the textblocks simply do not exist for the BGE. But you can get it with a dirty trick:

  • setup a Python script controller in Script mode (no connection to any sensor or actuator required) with the name of the internal textblock
  • you can access this controller via KX_GameObject.controllers
  • the attribute script gives you the complete textblock content as string

but I do not think it helps you with your security checking

Monster - No, it dont help me… but it was a beautiful trick!

Update: found this http://code.google.com/p/pyblenderfile/

Seams inactive but is GPL - fine with me. Will look at it after work.