2
$\begingroup$

Is there a method, e.g., python script or add-on, to identify objects and/or mesh that do not have an assigned material? Something that works with > 2.9. There are old scripts on the internet, e.g., 2.8, but they don't work with latest blender.

$\endgroup$

1 Answer 1

4
$\begingroup$
import bpy

for object in bpy.data.objects:
    if object.type == 'MESH':
        found = False
        if object.material_slots:
            for slot in object.material_slots:
                if slot.material:
                    found = True
                    break
        if not found:
            print(object.name)
        

This script will print the name of any object that is a mesh but has no materials assigned. It should work for any version of Blender since 2.8. You can replace the print with whatever you want to do with the objects, of course.

If an object has no material_slots then obviously it has no assigned materials. But, as pointed out in a comment, it could have material_slots and they could all be empty. So we look for the first material slot that has a material assigned.

$\endgroup$
2
  • $\begingroup$ This will identify an object with no material slots. I want to identify an object whose mesh, or just a portion of its mesh, does not have an assigned material, even if there are material slots assigned. $\endgroup$
    – G Lap
    May 11, 2022 at 7:05
  • $\begingroup$ @GLap I've added the loop for checking existing material slots. $\endgroup$ May 11, 2022 at 16:00

You must log in to answer this question.

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