Skip to content
Shapemetry

Model - Entities

API reference for src/document/entities on @huukhanhnguyen/model, reachable from ..

See the Guide for the ModelJSON / evaluate pipeline.

API reference

Signatures are generated from the live package .d.ts - not hand-written.

annotationPoints

function

Every point an annotation's own geometry carries, in a fixed order — the ONE place the per-type field layout is spelled out. Bounds, view windowing and hit-testing all read through this instead of reaching for a field that only one of the six types has (anchors, until 2026-08-16). For a radial mark the arc is sampled at centre + both axis tips, which is what bounds need and what mapAnnotationGeometry inverts.

annotationPoints(e: AnnotationEntity): Point[]

draftingTextOf

function

The string a mark displays, when it carries one of its own. A dimension's measurement is NOT this: it is derived from the geometry at draw time and lives in the TextEntity inside entities; only an explicit text OVERRIDE answers here.

draftingTextOf(e: AnnotationEntity): string | undefined

entityTypeOf

function

Stream entity kind — ONE spelling with tessellation primitives: faceEntity ↔ tessellation type "faceEntity" (was "mesh"), curveEntity ↔ "curveEntity" (was "curve"), pointEntity ↔ "pointEntity". Annotation entities share AnnotationType via geometry.annotation.

entityTypeOf(e: unknown): "curveEntity" | "faceEntity" | "pointEntity" | "blockEntity" | "meshEntity" | "annotationEntity" | "sectionEntity" | "hatchEntity" | "lightEntity"

isAngularDimension

function

isAngularDimension(e: unknown): e is AngularDimensionEntity

isAnnotation

function

isAnnotation(e: unknown): e is AnnotationEntity

isBlock

function

isBlock(e: unknown): e is BlockEntity

isCurve

function

Curve-entity geometry is a PolyCurve and nothing else. A Wire (the branching B-Rep 1D graph) and a bare NurbsCurve are NOT stream geometry.

isCurve(e: unknown): e is CurveEntity

isDimension

function

Any of the three MEASURED marks — what carries a style, a drawn form and the text/textPoint overrides.

isDimension(e: unknown): e is LinearDimensionEntity | RadialDimensionEntity | AngularDimensionEntity

isHatch

function

Hatch sniff: geometry has cell (and typically face). Unique key.

isHatch(e: unknown): e is HatchEntity

isImage

function

isImage(e: unknown): e is ImageEntity

isLeader

function

isLeader(e: unknown): e is LeaderEntity

isLight

function

Light sniff: geometry has lumens — the one field only an emitter has. A light is an ordinary entity kind (see LightEntity): its geometry IS the emitting shape, so nothing else in the stream needs a light-shaped flag.

isLight(e: unknown): e is LightEntity

isLinearDimension

function

isLinearDimension(e: unknown): e is LinearDimensionEntity

isMesh

function

isMesh(e: unknown): e is MeshEntity

isPoint

function

isPoint(e: unknown): e is PointEntity

isPolyCurve

function

Is this value a PolyCurve? Ordered chain of tagged segments.

isPolyCurve(value: unknown): value is PolyCurve

isRadialDimension

function

isRadialDimension(e: unknown): e is RadialDimensionEntity

isSection

function

isSection(e: unknown): e is SectionEntity

isShell

function

isShell(e: unknown): e is ShellEntity

isText

function

isText(e: unknown): e is TextEntity

mapAnnotationGeometry

function

Apply a point map to an annotation geometry, rebuilding each type from its OWN fields — the counterpart of annotationPoints and the ONE place a transform or a view projection touches annotation geometry.

A radial mark cannot be point-mapped naively: its arc carries a frame, so the frame is REBUILT from the mapped centre and axis tips. That throws when the map is not a similarity in the arc's plane (a squash, or a projection seen edge-on), because the result would not be a circle and a silently wrong radius is exactly the believable-number bug the fail-loud law names.

mapAnnotationGeometry(e: AnnotationEntity, map: (p: Point) => Point): AnnotationEntity["geometry"]

VIEW_FAMILIES

const

Entity-stream RUNTIME — the geometry-shape guards and the drafting helpers.

An entity is { geometry, …meta }: there is NO type discriminant tag, so an entity's kind is sniffed from the SHAPE of its geometry field. That sniffing is what this module is. Every TYPE it names — Entity and its per-kind members, BlockDefinition, Annotation — is declared in @huukhanhnguyen/types and re-exported from this package's barrel (src/index.ts); this file holds only what a declarations-only package cannot: values.

const VIEW_FAMILIES: readonly ["3d", "plan", "section", "elevation", "pattern", "detail"]
Last updated: 📖 3 min readEdit on GitHub