docs / Select geometry

Select geometry

Pick the edges or faces a feature acts on. Query inside OCCT first, then sort or group what comes back.

The query returns the edges it matched, so you can check what you selected before building on it.

const plate = box(80, 50, 10);

const topEdges = await selectEdges(plate, { atZ: 10 });
if (topEdges.length !== 4) {
  throw new Error('expected 4 edges on the top face, got ' + topEdges.length);
}

return plate.fillet(3, { atZ: 10 });
JavaScript is off — the listing above is the whole example.

Calls

CallWhat it does
selectEdges(shape, query?) => Promise<ShapeList<EdgeSegment>>Pre-select edges by EdgeQuery.
selectEdge(shape, query) => Promise<EdgeSegment>Like selectEdges but throws if zero or multiple edges match.
select : <T>(items: Iterable<T>) => ShapeList<T>Wrap any array of topology query results in a ShapeList so the selector algebra applies — face summaries from inspect({ of: 'faces' }), ResolvedEntity[] from q.face(...).evaluate(scene), or a hand-assembled list.
q : { face, edge, vertex, connector, part, solid, createdBy, ownedByPart, ownerPart, union, intersection, subtraction, containsPoint, closestTo, geometryType, withLabel, withFeatureName, nthElement, fromString, nothing, everything }Query DSL constructor namespace.
ShapeList.sortBy(criterion: 'X' | 'Y' | 'Z' | Vec3 | 'area' | 'length' | 'radius', opts?: { descending?: boolean; tolerance?: number }) => ShapeList<T>Order the list by a criterion, ascending by default.
ShapeList.sortByDistance(point: Vec3, opts?: { descending?: boolean; tolerance?: number }) => ShapeList<T>Order by straight-line distance from each entity position to point, nearest first.
ShapeList.groupBy(criterion: 'X' | 'Y' | 'Z' | Vec3 | 'area' | 'length' | 'radius', opts?: { tolerance?: number; descending?: boolean }) => ShapeGroups<T>Partition into groups sharing a quantized criterion value — one group per Z level, per hole diameter, per face area.
ShapeList.filterBy(spec: ((item: T) => boolean) | Axis | string, opts?: { angleTolerance?: number }) => ShapeList<T>Keep matching entities.
ShapeList.filterByPosition(axis: 'X' | 'Y' | 'Z' | Vec3, min: number, max: number, opts?: { inclusive?: boolean }) => ShapeList<T>Keep entities whose position projected onto axis falls within [min, max] (mm).
ShapeList.take(n: number) => ShapeList<T>First n entities, clamped to the list length.
ShapeList.first : T | undefinedGetter — the first entity, or undefined when the list is empty.
ShapeList.last : T | undefinedGetter — the last entity, or undefined when the list is empty.
ShapeList.at(i: number) => T | undefinedEntity at index i; negative indexes count from the end.