Selecting objects with no materials

For quickly finding and selecting objects that do not have materials, we can use the Blender Python API and write a script consisting of just a few lines.

First, we need to loop through all the objects in the scene and process only those of them that are of type “mesh”:

In the simplest case, when a mesh can either have only one material or no material at all, we can check the mesh’s active_material property, which is the pointer to the mesh’s currently active material. If this property is not empty, then the mesh has material.

To select a mesh, we will use the select_set method, in the parameter of which we will pass an assessment of the presence of a material: False – if there is a material (such meshes do not need to be selected) and True – if there is no material.

For an active object that has no active material:

And all together:

This way we select objects that do not have active material.

However, a more complicated case is also possible, when the object has a material, but it is not active, because, it is not located in the active material slot.

Not to include such objects in our selection, let’s change the code a bit.

First, let’s check if the object has material slots. If not – select it.

If there are slots, check if there is at least one slot in which there is material, and if there is no such slot, select the object:

And all together:

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments