3
$\begingroup$

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
$\endgroup$
1
  • $\begingroup$ You can find the answer here $\endgroup$ May 24, 2019 at 7:48

1 Answer 1

2
$\begingroup$

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
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .