4
$\begingroup$

I have a multiple scenes in a blend file, each scene has multiple camera objects. Is there a way to read out every camera object for each scene? I can read every camera in the blend file, but I don't know which camera belongs to which scene. This is my code so far:

camList = []
with blendfile.open_blend(filepath) as blend:
    objs=blend.find_blocks_from_code(b'OB')
    for o in objs:
        if o[b'type'] == 11:
            camList.append(o[b'id',b'name'][2:])

EDIT: I want to read the blend-file outside from blender (using the blendfile.py module)

EDIT2: As far as I understand each scene has multiple base structs that stores the objects, but base = scene.get_pointer(b'basact') gives None

EDIT3: bases are outdated, if I work with an older blend file (<2.8) it works fine, but not with newer (>=2.8) files

$\endgroup$
5
  • $\begingroup$ I would think the answer is to get Scenes from the blendfile and iterate to find any Camera type objects: blend.find_blocks_from_code(b'SC') ... for scene in scenes: for o in s.objects: if o.id_data.type == 'CAMERA': ? $\endgroup$
    – james_t
    Oct 27, 2021 at 17:53
  • $\begingroup$ as far as I know the scene struct doesn't contain the objects, $\endgroup$ Oct 27, 2021 at 18:31
  • $\begingroup$ Just fishing as I'm not a blendfile expert and only work with things like blender mfile.blend -P script.py, where I can do what I suggest. $\endgroup$
    – james_t
    Oct 27, 2021 at 20:03
  • $\begingroup$ yeah this would be a workaround but it would be nice if I could read a blend file out side blender $\endgroup$ Oct 28, 2021 at 14:17
  • $\begingroup$ Unfortunately, in devtalk, the devs have made it clear that they prefer that the blendfile format remain undocumented because it is intended to be used only by blender itself. $\endgroup$ Nov 1, 2021 at 17:21

0

Your Answer

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

Browse other questions tagged or ask your own question.