I’m searching for an idea to label the polygons of my mesh with different multiple labels.
So far I’m using vertex groups, putting all the vertices belonging to polygons that share a label into one vertex group.
But storing that information in vertices is not bidirectional, because as you can see in this Image, all 3 vertices got the information they belong to the yellow and the blue label and in the end the mid polygon is blue and yellow instead of only blue.
Can this be achieved with materials? Afaik there is only one material_index per polygon.
Is it possible to store more than one material to a polygon? (I don’t care which one is displayed as long as I can read it via python)
Maybe polygon_layers. Haven’t used these myself, the following produces a string layer with a value for every poly in the mesh. The layers are saved with the file. I’m “assuming” that the indexes match those of the polygons in the mesh.
An int ( as boolean) layer for each material would be one way to utilise polygon layers to store multiple material indexes per poly.
Its just a list with the same length as the polygon count in the mesh.
Every list item is associated with a polygon.
So you can store strings, ints or floats to every polygon.
Thats how I’m using it, reduced to an example.
#save triangle index in the polygon_layers_int
me = context.selected_objects
for idx,poly in enumerate(me.data.polygons):
me.data.polygon_layers_int["triangle"].data[idx].value = idx