[Solved] Get list of all scenes in a .blend that is not the active one

Hi,

I would like to get the list of all the scenes that belong to a .blend that is not the current one.

That’s what I have for now :


import Blender
from Blender import Scene
blendList = g.getBlendFileList("//")

for blend in blendList:   
    #sceneList = blend.Scene.Get() #Doesn't work. blend is a string
    

Also :

  1. I want to avoid the pre-creation of a list that would contain those
  2. I want to keep the current blend open and active : I don’t want to open another one.

Questions :

  • Do you have a solution?
  • Is there a method to get a blend object from a blend name variable?

Edit : Should it be in the Python section?

Hi cray,

I’m moving your thread to Python and Plugins, since it deals with the main Blender Python API, not the Game Engine API.

If I understand correctly, you are trying to get a list of scenes similar to what you see when you select a .blend in “File >> Append or Link” the select “Scenes.” However, you would like to have this list available to your Python script. Am I correct?

I don’t know enough about the main Blender API to answer your question, but I’m rather certain this is possible.

Hi blendenzo,

If I understand correctly, you are trying to get a list of scenes similar to what you see when you select a .blend in “File >> Append or Link” the select “Scenes.” However, you would like to have this list available to your Python script. Am I correct?

Exactly.
Before loading a scene in an external blend (already working) I would like to be able to scan the list of scenes available in that blend / if it doesn’t exist, load default scene.

Same as sceneList = Scene.Get() with an external blend.

The LibData module might help, see the example at the top of the page:http://www.blender.org/documentation/249PythonDoc/LibData-module.html

example:


lib = bpy.libraries.load('//file.blend')
for s in lib.scenes:
    print s # a string
 
linked_scene = lib.scenes.link('Scene')

That works perfectly.

thank you very much :slight_smile: