In Blender 2.8, I have an image/plane ("sky") serving as a background that shows an unwanted shadow from an object in the foreground. Manually, I can eliminate the unwanted shadow on the background 'Sky' by changing the "Diffuse BSDF" shader to "Emission."

I would like to do this in Python, but my code doesn't produce the desired result. Instead, the entire background image goes either gray or purple depending on which lines are executing. I have noted where the code starts to create unwanted results.

Any suggestions would be much appreciated. Thanks in advance!

bpy.ops.object.select_all(action='DESELECT')
bpy.data.objects['Sky'].select_set(True)
obj=bpy.data.objects['Sky']
skymaterial = bpy.data.materials.new('SkyMat')
obj.active_material = skymaterial  #UNWANTED RESULTS START HERE
skymaterial.use_nodes = True
nodes = skymaterial.node_tree.nodes
nodes.clear()


I suggest that you learn how to do this manually first.

To create any material you will need a material output and link the emissive shader to that. Use the Shader Editor to review your result.

import bpy

bpy.ops.object.select_all(action='DESELECT')
bpy.data.objects['Sky'].select_set(True)

obj = bpy.data.objects['Sky']

skymaterial = bpy.data.materials.new('SkyMat')
obj.active_material = skymaterial  #UNWANTED RESULTS START HERE
skymaterial.use_nodes = True
nodes = skymaterial.node_tree.nodes
nodes.clear()

# Create needed Nodes