Why does "material_index" return zeros?
The number 'zero' is just a zero based enumerator (eg: 0th,1st,2nd...etc) for the material used on your polygon.
I think, that the enumerator order corresponds to it's position in the (Materials?) editor scroll box.
If you want to see '1'. Create a new material, select your object or a face of it and &quot;Assign&quot; (Button) the object to the second Material in the list. Re-run your script.
..oh, also &quot;set&quot; only contains unique values. So if all your polgons use material '0' there will only be one entry.