1

I'm trying to fix:

bpy.context.scene.world.light_settings.use_environment_light = True
bpy.context.scene.world.light_settings.environment_energy = energy
bpy.context.scene.world.light_settings.environment_color = 'PLAIN'

to make them work in blender 2.8. I read Setting up a Sky: bpy.context.world = None, but my bpy.context.scene.world.node_tree is None. How would I set up a node tree and add the Background node?

It seems like the correct code should be something like bpy.context.scene.world.node_tree.nodes['Background'].inputs['Strength'].default_value = energy, but I can't figure out how to make the node_tree.

Any help would be greatly appreciated!

Ray Mairlot
  • 29,192
  • 11
  • 103
  • 125
prbodas
  • 11
  • 1
  • 2
    Can you please explain what you actually want to do? Setting up a custom environment using a hdri or just a plain color and up the strength? – brockmann Feb 24 '20 at 09:15
  • 1
    Once the world is created, just add something like: world.use_nodes = True This will create the node tree. – lemon Feb 24 '20 at 09:33
  • Related: https://blender.stackexchange.com/questions/132271/blender-2-8-get-environment-texture-path-from-ui-to-python-script – batFINGER Feb 24 '20 at 11:11
  • @brockmann i am trying to convert a neural net script, so i am not really sure what its supposed to do exactly - i just want to convert these lines as close to the original as possible – prbodas Feb 25 '20 at 04:18
  • @lemon thank you so much! that worked! – prbodas Feb 25 '20 at 04:31

0 Answers0