Skip to content

compas_brep.trim ¤

Classes¤

BrepTrim ¤

BrepTrim(
    edge: BrepEdge | None,
    is_reversed: bool = False,
    curve_2d: NurbsCurve | None = None,
    vertex: BrepVertex | None = None,
)

A coedge: a directed usage of a BrepEdge within a BrepLoop on a BrepFace.

Inspired by STEP's ORIENTED_EDGE / PCURVE model. A trim wraps a shared BrepEdge with: - is_reversed: whether this usage traverses the edge backward - curve_2d: a NurbsCurve in the face surface's UV parameter space (pcurve)

The pcurve allows direct UV-space tessellation without 3D→UV inversion. The 3D curve and vertices are accessed via the underlying edge.

Attributes¤

curve property writable ¤
curve: NurbsCurve | None

The 2D parametric curve in the face's UV space (pcurve).

curve_2d property writable ¤
curve_2d: NurbsCurve | None

Alias for the 2D parametric curve (pcurve).

curve_3d property ¤
curve_3d: Any

The 3D curve from the underlying edge. None for a singular trim.

edge property ¤
edge: BrepEdge | None

The underlying shared BrepEdge, or None for a singular trim.

end_vertex property ¤
end_vertex: BrepVertex

End vertex in the trim's traversal direction.

is_reversed property ¤
is_reversed: bool

Whether this trim traverses the underlying edge backward.

is_singular property ¤
is_singular: bool

Whether this trim has no edge and collapses to a single vertex.

A sphere's poles are the canonical case: the trim spans the full u-range of the surface at v = min or v = max, but every point on it is the same point in 3D.

start_vertex property ¤
start_vertex: BrepVertex

Start vertex in the trim's traversal direction.

vertex property ¤
vertex: BrepVertex | None

The vertex a singular trim collapses to. None for an ordinary trim.

Methods:¤

sample_points ¤
sample_points(surface: Any, n: int = 64) -> list[Point]

Sample points along this trim for visualization.

When a pcurve is available, samples via pcurve → surface evaluation so the resulting polyline lies exactly on the tessellated surface mesh. Falls back to the 3D edge curve when no pcurve is present.

Parameters:

  • surface (Any) –

    The parent face's surface (needed for pcurve → 3D evaluation).

  • n (int, default: 64 ) –

    Number of segments. Defaults to 64.