Python access to Render Pass in Viewport?

Hi how do I get python access to the render pass in the viewport cycles preview?
I mean this:

image

INFO editor reports:
bpy.data.screens["Layout"].(null) = 'COMBINED'

checkmarks up above are:
bpy.context.space_data.shading.use_scene_lights_render
and
bpy.context.space_data.shading.use_scene_world_render

edit:
right-click + “Edit source” returns error:
Active button match cannot be found
while hovering on it for python baloon gives me:

image

BTW

if I type bpy.context.space_data. in the console editor the autocompletion doesn’t give any “shading” property, is it because the context (console) is wrong?
It actually works in an addon I made, where I have a button operator in the 3d view.

3 Likes

I’m bumping this up a bit…

In case you are still looking for it:
you can access it using bpy.context.space_data.shading.cycles.render_pass

2 Likes

Ops! I forgot to update this thread.
I found that solution thanks to someone on BA, but thanks anyway :slight_smile: