All Resources
ArticleSolidWorks API2026-02-20
Understanding the SolidWorks B-Rep Model
The B-Rep (Boundary Representation) model is the foundation of all geometry access in the SolidWorks API. Learn the critical difference between topology and geometry objects.
What Is B-Rep?
B-Rep (Boundary Representation) is how SolidWorks internally represents solid geometry. Instead of storing the solid as a volume, it stores the boundaries — the faces, edges, and vertices that define the shape's surface.
Understanding B-Rep is the key to advanced API operations: measuring distances, detecting collisions, recognizing features, and manipulating geometry directly.
Topology vs Geometry
This is the single most important distinction in the SolidWorks API, and it's poorly explained everywhere:
- Topology = the structure (what's connected to what)
- Geometry = the math (what shape things are)
Topology Objects (Structure)
| Interface | What It Represents |
|---|---|
| IBody2 | The entire solid or surface body |
| IFace2 | A bounded region on the surface of a body |
| IEdge | The boundary between two faces (or a free edge) |
| IVertex | A point where edges meet |
| ILoop2 | An ordered chain of edges forming a closed boundary on a face |
Geometry Objects (Math)
| Interface | What It Represents |
|---|---|
| ISurface | The mathematical surface underlying a face (plane, cylinder, cone, sphere, torus, B-spline) |
| ICurve | The mathematical curve underlying an edge (line, circle, ellipse, B-spline) |
| IMathPoint | A point in 3D space |
The Hierarchy
Body (IBody2)
+-- Face (IFace2) // GetFaces()
| +-- Surface (ISurface) // GetSurface()
| +-- Loop (ILoop2) // GetLoops()
| +-- Edge (IEdge) // GetEdges()
| +-- Curve (ICurve) // GetCurve()
| +-- Vertex (IVertex) // GetStartVertex() / GetEndVertex()
| +-- Point (IMathPoint) // GetPoint()Key Relationships
- A face always has one underlying surface. But a surface can be infinite — the face defines the bounded region
- An edge always has one underlying curve. The edge defines the bounded segment of that curve
- A face has one or more loops. The outer loop defines the boundary. Inner loops are holes
- Each edge is shared by exactly two faces (or one face, if it's a free edge on a surface body)
Checking Face Types
To determine what geometric shape a face is:
ISurface surface = face.GetSurface();
if (surface.IsPlane()) { /* flat face */ }
else if (surface.IsCylinder()) { /* cylindrical face — holes, shafts */ }
else if (surface.IsCone()) { /* tapered face */ }
else if (surface.IsSphere()) { /* spherical face */ }
else if (surface.IsTorus()) { /* fillet face */ }
else { /* B-spline or other complex surface */ }Practical Applications
- Distance measurement: Use ISurface.GetClosestPointOn() or IBody2.GetClosestPoint() to find minimum distances between bodies
- Hole recognition: Find cylindrical faces, check if they're internal (face normal points inward), measure the radius from ISurface.CylinderParams
- Flat face detection: Find all planar faces for machining operation planning
- Edge length calculation: Use ICurve.GetLength() for total edge length (useful for weld length estimation)
- Collision detection: Use IBody2.Operations2 with intersection to check if two bodies overlap
Tips
- Always check for null when navigating B-Rep — edges can have null start/end vertices (closed loops like circles)
- Face normals point outward on solid bodies. Use IFace2.GetNormal() to determine face orientation
- B-Rep traversal is the fastest way to analyze geometry — it doesn't require feature recognition or rebuilds
- When comparing faces or edges across operations, use persistent IDs (IEntity.GetPersistReference3) rather than object references, which may change after rebuilds
SolidWorks APIB-RepTopologyGeometryFacesEdges