Did you know, you can assign different materials (eg:colors) to different faces in a polygon?
Before Blender 2.8 you could get a list of the materials used for each Face with:
for aFace in anObject.data.polygons : print ("material: ", face.material_index)
However, in Blender 2.8, I guess 'material_index' is no longer a property of polygons. I'll show you:
>>> anObject.data.polygons.material_index
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
AttributeError: 'bpy_prop_collection' object has no attribute 'material_index'
How can I walk through polygons or faces and get the material_index for each?
Trying to write a file exporter for faces and their colors.
anObject.data.polygons[index].material_indexwhere index is the face index. It is a property of a polygon, not of the polygons collection. – batFINGER Jun 20 '20 at 14:35Mesh.facescollection was renamed toMesh.polygonswith the introduction of ngon faces (over 4 verts). The first piece of code usesaFaceas iter variable, instead you are trying to print one namedface. The second is as pointed out in first comment.material_indexhas never been a property of the polygons collection. There is no need for a new 2.8 answer if there is no change. – batFINGER Jun 23 '20 at 04:19