2
$\begingroup$

I want to make custom node that can be used in compositing nodes. I stuck in part when I need to pass color value (and do some operation on that) from input to output socket.

def init(self, context):
    inp = self.inputs.new('NodeSocketColor', "Input 1")
    inp2 = self.inputs.new('NodeSocketColor', "Input 2")

    out = self.outputs.new('NodeSocketColor', "Out")
    out2 = self.outputs.new('NodeSocketColor', "Out 2")
  1. I don't know how to set up links (inp -> out, inp2 -> out2). Outputs are always connected to the first input socket.
  2. How to change value before outputting.
$\endgroup$

1 Answer 1

1
$\begingroup$

From the code above I'm not exactly sure how to give a contextually direct solution, but in an attempt to help move along the issue...

  1. Set up a node tree reference:

    tree = bpy.context.scene.node_tree

  2. Set up a link reference:

    your_links = tree.links

  3. Make your links:

    your_link = your_links.new(your_node.outputs[0],another_node.inputs[0])

To change the values you could do something like:

your_node.inputs[0].default_value = 0.3
$\endgroup$
1
  • $\begingroup$ As I understand your answer, you are talking about linking few nodes to solve a problem. I was thinking about making a singular custom node performing complex algorithm. $\endgroup$ Commented Aug 4, 2015 at 13:47

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.