how can I assign colours to a specific face/polygon in the python API? I have found a way of creating materials, but how can I use them through the API on chosen polygons of an object? Does an object have to be fully covered with a material before you can change that of individual parts?

Thank you for your time!


The mesh doesn't have to be fully covered with a material, but it does have to have material slots(at least two) if you want to be able to change individual parts.

import bpy

obj = bpy.data.objects['Cube']
mat = bpy.data.materials['Red']
mat_slots = obj.material_slots
polys = obj.data.polygons

#add a material slot using a material

#remove material from material slot
mat_slots[0].material = None

#add the material slot that will be used for individual face

#apply material to one face
polys[0].material_index = 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.