📋 Metadata

💬 Content

Pinhead:

  1. (As a pie menu) Can I search and select objects with a given material without selecting any object? For example, a menu with a list of materials. I click on the material and all objects / components with the given material are marked.

Add a regular menu with 1 slot and this code in Custom tab:

col = L.column(); [operator(col, "pme.exec", text=m.name, icon_value=m.preview.icon_id, cmd="bpy.ops.object.select_all(action='DESELECT'); [o.select_set(True) for o in D.objects for ms in o.material_slots if ms.material and ms.material.name == '%s']; bpy.ops.ed.undo_push(message='Select Objects by Material')" % m.name) for m in D.materials]

And use the new regular menu in your pie menu (Menu tab)

Pinhead:

  1. (As a pie menu) Is there any command that would remove unused materials?

Command tab:

unused_mats = [m for m in D.materials if m.users == 0]; [D.materials.remove(m) for m in unused_mats]

Pinhead:

  1. …and remove empty Material slots?

Command tab:

[(setattr(o, "active_material_index", i), bpy.ops.object.material_slot_remove(dict(object=o))) for o in D.objects for i, ms in enumerate(o.material_slots) if not ms.material]

❤️ 4 likes


🔗 View on Blender Artists