How can I connect nodes in a node group to the input or output sockets?
This connection here:
I can't figure out how to access the group node_tree
, and the Group node as well as the Group input/output nodes seem to be different than normal nodes.
My script so far:
import bpy
for area in bpy.context.screen.areas:
if area.type == "NODE_EDITOR":
override = {'screen': bpy.context.screen, 'area': area}
bpy.ops.node.select_all(override, action='DESELECT')
tree = bpy.context.object.active_material.node_tree
nodes = tree.nodes
links = tree.links
node = nodes.new(type='ShaderNodeMath')
node.operation = "ADD"
node.location = (100,0)
node_add = node
node = nodes.new(type='ShaderNodeMath')
node.operation = "GREATER_THAN"
node.name = "greater"
node.location = (-100,100)
links.new(node.outputs["Value"], node_add.inputs[0])
node = nodes.new(type='ShaderNodeMath')
node.operation = "LESS_THAN"
node.name = "less"
node.location = (-100,-100)
links.new(node.outputs["Value"], node_add.inputs[1])
bpy.ops.node.group_make(override)
bpy.ops.node.tree_socket_add(override, in_out='IN')
bpy.ops.node.tree_socket_add(override, in_out='IN')
bpy.ops.node.tree_socket_add(override, in_out='OUT')