1

I'm trying to change the values of Wave Texture (Shader Editor) by python: I mean that I what to change the value of Distortion or Detail Scale by python code.

wave_texture = bpy.data.objects['plane'].active_material.node_tree.nodes['Wave Texture']

I stack at this point, how I get and set Distortion for example.

1 Answers1

2

You can access a node input sockets by either their name or their rank using their inputs property:

distortion_socket = wave_texture.inputs['Distortion']

or

distortion_socket = wave_texture.inputs[2]

Then you can set the value using default_value (the value not given by a link):

distortion_socket.default_value = 2
lemon
  • 60,295
  • 3
  • 66
  • 136
  • Using the index (rank) is fail-safe in case user is using another language. Console is a handy way to enumerate them https://blender.stackexchange.com/a/160069/15543 – batFINGER Sep 20 '20 at 08:20