Class Face2Extensions
- Namespace
- Hymma.Solidworks.Extensions
- Assembly
- Hymma.Solidworks.Extensions.dll
Extension methods for SolidWorks.Interop.sldworks.Face2 objects providing geometric operations and face analysis utilities.
public static class Face2Extensions
- Inheritance
-
Face2Extensions
- Inherited Members
Examples
Common face operations:
Face2 face = selectedFace as Face2;
// Get centroid for annotation placement
double[] center = face.GetCentroid();
// Check surface type
if (face.IsPlanar())
{
// Find all connected tangent faces (coplanar faces)
var tangentFaces = face.GetTangentFaces();
double totalArea = face.GetArea();
foreach (Face2 tf in tangentFaces)
{
totalArea += tf.GetArea();
}
}
Remarks
These extensions simplify working with faces in SolidWorks:
- Get edge vertex points
- Calculate face centroid
- Check if face is planar
- Find tangent faces (same normal direction)
- Assign names to faces
Methods
GetCentroid(Face2)
get the center of a face
public static double[] GetCentroid(this Face2 face)
Parameters
faceFace2
Returns
- double[]
GetPoints(Face2)
Gets all unique vertex points from the face's edges.
public static List<double[]> GetPoints(this Face2 face)
Parameters
faceFace2The face to get points from.
Returns
- List<double[]>
A list of double arrays, each containing [X, Y, Z] coordinates in meters. Curved edges (circles, splines) that have no distinct vertices are skipped.
Examples
List<double[]> points = face.GetPoints();
foreach (var point in points)
{
Console.WriteLine($"X: {point[0]}, Y: {point[1]}, Z: {point[2]}");
}
GetTangentFaces(Face2, int)
get all faces that are tangent to this face
public static IList<Face2> GetTangentFaces(this Face2 face, int digits = 5)
Parameters
faceFace2the face that you want to find the tangent faces to
digitsintthe value to be used to round the differences between the normals using AlmostEqual(double[], double[], int)
Returns
- IList<Face2>
Remarks
Because Double values can lose precision when arithmetic operations are performed on them,
a comparison between two face instances that are logically tangent might fail. hence we use a tolerance
IsPlanar(Face2)
determine if a face is planar or curved
public static bool IsPlanar(this Face2 face)
Parameters
faceFace2
Returns
SetName(Face2, PartDoc, string)
assigns a name to a face
public static void SetName(this Face2 face, PartDoc part, string name)
Parameters
faceFace2the face to assign name to
partPartDochas to be part document only
namestringstring value to assign to face