I'd like to be able to use an external instance of Python (ie. not Blender's internal python) to read a blend file and inspect it for Render Settings (ie. Start Frame, etc.).

Is this possible without firing up the Blender app itself? I don't want to have to depend on a Blender app, or to import the bpy module because the main project is in Python 2.7.

Also, I'd like to avoid any cli calls to blender to get this information.

  • $\begingroup$ I believe not, but from the source code of blender it is possible to compile a only a standalone bpy. IT can do the trick for you. $\endgroup$
    – Mörkö
    Sep 16 '15 at 5:54
  • $\begingroup$ Looks like it is possible by inspecting the file on a byte level, and by knowing the byte address of the specific data value that you want. More info here: atmind.nl/blender/mystery_ot_blend.html. Once I figure out the specifics I'll post more. $\endgroup$ Sep 16 '15 at 6:23
  • 5
    $\begingroup$ Check out blender.stackexchange.com/questions/3141/… $\endgroup$
    – batFINGER
    Sep 16 '15 at 12:48
  • $\begingroup$ What settings do you need? - (ie. Start Frame, etc.). is too vague. $\endgroup$
    – ideasman42
    Sep 16 '15 at 17:27
  • $\begingroup$ I'd be happy with Start Frame, End Frame, and output File Format to begin with. $\endgroup$ Sep 16 '15 at 18:16

While it is possible, using blender will be much easier. A small script that you pass to blender when run from a cli is small and easy to maintain. From another python script you could automate it with -

from subprocess import call

You can even have your script generate the small temporary script that gets passed to blender.

However if you really have a need to not require blender to be installed, you may want to look at an old project that appears to have died off called blender-aid, it provided a web interface to blend files and used a python script to access data in the blend file, it was intended to assist project management and allowed file links to be repaired and/or re-factored, so apart from reading a blend file it could also write changes to them. While the full info of reading a blend file is contained within blender's source code, you may be able to get a start with blender-aid's old script here - or at least it will give you an idea of how much code is needed.

  • $\begingroup$ The blendarid tip was great! I'm thinking that will help me find the solution. Thanks. $\endgroup$ Sep 16 '15 at 18:29
  • $\begingroup$ @sambler The old script link is dead, I've tried to find it... there is a trunk folder at google code, but I was not sure. $\endgroup$
    – p2or
    Sep 17 '15 at 12:25
  • $\begingroup$ @poor My bad, I pasted the wrong link. Yes, the blender-aid svn repo is at google code. $\endgroup$
    – sambler
    Sep 17 '15 at 13:16

I've found a solution that works the way I need for my project. A big thank you to sambler for pointing me in the right direction towards the blenderaid project which allowed me to get the results I needed.

Here's how I did it:

  1. I downloaded the blender aid package, renamed the folder from "blenderaid-py-20110211-2" to just "blenderaid" and placed the folder in the /lib folder of my project
  2. I added init.py files to the /lib and /lib/blenderaid folders
  3. In my root folder I created a test.py file with the following code:

Update - I discovered that the block label for finding image type changed at Blender 2.61 - I updated code to add the if/then statement

import os
from lib.blenderaid.blendfile import *


def formatImageType(value):
    if value<len(TRANS):
        return TRANS[value]
        return "UNKNOWN"

file = 'path/to/file.blend'

if file.endswith(".blend"):

    for block in bf.FindBlendFileBlocksWithCode("SC"):

        scStartFrame = block.Get("r.sfra");
        scEndFrame = block.Get("r.efra");
        scImageType = formatImageType(block.Get("r.imtype"))

        if bf.Header.Version>=261:
            scImageType = formatImageType(ord(block.Get("r.im_format.imtype")))
            scImageType = formatImageType(block.Get("r.imtype"))

    print scStartFrame, scEndFrame, scImageType
  • $\begingroup$ Hey @ToddMcIntosh do you still have a copy of blenderaid? If so, could you upload it somewhere? Thanks in advance. $\endgroup$
    – Teck-freak
    May 7 '17 at 9:41
  • $\begingroup$ Can you not just download it from the repo I linked above? $\endgroup$ May 7 '17 at 13:25
  • $\begingroup$ Weird! Wenn I was on that repository, it claimed an 404. Well, just went there again to double-check and there it was. . . Anyways, thanks mate. $\endgroup$
    – Teck-freak
    May 10 '17 at 15:01

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.