Assign Material Slot to no material via python I'd like to, in code, remove a material from a material slot without deleting that material slot (because deleting it would remove the connections between that material slot and the vertices). The only code I've found that can remove materials also deletes the material slot: bpy.ops.object.material_slot_remove()

I've also tried to use the property_unset function in the material slot, but it just doesn't seem to do anything. For example: C.object.material_slots[0].property_unset('material')

Setting the material to something else is fairly straightforward, but setting it to NULL seems impossible, even though it's easy to do via the interface.

This is related to, but not solved by:Python - Set material to material slot
Its as easy as bpy.context.object.data.materials[0] = None. Check this answer How to assign a new material to an object in the scene from Python? to see why and how it works.