Can't create Output sockets for a NodeGroupInput, bug?

I was updating from 2.66 to 2.68 an importer that loads models with cycles materials and creates node groups.

I could update everything find reading the release notes, wiki and this bug report, but what I can’t figure out is why you can’t create node sockets (outputs) for a nodegroupInput unless you create a link to something first.

Examples:

  1. Manually you can’t create an output unless you link it to something

http://i44.tinypic.com/kuq6c.png

  1. Once you created a link, you can create as many new outputs as you want in the N panel.
    http://i39.tinypic.com/of0zzo.png

So this looks to me to a limitation both in python and in the UI compared to the old way node groups worked.
This code should create a nodeGroupInput with all the sockets(outputs) I want but it doesn’t, and it doesn’t give any warnings either. It just creates a Group input without any socket/outputs:


import bpy

NodeGroup= bpy.data.node_groups.new("GroupTest", type='ShaderNodeTree')

Input_group = NodeGroup.nodes.new("NodeGroupInput")
Input_group.outputs.new('RGBA', "Tex Diffuse")
Input_group.outputs.new('RGBA', "Tex Specular")
Input_group.outputs.new('RGBA', "Tex Normal")

Can someone confirm this looks like a bug?
This is something important for scripts since you want to create only one group with their inputs but they might not be used always in all materials.

I wrote a group node writer a while ago and this was the way i handled inputs / outputs


import bpy


x = bpy.data.node_groups.new("rayTransparency","ShaderNodeTree")
ngo = x.nodes.new(type="NodeGroupOutput")
ngi = x.nodes.new(type="NodeGroupInput")




mth = x.nodes.new(type="ShaderNodeMath")




x.links.new(mth.inputs[0],ngi.outputs[0])


x.links.new(mth.outputs[0],ngo.inputs[0])
x.inputs[0].name = "Transparency"
x.inputs[0].default_value = 1
x.outputs.new


Pretty much you cant just hit create new for some strange reason in python… you have to link it to a socket then rename.

Yeah, that’s my point, in the previous way of creating nodes by python was much convenient. I couldn’t find any discussion about this though.

maybe submit it as a bug to the bug tracker?

Yeah, I think I will because in this case in 2.67 when the node groups were overhauled this counts like a broken features. But any other opinion before submitting will be good

is this a bug ?

i think there are other bug also for some other method to access I/O
but will avhe to see it it is corrected
right now only way i was able to do it was with index method
other 2 methods did nto work!

thanks

Well, I opened a bug and Lukas pointed me in the right direction thankfully.
Turns out you don’t have to reference the Input group node, but group.inputs, as in 2.67.

can you show update example

thanks

Ricky, Lucas posted this:


import bpy
TestGroup = bpy.data.node_groups.new("Test", type='ShaderNodeTree')
Input_node = TestGroup.nodes.new("NodeGroupInput")

# Use the nodetree.inputs/outputs collections for extending the node group interface
TestGroup.inputs.new('NodeSocketColor', "Tex Diffuse") 
TestGroup.inputs.new('NodeSocketColor', "Tex Specular")

cheers