Is there a way to find and utilize the index of objects that share the same modifier/geometry nodes data?

In the modifier stack when multiple objects share the same Geo Nodes group/any modifier, the number is indicated such as the image below. Is there a way to access this data within Geometry Nodes?

enter image description here


1 Answer 1


I don't know of any UI level tool to do this currently, but here's a python snippet that lists all the objects using the same geometry nodes as the active one:

import bpy

obj_act = bpy.context.active_object
mod_act = obj_act.modifiers.active
if mod_act and mod_act.type=='NODES':
    users = [obj for obj in bpy.data.objects if any(mod for mod in obj.modifiers if mod.type=='NODES' and mod.node_group==mod_act.node_group)]
  • $\begingroup$ I've been considering making an addon for "advanced node search" for a while. It would have features like this one for searching objects that use a given node tree, or instances of the selected node group, stuff like that. I almost expect there to be an addon for it already that i'm just not aware of, it just seems so incredibly useful. $\endgroup$
    – user436
    Commented Jun 10, 2022 at 8:11
  • $\begingroup$ Thank you for this. Would it be possible to then have this script run within the Geo Nodes network? The reason I want this is to utilise the number of objects as a seed value on a Random Value node - effectively giving a different seed to every object with this Node Tree. $\endgroup$ Commented Jun 10, 2022 at 8:30
  • $\begingroup$ You could use it to assign an integer value to a geonodes input, but not inside the geonodes themselves. I wouldn't recommend doing this as a driver though, there are no guarantees on the order of objects in the bpy.data list, so this could change after file reload, etc. Instead you could run a script like this as a user tool, assign a "UID" geonode input value, and then re-run the script when necessary if you add more objects. That way the UID remains stable until you deliberately change it, and you don't have to go through the hassle of setting up custom driver functions. $\endgroup$
    – user436
    Commented Jun 10, 2022 at 8:43
  • $\begingroup$ A custom driver would basically act as polling every time a node tree is evaluated. It would require enabling script auto-exec, but would ensure the data is always up-to-date. $\endgroup$ Commented Jun 10, 2022 at 11:38

You must log in to answer this question.

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