Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a method that creates a triangulated solid mesh based on Solid, but it only works with PlanarFace.
public static bool CreateMesh(this Solid solid, out List<XYZ> listVectors, out List<Tri> listTri)
{
double k = UnitUtils.ConvertFromInternalUnits(1, UnitTypeId.Meters);
listVectors = [];
listTri = [];
bool allPlanar = true;
int indV = 0;
foreach (Face face in solid.Faces)
{
if (face is PlanarFace pFace)
{
Mesh mesh = pFace.Triangulate();
for (int tN = 0; tN < mesh.NumTriangles; tN++)
{
var tri = mesh.get_Triangle(tN);
var pT = new int[3];
for (int vN = 0; vN < 3; vN++)
{
var p = tri.get_Vertex(vN) * k;
if (p.Contain(listVectors, out XYZ pF, out int index))
{
pT[vN] = index;
}
else
{
pT[vN] = indV;
listVectors.Add(p);
indV++;
}
}
listTri.Add(new(pT[2], pT[1], pT[0]));
}
}
else
{
allPlanar = false;
break;
}
}
return allPlanar;
}
Is there a way to get a triangulated surface from a Face that is not a PlanarFace?
Solved! Go to Solution.