I was trying to create a material and a texture, and then attach the texture to the material's Displacement slot, but I couldn't find the texture node's outputs through the Python api.
Here's my test scene:
import os, bpy bpy.context.scene.render.engine = 'CYCLES' # new texture texture=bpy.data.textures.new('tex', 'IMAGE') texture.use_nodes = True texnodes = texture.node_tree.nodes # new material mat = bpy.data.materials.new('mat') mat.use_nodes = True matnodes = mat.node_tree.nodes # assign texture to material's displacement disp = matnodes['Material Output'].inputs['Displacement'] mat.node_tree.links.new(disp, texnodes["Output"].color)
That last line threw the error:
TypeError: NodeLinks.new(): error with argument 2, "output" - Function.output expected a NodeSocket type, not Color
I've seen this method used elsewhere:
But if I try it in this situation, it throws this error:
AttributeError: 'ImageTexture' object has no attribute 'outputs'
The Plot Twist:
Then I discovered that if I create the texture directly on the material, like so:
texture.outputs method works, although then the texture node claims it doesn't have a
What's the difference between these two textures? Is there a way to make my first try work like the second? What's the best way to do this?