0
$\begingroup$

Is there a way to search and select all nodes with a certain name within the GN node editor? I asked about this in blender chat in the past, but no one came up with an immediate solution.

However, I came across this blender exchange answer today and would like some help to modify it for Geometry Node editor.

Is it possible to select all of one type of node in the node editor?

import bpy

#Get composite nodes
nodes = bpy.context.scene.node_tree.nodes
#Get indentifer of the active node
find_type = bpy.context.scene.node_tree.nodes.active.bl_rna.identifier
#loop through nodes
for node in nodes:
    #if node has the same idetifier
    if node.bl_rna.identifier == find_type:
        #select it
        node.select = True

(If this is already possible via an existing addon, please let me know in reply, thx in advance!)

$\endgroup$
3
  • $\begingroup$ on Blender 3.2 at least this gave me this error: line 6, in <module> AttributeError: 'NoneType' object has no attribute 'bl_rna'. $\endgroup$
    – Zhen Dai
    Jul 23, 2022 at 12:17
  • $\begingroup$ You need to select (click on) a node first $\endgroup$
    – Gorgious
    Jul 23, 2022 at 12:26
  • $\begingroup$ @Gorgious it did not work with a node selected (my error happens when I have a node selected) $\endgroup$
    – Zhen Dai
    Jul 23, 2022 at 13:16

1 Answer 1

4
$\begingroup$

You can modify it this way to get the nodes from a node space. If there are many geometry node spaces, it will use the nodes from the last one.

import bpy

for window in bpy.context.window_manager.windows:
    for area in window.screen.areas:
        for space in area.spaces:
            if (space.type == 'NODE_EDITOR' and space.tree_type == 'GeometryNodeTree'):
                nodes = space.node_tree.nodes

#Get identifer of the active node
find_type = nodes.active.bl_rna.identifier
#loop through nodes
for node in nodes:
    #if node has the same idetifier
    if node.bl_rna.identifier == find_type:
        #select it
        node.select = True
$\endgroup$
2
  • $\begingroup$ I have GN editor open and a Group Input node selected by it still gives me this error: line 7, in <module> AttributeError: 'SpaceImageEditor' object has no attribute 'node_tree' $\endgroup$
    – Zhen Dai
    Jul 23, 2022 at 13:15
  • $\begingroup$ for future readers, the updated answer now works $\endgroup$
    – Zhen Dai
    Jul 23, 2022 at 13:39

You must log in to answer this question.

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