0
$\begingroup$

It's fairly easy to get the objects that are in a scene:

dict(myScene.collection.all_objects) # mapping from name to object.

But how to go the other way?

scene = magic_get_linked_scenes(myOb)

One could iterate through all scenes:

linked_scenes = []
for scene_name, scene in dict(bpy.data.scenes):
  for ob_name, ob in dict(scene.collection.all_objects):
     if ob.name == name:
         linked_scenes.append(scene) # checking object equality should also work. 

But this is clumsy and slow if there are a very large number of objects. Is there a better way?

$\endgroup$
1
  • $\begingroup$ Best practice is to get all objects of the scene in context: list(bpy.context.scene.objects) $\endgroup$ – brockmann Sep 11 '20 at 17:02
1
$\begingroup$

object.users_scene seems to show the scenes using the object.

Blender's Python Console is very useful when finding this stuff out. If you start typing and hit Tab Auto Complete shows you all the options you have:

enter image description here

$\endgroup$

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.