Table of Contents

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

face Face2

Returns

double[]

GetPoints(Face2)

Gets all unique vertex points from the face's edges.

public static List<double[]> GetPoints(this Face2 face)

Parameters

face Face2

The 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

face Face2

the face that you want to find the tangent faces to

digits int

the 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

face Face2

Returns

bool

SetName(Face2, PartDoc, string)

assigns a name to a face

public static void SetName(this Face2 face, PartDoc part, string name)

Parameters

face Face2

the face to assign name to

part PartDoc

has to be part document only

name string

string value to assign to face