In my script, and thanks to brockmann!.. I have added a texture (in the Texture Editor) and also added a Texture Node (in the compositor). The Texture is connected to the Texture Node and that works great. I would like to add two new sockets to change the values of one of the Nodes in the Texture editor

For example,

I have a blend Node in the Texture Editor, and I want to be able to change the colors of the blend.

enter image description here

I figured out how to add a socket (which was pretty simple) but they do not control the colors, I am not sure how I would now connect the new sockets to the texture blend node..

I added the sockets to my Texture node like this

    comp_node_texture.inputs.new('NodeSocketColor', 'Color 1')
    comp_node_texture.inputs.new('NodeSocketColor', 'Color 2')

enter image description here

But I now need them to be connected?


If I understand the question correctly, you want to set node inputs values.

Say you have added texture node so that it can be accessed like so, for instance:


Then input slots are already created and you don't need to create the slots.

You can for instance:

node.inputs[0].default_value = (0,0,0,1)
node.inputs[1].default_value = (1,1,1,1)

An easy way to identify Python accesses is to use the tooltips:

enter image description here

To connect texture node output for blend node first input:

import bpy

tree = bpy.data.textures['Texture'].node_tree

texture_node = tree.nodes['Texture']

blend_node = tree.nodes['Blend']

tree.links.new( texture_node.outputs[0], blend_node.inputs[0] )
| improve this answer | |
  • $\begingroup$ I have added Nodes in the Texture editor, one of them is a blend node.. I have also added a Texture Node in the Compositor. I would like to be able to change the colors of the blend node with the texture node.. So I have added the sockets but they are not connected to anything. $\endgroup$ – Darkfall Sep 22 '19 at 8:33
  • $\begingroup$ So you mean you want to connect the texture node output as input for the blend node? That's it? $\endgroup$ – lemon Sep 22 '19 at 8:42
  • $\begingroup$ sorry if I am not being clear. I just added two images to the post it may help. I have created a texture in the Texture editor and added a blend node (as in picture 1) and then in the compositor editor, I have added a texture node and connected the material (as in picture 2). I want to be able to control the colors of the blend node but on the Texture node. So I don't have to switch windows to change each color of the blend node. I have added sockets but they are useless since I am not sure how to make it work. $\endgroup$ – Darkfall Sep 22 '19 at 8:48
  • 1
    $\begingroup$ Oh, ok, you want to connect a texture node tree into the compositor node tree? $\endgroup$ – lemon Sep 22 '19 at 8:51
  • $\begingroup$ If that would give me control then yeah I think so.. $\endgroup$ – Darkfall Sep 22 '19 at 8:53

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.