I am trying to add a new input NodeSocket to an existing node using the below code:

tree = bpy.context.scene.node_tree
tree.nodes['File Output'].inputs.new('RGBA', 'Image')
tree.nodes['File Output'].update()

Below are the nodes that I have created for my blend file.

enter image description here

As shown in the above image, the "File Output" node has 5 input sockets. The above code should add a 6th one, however it is not adding. Am I missing something here?


Found out from here that instead of adding sockets to these node using the node.inputs collection, the node.file_slots or node.layer_slots collections should be used. Both of them work, they just provide slightly different properties for use with simple files or multi-layer EXR.

An example is posted here: http://pasteall.org/45535/python

  • 1
    $\begingroup$ Thanks. output_node.layer_slots.new("my_new_input_socket") $\endgroup$ – Sibbs Gambling Aug 25 '18 at 21:05

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.