Skip to content

Entities

The elements of one drawing context: the model root, a group or a component definition. Iteration takes a snapshot. All edits must happen inside Model.operation.

readonly length: number

Number of elements.


readonly vertices: readonly Vertex[]

All vertices in this context.

[iterator](): Iterator<AnyElement>

Iterator<AnyElement>

Iterable.[iterator]


addEdges(points): Edge[]

Draws connected line segments through two or more points. Segments split where they cross existing edges, and closing a planar outline can create a face. Returns the edges that now lie on the requested segments, in model order; there isn’t necessarily one edge per segment.

Iterable<Point3dLike>

Edge[]


at(index): AnyElement | undefined

Returns the element at index, counting from the end when negative.

number

AnyElement | undefined


copyEntities(transformation, entities): AnyDrawingElement[]

Copies elements of this context, transformed, and returns the new elements. The originals don’t change. Face boundaries, complete curves and holes are copied too, groups and instances keep their definitions, and copies don’t merge with geometry they intersect.

Transformation

Iterable<DrawingElement>

AnyDrawingElement[]


erase(entity): void

Erases one entity, subject to the model’s topology rules.

AnyEntity

void


eraseEdges(edges): void

Erases several edges at once and heals the faces around them. Erasing any edge of a curve erases the whole curve.

Iterable<Edge>

void


ofType<T>(type): (Extract<Guide, { type: T; }> | Extract<Edge, { type: T; }> | Extract<Face, { type: T; }> | Extract<ComponentInstance, { type: T; }> | Extract<Group, { type: T; }>)[]

Returns the elements of the given type.

T extends "Edge" | "Face" | "ComponentInstance" | "Group" | "Guide"

T

(Extract<Guide, { type: T; }> | Extract<Edge, { type: T; }> | Extract<Face, { type: T; }> | Extract<ComponentInstance, { type: T; }> | Extract<Group, { type: T; }>)[]


toArray(): AnyElement[]

A snapshot of the elements.

AnyElement[]


transformEntities(transformation, entities): boolean

Moves elements of this context by a transformation in this context’s coordinates. Shared boundary vertices move once. Returns false when entities is empty.

Transformation

Iterable<DrawingElement>

boolean