C# MeshFace from Mesh

Below is a faulty code that fails converting mesh.Faces to either List(List) or MeshFace (Line 3)
I was wondering, if Line 4 (MeshFace face = mesh.Faces[2]:wink: works, why this is not the case for the List or Array as in Line 3?
What would be the proper and direct way to get list of MeshFace(s) from Mesh without using for/foreach?

Capture

Hi @AndrewAhn,

How about this?

List<MeshFace> face_list = null;
if (null != mesh)
{
  face_list = new List<MeshFace>();
  face_list.AddRange(mesh.Faces);
  // TODO...
}

You can also do this:

List<MeshFace> face_list = null;
if (null != mesh)
{
  face_list = new List<MeshFace>(mesh.Faces);
  // TODO...
}

– Dale

1 Like