2

When the socket is not connected to other nodes, the script can be read into its variable. Everything is fine.

MyObjName = bpy.data.node_groups["MyGNStrings"].nodes["Group output"].inputs[1].default_value

The value object_test is written in variable MyObjName: enter image description here

But when I connect this socket to other sockets, its value is no longer readable by the script:

enter image description here

For each animation frame, I need to get my own object index, which will be contained in this socket.

Duarte Farrajota Ramos
  • 59,425
  • 39
  • 130
  • 187

1 Answers1

0

Have you or anyone tried to get the value via identifier? (I tested the code below for Group Input in Blender 4.1 ). Edit: Unfortunately, for Group Output it gives errors for me. Edit2: It works if you assign some value before you read the value!

    import bpy
in_input_id = bpy.data.node_groups["MyGNStrings"].nodes["Group Input"].inputs["InputObjectName"].identifier #this works 

value1 = bpy.data.objects['Cube'].modifiers['GeometryNodes'][in_input_id]  #or whatever the object
print("input_value=", value1)

out_input_id = bpy.data.node_groups["MyGNStrings"].nodes["Group Ouput"].inputs["OutputObjectName"].identifier #this get the identifier but not the value for below
bpy.data.objects['Cube'].modifiers['GeometryNodes'][out_input_id] = "test_string"

value2 = bpy.data.objects['Cube'].modifiers['GeometryNodes'][out_input_id]  #or whatever the object
print("output_value=", value2)  #KeyError: 'bpy_struct[key]: key "Socket_16" not found' (if you not assign some value to it!)