3
$\begingroup$

I need to programatically modify the value of Material > Surface(Emission) > Strength enter image description here

When I change this value manually the output is: bpy.context.space_data.context = 'DATA' bpy.data.node_groups["Shader Nodetree"].nodes["Emission"].inputs[1].default_value = 1.2

enter image description here

But this command produces an error on the console:

>>> bpy.data.node_groups["Shader Nodetree"].nodes["Emission"].inputs[1].default_value = 2
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
KeyError: 'bpy_prop_collection[key]: key "Shader Nodetree" not found'

I also tried accessing a surface attribute of the material but this doesn't work either:

>>> bpy.data.materials['light_emit.002'].surface
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
AttributeError: 'Material' object has no attribute 'surface'

Besides, where can I find the api reference to try solve these problems by myself in the future?

$\endgroup$

1 Answer 1

6
$\begingroup$

Found a solution:

bpy.data.materials['material_name'].node_tree.nodes["Emission"].inputs[1].default_value = 3 #or any other value

Thanks to this reference

$\endgroup$
2

You must log in to answer this question.

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