For a standard mesh you get the MeshFace
MeshFace mf = M.Faces[i]
if (mf.IsQuad) facesVerticesCount .Add(4);
if (mf.IsTriangle) facesVerticesCount .Add(3);
and for ngon
More simple with Ngon
private void RunScript(Mesh M, ref object A, ref object B)
{
M.Unweld(0, true);
List<int> facesVerticesCount = new List<int>();
IEnumerable<MeshNgon> ngs = M.GetNgonAndFacesEnumerable();
foreach (MeshNgon ng in ngs)
{
facesVerticesCount.Add(ng.BoundaryVertexCount);
}
A = M;
B = facesVerticesCount;