7
$\begingroup$

How can I see all the "users" of a datablock? Is it possible with the Blender's UI? With Python?

For example, I'd like to know which 3 objects are the users of my material:

enter image description here

$\endgroup$
3

1 Answer 1

5
$\begingroup$

Without Python:

You can simply select one of the objects and use Shift+L > Material to select all the objects that share the same material. If the object has more than one material, it'll check for the one that's currently active.

With Python:

It's a bit of a workaround. Each material has the attribute users, but this is only the number of users and not actually a list of objects/data.

So in order to get a list of all the objects that use a certain material, we have to loop through the objects, then through each object's material slots:

import bpy

objects = bpy.context.selectable_objects
mat = bpy.context.object.active_material

for obj in objects:
    for slot in obj.material_slots:
        if slot.material == mat:
            obj.select = True
$\endgroup$
1
  • 2
    $\begingroup$ Another non-python way is to search with the outliner $\endgroup$
    – sambler
    Commented Jun 24, 2014 at 8:18

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