Python Render Properties Tab 2.8

Hello!

I am very new to Python and I would like to be able to make a script that will change certain values in the Properties Window.

I am currently able to change the Render Engine with this line:
bpy.context.scene.render.engine = ‘BLENDER_WORKBENCH’

Then I tried to change the Lighting to Matcap with this line:
bpy.context.scene.shading.light = ‘MATCAP’

but I get an Error message saying:
AttributeError: ‘Scene’ object has no attribute ‘shading’

I took both code lines from the script listener of Blender, so I don’t know what I am missing.

Thank you in advance for your help and have a nice day! :slight_smile:

Hi,
for matcap, I got :

bpy.context.space_data.shading.light = ‘MATCAP’

I tried your line but I still get the same error message when I press F5 in the scripting tab to test the script.

I found this.

import bpy

area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')

for sp in area.spaces:
    if sp.type == 'VIEW_3D':
        sp.shading.light = 'MATCAP'
1 Like

This only affect the solid mode of the 3D View.
I am trying to access the Propertirs editor.

Try this one:

bpy.context.scene.display.shading.light = 'MATCAP'
1 Like

So it seems to be a mix of both Xylvier and Elreenys last answers.

import bpy

area = next(area for area in bpy.context.screen.areas if area.type == ‘VIEW_3D’)

for sp in area.spaces:
if sp.type == ‘VIEW_3D’:
bpy.context.scene.render.engine = ‘BLENDER_WORKBENCH’
bpy.context.scene.display.shading.light = ‘MATCAP’
bpy.context.scene.display.shading.show_cavity = True

Thank you guys so much for your help I really appreciate it :slight_smile: