7
$\begingroup$

I would like to get the list of objects on a specific layer with python. When it can be done through iterating bpy.data.objects[].layers with True value, are there any built-in ways to get what is on a layer?

$\endgroup$
8
$\begingroup$

There is no special property or method to retrieve all objects on a certain layer in Blender. There is a context member visible_objects, but multiple properties affect it (visibility of object, visibility of layer).

Thus, you should use a plain Python list comprehension:

objects_on_2nd_layer = [ob for ob in bpy.context.scene.objects if ob.layers[1]]
| improve this answer | |
$\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.