Skip to content

Instantly share code, notes, and snippets.

@chuongmep
Created August 13, 2020 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuongmep/46fbecf448c09dfa05bd0773f1cca8f8 to your computer and use it in GitHub Desktop.
Save chuongmep/46fbecf448c09dfa05bd0773f1cca8f8 to your computer and use it in GitHub Desktop.
/// <summary>
/// Return an arbitrary point on a planar planarFace,
/// namely the midpoint of the first mesh triangle.
/// </summary>
/// <returns name="point"></returns>
public static XYZ PointOnFace(PlanarFace planarFace)
{
XYZ point = new XYZ(0, 0, 0);
Mesh mesh = planarFace.Triangulate();
for (int i = 0; i < mesh.NumTriangles;)
{
MeshTriangle triangle = mesh.get_Triangle(i);
point += triangle.get_Vertex(0);
point += triangle.get_Vertex(1);
point += triangle.get_Vertex(2);
point *= 0.3333333333333333;
break;
}
return point;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment