Face materials

I have a solid brep with multiple materials on its faces.
I need to differentiate faces by materials, but I can only return the index of one of the materials. How can I get material indices for all faces?

Hi @p-e-t-e-r,

BrepFace.MaterialChannelIndex specify a material channel index used by the Brep face.

If this value is 0, then the object’s material is used to render the face. Otherwise the material with the id returned by Material.MaterialChannelIdFromIndex is used to render the face.

– Dale

1 Like

Hello Dale. I tried to understand the question with your help, but I just can’t understand the relationship between MaterialChannelIndex and materials from MaterialTable. With 0 index it is clear, but what others mean, I cannot figure it out. Would really appreciate your more detailed hint.

Also, I replaced that each time a material is assigned to BrepFace, the MaterialTable list is updated with new items, despite the fact that there are still 3 materials in the Rhino material editor.


Hi @p-e-t-e-r,

If base_material is the material assigned to render this Brep, and face_material_id = base_material.MaterialChannelIdFromIndex(material_channel_index) is not an empty GUID, then face_material_id identifies an override rendering material for this face. Otherwise base_material is used to render this face.

Does this help?

– Dale

1 Like

Yes, everything worked out! Thanks a lot!