Read Cameras W/out starting Blender

Here’s what I need to do: read a .blend file using Python, spit out a list of scenes and a list of cameras in that file, and quit. The problem is, I need to do this without actually starting Blender.

Is this possible? Or am I living in a fantasy world? Any ideas are appreciated.

You do realize you can run blender without the GUI, right?

blender -h is your friend.

Thanks stiv. I actually did not realize that “Render in background” meant “render with no gui.” I guess I should have put that together, but it doesn’t really solve my problem entirely. Even with this, I still have to run Blender, this just has no GUI. Is there a way to get the Python scripts needed to read a .blend file all into one place and read a file using only Python and skip the opening Blender part?

Anyone?

no, you still have to run blender to open the .blend

however the thing you want is the -P switch

blender myfile.blend -P myexport.py

Thanks z3r0d. Yeah, I’m running it using a Python script with -P already. I’d just like to be able to use a server with a php script to find out information about a .blend file without having to actually run Blender. But, if it can’t be done, it just can’t. Thanks for the help you guys. At least the “no GUI” mode will help.

Is there a way to get the Python scripts needed to read a .blend file all into one place and read a file using only Python and skip the opening Blender part?

Sure. Just write a python script to read the .blend as binary data and parse out what you need. The struct module will be your friend here. Let us know when you are done. Don’t forget to handle any changes to the .blend format in upcoming versions!

If all you want is the names of cameras and scenes you can run strings on the .blend and grep for the names you want. Scene names are prefixed with ‘SC’, for example.

yea, you would need to find the format specifications for a .blend file, which I’m sure is out there somewhere. Blender is open-source, so I’m sure it file formats are too.

This script will read and parse blend files, but the output is very “raw”/low level, the script doesn’t understand what the internal Blender structures are. It’s probably possible to modify it but …

You’d be better off using the ‘-P’ switch as z3r0 mentioned and take advantage of the higher level python/blender functions to extract the objects/names etc.

Put all the filenames in a .bat file / shell script

Mike