.new() does not work when trying to create new sockets on a group input or group output node
Closed, ResolvedPublic

Description

Broken: 2.75-2.78
Worked: I ran code like this before and it worked, but I cannot remember a version number

Short description of error
Adding a new input socket to a group output node and adding a new output socket to a group input node do not work. If you run the code below, the lines that try and add sockets have no affect. I found a workaround, which is linking to the NodeSocketVirtual multiple times.

Exact steps for others to reproduce the error

import bpy

mat = bpy.data.materials.new("test")
mat.use_nodes = True    
ng = bpy.data.node_groups.new(name="issue", type="ShaderNodeTree")
nodes = ng.nodes

n = mat.node_tree.nodes.new("ShaderNodeGroup")
n.node_tree = ng

group_in = nodes.new("NodeGroupInput")
group_in.location = (-200, 0)
group_out = nodes.new("NodeGroupOutput")
group_out.location = (200, 0)
diff = nodes.new("ShaderNodeBsdfDiffuse")

group_in.outputs.new("NodeSocketColor", "color")  # line has no affect
group_out.inputs.new("NodeSocketShader", "shader")  # line has  no affect


#ng.links.new(group_in.outputs[0], diff.inputs[0])
#ng.links.new(group_in.outputs[1], diff.inputs[1])

Details

Type
Bug
Jacob Morris (BlendingJake) changed the title from ".new does not work when trying to create new sockets on a group input or group output node" to ".new() does not work when trying to create new sockets on a group input or group output node".Jan 12 2017, 3:27 PM

I can not reproduce this working on 2.77 which does not match with the report, which version did this work on, can you retest please?

Have you tested with the 'a' releases?

I can not reproduce this working on 2.77 which does not match with the report, which version did this work on, can you retest please?

Have you tested with the 'a' releases?

I just tested 2.75-2.78a and none of them work. I have in the past run code that used .new() to create sockets on group input and group outputs nodes, but I cannot remember a version number.

ng.outputs.new("NodeSocketColor", "color")  
ng.inputs.new("NodeSocketShader", "shader")

will probably work.

ng.outputs.new("NodeSocketColor", "color")  
ng.inputs.new("NodeSocketShader", "shader")

will probably work.

That does seem to work! However, why would group_input.outputs.new() and group_output.inputs.new() not work?

Joey Ferwerda (TheOnlyJoey) closed this task as "Resolved".Jan 19 2017, 5:00 PM
Joey Ferwerda (TheOnlyJoey) claimed this task.