2
$\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$
  • $\begingroup$ You can find the answer here $\endgroup$ – João Cartucho May 24 '19 at 7:48
1
$\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
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.