How can I distinguish the type of node in Python when importing node groups from other files?
I want, after I read a folder with blend files and search in the files for objects of type node_groups, to set a different action depending on the type of the group.
The crucial thing is: The type of the nodes must be clearly recognizable in this case BEFORE the node has even been imported!
Finally there are GeometryNodeTree, ShaderNodeTree, CompositorNodeTree and TextureNodeTree, but I somehow can't find a way to query this type.
This is the code I use to read the files:
for fn in os.listdir(dirpath):
filepath = os.path.join(dirpath, fn)
with bpy.data.libraries.load(filepath) as (data_from, data_to):
for group_name in data_from.node_groups:
print("Very well, and what type are we talking about here?")
What do I need this for?
I would like to improve the addon Node Presets and here it needs a distinction of the nodes, so that not for each node type a separate path must be specified: How can I use custom node groups as node templates (Blender 3.1)?