0
$\begingroup$

I'm trying to make a list of inputs to a GeometryNode Node I created. I've done this before in Blender 3.6 like so: input_names = [input.name for input in bpy.data.node_groups["Neuron"].inputs if input.name != "Geometry"]

Neuron is the name of the Node Tree I've created. The problem with this line of Python code is that it doesn't work in Blender 4.1. Apparently bpy.data.node_groups["Neuron"] doesn't have attribute inputs anymore. enter image description here

These are the input names I want to put in a list. I've been able to access the float values and Input_XX number names like: for key in bpy.data.objects[“Raft L (Microscope)”].modifiers[“GeometryNodes”].keys(): print(bpy.data.objects[“Raft L (Microscope)”].modifiers[“GeometryNodes”][key])

but I haven't been able to find the Attribute (or input) names anywhere.

I've also tried: bpy.data.node_groups[“Neuron”].nodes bpy.data.node_groups[“Neuron”].nodes[“Group Input”].inputs.values() bpy.data.node_groups[“Neuron”].nodes[“Group Input”].inputs.keys() bpy.data.node_groups[“Neuron”].nodes[“Group Input”].inputs.items()

and I couldn't find the names I'm looking for in there either.

Does anyone know how to access these Node input names?

$\endgroup$

1 Answer 1

0
$\begingroup$

It was: node_groups["Neuron"].inputs

It changed to node_groups["Neuron"].interface.items_tree


*So the whole line would look this way:

input_names = [input.name for input in bpy.data.node_groups["Neuron"].interface.items_tree if input.name != "Geometry"]

**But since the line became longer - it's not quite rational to keep the code as a single line anymore.

Hence I'd prefer to wright it in the multiple lines:

input_names = []

for input in bpy.data.node_groups['Neuron'].interface.items_tree:
    
    if input.name != 'Geometry':
        
        input_names.append(input.name)
$\endgroup$
1
  • 1
    $\begingroup$ but, list comprehension is faster than for loop. $\endgroup$
    – Karan
    Commented Apr 20 at 10:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .