# How to know which layer is active in a certain 3d view

I have couple of 3d views in my file, where all of them has layer 0 as the active layer and only one of them has layer 1 as the active layer. I wonder how I can check which layer is active in a 3d view, like in my case I want to know which 3dview has layer 1 active in it.

This is what I did so far:

import bpy

for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
if area.spaces.active.layers_used[1] == True: # <-- not working if other 3d views has layer 1 even if it's not active in this 3dview

#do something


like the one shown below:

• What do you mean by active, that its visible? the layer used when adding new objects? – ideasman42 May 3 '17 at 11:58
• @ideasman42 yes, the visible selected one – Tak May 3 '17 at 11:59

layers_used is for the layers that have content (as shown by the dots)