Appearance
Query: Brep
BREP queries — read the topology and geometry of a boundary-representation mesh as plain values / child handles. A BrepHandle is a session-ephemeral resource handle obtained from design.query.geometry.getBrep; it goes stale on undo/redo/re-topologize. Enumerations mint fresh child topology handles (FaceHandle, EdgeHandle, VertexHandle, HalfEdgeHandle); the registry dedupes by identity, so re-enumeration returns the same handles. Position reads return Vec3Components. No query mutates its inputs. Accessed via snaptrude.core.geom.query.brep.
Types
Vec3Components
Plain-value vector record returned by position reads.
| Property | Type | Description |
|---|---|---|
x | number | X component |
y | number | Y component |
z | number | Z component |
BBoxComponents
Plain-value axis-aligned bounding box record.
| Property | Type | Description |
|---|---|---|
min | Vec3Components | Minimum corner |
max | Vec3Components | Maximum corner |
Functions
listFaces(brep)
List the faces of a brep.
- Parameters:
brep:BrepHandle— The brep to query
- Returns:
FaceHandle[]— The faces
ts
const brep = await snaptrude.design.query.geometry.getBrep(component);
const faces = await snaptrude.core.geom.query.brep.listFaces(brep);listEdges(brep)
List the edges of a brep.
- Parameters:
brep:BrepHandle— The brep to query
- Returns:
EdgeHandle[]— The edges
listVertices(brep)
List the vertices of a brep.
- Parameters:
brep:BrepHandle— The brep to query
- Returns:
VertexHandle[]— The vertices
listHalfEdges(brep)
List the half-edges of a brep.
- Parameters:
brep:BrepHandle— The brep to query
- Returns:
HalfEdgeHandle[]— The half-edges
getEdge(brep, vertexIndexA, vertexIndexB)
Get the edge connecting two vertices (by their brep vertex indices).
- Parameters:
brep:BrepHandle— The brep to queryvertexIndexA:number— First vertex indexvertexIndexB:number— Second vertex index
- Returns:
EdgeHandle | null— The edge, ornullif no such edge exists
hasEdge(brep, vertexIndexA, vertexIndexB)
Test whether an edge connects two vertices (by their brep vertex indices).
- Parameters:
brep:BrepHandle— The brep to queryvertexIndexA:number— First vertex indexvertexIndexB:number— Second vertex index
- Returns:
boolean—trueif such an edge exists, otherwisefalse
listEdgesBetween(brep, vertexIndexA, vertexIndexB)
List every edge connecting two vertices (by their brep vertex indices).
- Parameters:
brep:BrepHandle— The brep to queryvertexIndexA:number— First vertex indexvertexIndexB:number— Second vertex index
- Returns:
EdgeHandle[]— The edges
getEdgeCurve(brep, edge)
Read the exact curve of a brep edge as plain values — a discriminated union on type. Pure read: no geometry kernel is loaded. Points and directions are Vec3Components (like getVertexPosition); axis is a unit vector; lengths and radii are raw Babylon units. Unlike query.edge.getCurve — which mints a curve handle and returns null for full-circle edges — this read returns plain values for every exact curve, circles included.
type | Fields |
|---|---|
"line" | startPoint, endPoint, length |
"arc" | startPoint, endPoint, centre, axis, radius, length |
"circle" | centre, axis, radius, length — a full-circle edge (e.g. a cylinder cap rim) |
- Parameters:
brep:BrepHandle— The brep the edge belongs toedge:EdgeHandle— The edge whose curve to read
- Returns: The curve data as a discriminated union on
type(see table above) - Throws:
VALIDATIONif the edge is not onbrep(enumerate edges of the same brep vialistEdges/getEdge);OPERATION_FAILEDif the edge carries no exact curve geometry (never the case for breps authored viacore.geom.create)
ts
// Read the radius of a cylinder's curved rim edges
const cylinder = await snaptrude.core.geom.create.brepFromExtrusion(
circleContour, // a circle authored as two semicircular arcs
{ x: 0, y: 1, z: 0 },
5
);
const edges = await snaptrude.core.geom.query.brep.listEdges(cylinder);
for (const edge of edges) {
const curve = await snaptrude.core.geom.query.brep.getEdgeCurve(cylinder, edge);
if (curve.type === "arc") console.log("rim radius:", curve.radius);
}getVertexPosition(brep, vertex)
Get the position of a vertex within a brep.
- Parameters:
brep:BrepHandle— The brep to queryvertex:VertexHandle— The vertex whose position to read
- Returns:
Vec3Components— The position, as{ x, y, z }
ts
const { brep: brepQuery } = snaptrude.core.geom.query;
const brep = await snaptrude.design.query.geometry.getBrep(component);
const vertices = await brepQuery.listVertices(brep);
const position = await brepQuery.getVertexPosition(brep, vertices[0]);
// position = { x, y, z } in Snaptrude unitslistVertexPositions(brep)
List the positions of all vertices in a brep (ordered as listVertices).
- Parameters:
brep:BrepHandle— The brep to query
- Returns:
Vec3Components[]— The positions
getCentroid(brep)
Get the centroid (mean of all vertex positions) of a brep.
- Parameters:
brep:BrepHandle— The brep to query
- Returns:
Vec3Components— The centroid
getFaceCount(brep)
Get the number of faces in a brep.
- Parameters:
brep:BrepHandle— The brep to query
- Returns:
number— The face count
getEdgeCount(brep)
Get the number of edges in a brep.
- Parameters:
brep:BrepHandle— The brep to query
- Returns:
number— The edge count
getVertexCount(brep)
Get the number of vertices in a brep.
- Parameters:
brep:BrepHandle— The brep to query
- Returns:
number— The vertex count
getHalfEdgeCount(brep)
Get the number of half-edges in a brep.
- Parameters:
brep:BrepHandle— The brep to query
- Returns:
number— The half-edge count
getBoundingBox(brep)
Get the axis-aligned bounding box of a brep.
- Parameters:
brep:BrepHandle— The brep to query
- Returns:
BBoxComponents— The bounding box, as{ min, max }
isEqual(brepA, brepB)
Test whether two breps are geometrically equal.
- Parameters:
brepA:BrepHandle— First brepbrepB:BrepHandle— Second brep
- Returns:
boolean—trueif the breps are equal, otherwisefalse
getDistance(brepA, brepB)
Measures the minimum distance between two solids, with the closest witness point on each. Touching or overlapping solids report a distance of 0 with contact points.
- Parameters:
brepA:BrepHandle— First solidbrepB:BrepHandle— Second solid
- Returns:
{ distance, pointA, pointB }— The minimum distance and the closest points onbrepAandbrepBasVec3Components - Throws:
OPERATION_FAILEDif the kernel cannot compute the distance
ts
const [a, b] = await snaptrude.design.query.listMasses();
const brepA = await snaptrude.design.query.geometry.getBrep(a);
const brepB = await snaptrude.design.query.geometry.getBrep(b);
if (brepA && brepB) {
const { distance, pointA, pointB } = await snaptrude.core.geom.query.brep.getDistance(
brepA,
brepB
);
console.log("clearance:", distance);
}Errors
Failed calls reject with a typed PluginError — see Error Handling. Conditions specific to this namespace:
| Code | Thrown by | When | details |
|---|---|---|---|
HANDLE_INVALID | all methods | The brep (or child topology) handle is invalid, foreign, or stale — brep handles go stale on undo/redo/re-topologize | — |
VALIDATION | getEdgeCurve | The edge does not belong to the given brep | — |
OPERATION_FAILED | getEdgeCurve | The edge carries no exact line/arc/circle curve geometry (never the case for breps authored via core.geom.create) | — |
OPERATION_FAILED | getDistance | The geometry kernel could not compute the distance between the two solids | — |
Beyond handle resolution these reads are total — degenerate topology comes back as []/null results, not errors. The exceptions: getDistance runs on the geometry kernel and can throw OPERATION_FAILED, and getEdgeCurve throws VALIDATION when the edge is not on the given brep.