3
$\begingroup$

How can I get geometry nodes group node-tree name? With this code I can get the name of node, but I need get name of node-tree assigning to this node group instead.

parent_group = bpy.data.node_groups['MY NODE GROUP PARENT']
    for nod in parent_group.nodes:
        if nod.type == 'GROUP':
            my_node_grp = nod

    # Try to get name of group I need name of node tree not node name or label
    print(my_node_grp.name)

enter image description here

If you are interested in why I need this, I actually want to write a script for searching my groups in node graphs

$\endgroup$

1 Answer 1

4
$\begingroup$

You do need to somehow identify the group node in the parent group. Let's say you know the name of the node that is "Group" as in your screenshot. That node called "Group" has data linked to it. That data is a node tree called "I NEED THIS NAME", so:

import bpy


parent_group = bpy.data.node_groups['MY NODE GROUP PARENT']
try:
    node = [n for n in parent_group.nodes if n.name == "Group"][0]
    name = node.node_tree.name
    print(name)
except: 
    print('Failed to find "Group"')
$\endgroup$
1
  • $\begingroup$ Great! ".node_tree.name" instead ".name" works fine! Thanks Martynas! $\endgroup$
    – 3D-buch
    Aug 2, 2023 at 22:38

You must log in to answer this question.

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