Blender - Open and parse a .blend file from python script
Question: I would like to open a .blend file from a python script and parse it (get
objects, animations and materials). The documentation I have read so far about
how to do this from blender API (running the script as a blender add-on), but
I would like to run this script from the command line without opening blender.

I appreciate all the help you can give me.


Answer: I realized I don't need to open the binary blender file and parse it in order
to use the objects. Blender has its own python installation, so I put a python
script inside the folder **path_to_blender/version/scripts/addons** , I can
execute it in the command line as follows:

    
    
    blender.exe --background  --python ./version/scripts/addons/superScript.py
    

Next, if you have a .blend file you want to read from your script, put it
after the background parameter as follows:

    
    
     blender.exe --background myFile.blend --python ./version/scripts/addons/superScript.py
    

And inside your python script do the following:

    
    
    import bpy
    import os
    for ob in bpy.context.scene.objects:
        print("object name:  ", ob.data.name)
    

In this example I'm printing all the objects inside the scene in the .blend
file

