3

I am new to both Blender and Python, I am trying to enable Use Nodes of a lamp from Python console.

I tried the tooltip showing on the button bpy.ops.cycles.use_shading_nodes, it did not give me an error, but also did not really enable the nodes(no change in UI), and I cannot change lamp strength using:

C.object.data.node_tree.nodes['Emission'].inputs['Strength'].default_value = 100
Duarte Farrajota Ramos
  • 59,425
  • 39
  • 130
  • 187

1 Answers1

2

This is the python command used to enable Use Nodes and change a lamp strength

Blender 2.79

# enable Use Nodes
bpy.data.lamps["your_light_name"].use_nodes = True/False

# set strength, set the default_value to whatever you like
bpy.data.lamps["your_light_name"].node_tree.nodes["Emission"].inputs[1].default_value = 10    

Blender 2.8

# enable Use Nodes
 bpy.data.lights["your_light_name"].use_nodes = True/False

# set strength, set the default_value to whatever you like
bpy.data.lights["your_light_name"].node_tree.nodes["Emission"].inputs[1].default_value = 10