0
$\begingroup$

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: enter image description here

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

You should use the SpaceView3D.layers attribute.

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

$\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.