I have this code that creates a bunch of Obj Info nodes and joins them with a join geometry node. It is supposed to end by linking the Join Geometry node to the Group output node but it's failing to do that:
import bpy
# Create a new Geometry Nodes tree
nt = bpy.data.node_groups.new(name='NewGeometryNodesTree', type='GeometryNodeTree')
# Retrieve active object
active_object = bpy.context.active_object
# Create Geometry Nodes modifier on the active object
modifier = active_object.modifiers.new(name="Geometry Nodes", type='NODES')
modifier.node_group = nt
# Access the node tree within the modifier
nodes = modifier.node_group.nodes
links = modifier.node_group.links
#Create group output
group_output = nodes.new('NodeGroupOutput')
group_output.location.x = 600
group_output.location.y = 0
#Create group input
group_input = nodes.new('NodeGroupInput')
group_input.location.x = -500
group_input.location.y = 0
# Create nodes and set up the node tree
join_geo = nodes.new('GeometryNodeJoinGeometry')
join_geo.location.x = 300
for i, ob in enumerate(bpy.context.selected_objects):
if ob == active_object:
continue
node = nodes.new('GeometryNodeObjectInfo')
node.location = (-170 * (i % 2), i * 100)
node.inputs['Object'].default_value = ob
node.transform_space = 'RELATIVE'
links.new(node.outputs['Geometry'], join_geo.inputs['Geometry'])
links.new(join_geo.outputs['Geometry'], group_output.inputs['Geometry'])
I assume this is because the Group Output node doesn't have an input with the geometry type, since it's empty by default.
How can I give the Group Output node that Input type when I create it? Or alternatively, how can I connect the Join Geometry 'Geometry' output to the empty socket?
I've tried copying the code from the scripting tab but manually linking the nodes just generates code to link 2 coordinates and it doesn't work in the script. Creating the Input and setting it to Geometry on the Group Output also seems to create code that doesn't work when I copy and paste it after the creation of the Group Output node


group.interface.new_socket(name="Geometry", in_out="INPUT", socket_type="NodeSocketGeometry")see docs.blender.org/api/current/… $\endgroup$