Unable to create group input/output sockets with python #37776

Closed
opened 2013-12-11 08:09:16 +01:00 by Shane Ambler · 5 comments

System Information
FreeBSD 9.2 amd64 Nvidia gt520

Blender Version
Broken: Blender 2.69
Worked: Blender 2.66

Short description of error
Using python I can create a group and add group input and output nodes but I can't add sockets to these nodes to connect anything to. I can create and connect other nodes within the group.

Exact steps for others to reproduce the error
In 2.66 the following script works, it creates a group, adds a node and connects the node to the group in/out sockets.

test_group = bpy.data.node_groups.new('testGroup', 'SHADER')
test_group.inputs.new('in_to_nodes','VALUE')
test_group.outputs.new('out_result','VALUE')

node_add = test_group.nodes.new('MATH')
test_group.links.new(test_group.inputs[0], node_add.inputs[0])
test_group.links.new(node_add.outputs[0], test_group.outputs[0])

From 2.67 node groups started to be edited over the top of the nodes display, this introduced group input and output nodes. This would mean the script would be changed to

test_group = bpy.data.node_groups.new('testGroup', 'ShaderNodeTree')

group_inputs = test_group.nodes.new('NodeGroupInput')

group_outputs = test_group.nodes.new('NodeGroupOutput')

node_add = test_group.nodes.new('ShaderNodeMath')
node_add.operation = 'ADD'

While that much works in python I can't get a new input or output socket created to make connections.

I expect group_inputs.outputs.new() to be the way to do this but it fails without error.

group_inputs.inputs.new() does create sockets but on the wrong side showing an error - Undefined Socket Type

Manually created sockets appear to be available in test_group.inputs but test_group.inputs.new() also fails without error.

There is an operator bpy.ops.node.tree_socket_add() that will create sockets but it is only available when a node editor is in context.

**System Information** FreeBSD 9.2 amd64 Nvidia gt520 **Blender Version** Broken: Blender 2.69 Worked: Blender 2.66 **Short description of error** Using python I can create a group and add group input and output nodes but I can't add sockets to these nodes to connect anything to. I can create and connect other nodes within the group. **Exact steps for others to reproduce the error** In 2.66 the following script works, it creates a group, adds a node and connects the node to the group in/out sockets. ``` test_group = bpy.data.node_groups.new('testGroup', 'SHADER') test_group.inputs.new('in_to_nodes','VALUE') test_group.outputs.new('out_result','VALUE') node_add = test_group.nodes.new('MATH') test_group.links.new(test_group.inputs[0], node_add.inputs[0]) test_group.links.new(node_add.outputs[0], test_group.outputs[0]) ``` From 2.67 node groups started to be edited over the top of the nodes display, this introduced group input and output nodes. This would mean the script would be changed to ``` test_group = bpy.data.node_groups.new('testGroup', 'ShaderNodeTree') group_inputs = test_group.nodes.new('NodeGroupInput') group_outputs = test_group.nodes.new('NodeGroupOutput') node_add = test_group.nodes.new('ShaderNodeMath') node_add.operation = 'ADD' ``` While that much works in python I can't get a new input or output socket created to make connections. I expect group_inputs.outputs.new() to be the way to do this but it fails without error. group_inputs.inputs.new() does create sockets but on the wrong side showing an error - Undefined Socket Type Manually created sockets appear to be available in test_group.inputs but test_group.inputs.new() also fails without error. There is an operator bpy.ops.node.tree_socket_add() that will create sockets but it is only available when a node editor is in context.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @sambler

Added subscriber: @sambler
Member

Added subscriber: @gandalf3

Added subscriber: @gandalf3
Author

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Shane Ambler self-assigned this 2013-12-11 11:55:43 +01:00
Author

We found the missing link, use NodeSocketFloat instead of VALUE for group.inputs.new()

test_group.inputs.new('NodeSocketFloat','grpInput')
test_group.outputs.new('NodeSocketFloat','grpOutput')

Though it would be helpful if inputs.new('VALUE','grpInput') provided some sort of error.

We found the missing link, use NodeSocketFloat instead of VALUE for group.inputs.new() ``` test_group.inputs.new('NodeSocketFloat','grpInput') test_group.outputs.new('NodeSocketFloat','grpOutput') ``` Though it would be helpful if inputs.new('VALUE','grpInput') provided some sort of error.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#37776
No description provided.