Skip to content

Query: Edge ​

Edge queries — read a single BREP edge's topology and geometry (all-handle model). An EdgeHandle is minted by walking from a brep/face/vertex handle; it is session-ephemeral and goes stale on undo/redo/re-topologize. Accessed via snaptrude.core.geom.query.edge.

Functions ​

Every method in this namespace takes the same single positional parameter.

getIndex(edge) ​

Get the index of an edge within its brep.

  • Parameters:
  • Returns: number — The index (-1 if unindexed)

getHalfEdge(edge) ​

Get the primary half-edge of an edge.

  • Parameters:
  • Returns: HalfEdgeHandle | null — The half-edge, or null if uninitialized

listVertices(edge) ​

List the two endpoint vertices of an edge.

ts
// Walk from a component's brep to an edge and read its endpoints
const brep = await snaptrude.design.query.geometry.getBrep(component);
const edges = await snaptrude.core.geom.query.brep.listEdges(brep);
const [start, end] = await snaptrude.core.geom.query.edge.listVertices(edges[0]);

getCurve(edge) ​

Get the underlying curve geometry of an edge (a line, arc or spline). For the curve as plain values — including full-circle edges, which have no CurveHandle form — use query.brep.getEdgeCurve.

  • Parameters:
  • Returns: CurveHandle | null — The curve (line_, arc_ or spline_), or null if it is a circle or unset
ts
const curve = await snaptrude.core.geom.query.edge.getCurve(edges[0]);
if (curve !== null) {
  const length = await snaptrude.core.geom.query.curve.getLength(curve);
}

listFaces(edge) ​

List the faces bordering an edge (one or two). One face means a seam — the edge closes a periodic surface onto itself and has no crease, which is why fillet and chamfer refuse it.

This is the read that picks edges by the surfaces they separate: pair it with face.getSurfaceKind on both faces and keep the pairs you want — a cylinder + plane pair is a rim, and two faces of the same kind are usually two patches of one smooth surface (again no crease). See the rim walk on brepFromFillet; brep.listEdgesBetween is a vertex-pair lookup and is not the tool for this.

Errors ​

Failed calls reject with a typed PluginError — see Error Handling. Conditions specific to this namespace:

CodeThrown byWhendetails
HANDLE_INVALIDall methodsThe edge handle is invalid, foreign, or stale (undo/redo/re-topologize invalidates it)—

Beyond handle resolution these reads are total — misses come back as null/[] (e.g. getCurve), not errors.