createEmptyDocument makes a new one. validateDocument checks one that you read from storage.
Import
Example
Notes
- A new document has no sheets.
- Sheet sizes, margins and positions are in millimetres. The origin is the top-left corner.
- The document is plain JSON data. Your app owns it.
createEmptyDocument
A blank document with no sheets.validateDocument
Structural guard for a deserialized document (validate at the storage boundary).findSavedView
Look up one saved drawing definition without resolving or drawing it.UnresolvedSavedViewError
A named view needs a project-level resolver before it can be drawn.Types
PaperDocument
The serializable paper-space document — the source of truth a consumer stores and syncs (.spec/debt.md “Paper / drawing layer”).1
required
UnitSystem
Which conventions the whole drawing set follows: millimetre dimensions and 1:50-style scales, or
feet-and-inches and 1/4” = 1’-0”. A set is one country’s practice, so this lives on the document
rather than per sheet. Absent means
"metric", so existing documents are unchanged.DimensionStyleRegistry
Named dimension styles, keyed by the id an annotation’s
styleId names. Absent means every
dimension uses DEFAULT_DIMENSION_STYLE.PaperStyleId
The paper style the whole set is drawn in — a builtin id or one of this document’s own
paperStyles.PaperStyle
An overlay on the style: one class changed without forking the preset. Plain JSON, like everything
else here.
PaperStyleRegistry
House styles that travel with the file, resolvable by id. They outrank the builtins and anything a
host registers.
Sheet[]
required
Sheet
string
Explicit sheet reference number; independent of the display name.
string
required
string
required
PageSpec
required
Viewport[]
required
Annotation[]
required
TitleblockInstance
PaperStyleId
This sheet’s style, outranking the document’s.
PaperStyle
Layered over the document’s overlay, then the viewport’s over this.
Viewport
SavedDrawingView
Authored drawing intent.PaperStyleId
A builtin autocompletes; any other string is a custom (registered) id.PaperStyle
A style, or the overlay a document/sheet/viewport layers on one.string
string
string
The preset this layers on. Resolved depth-first with a cycle guard.
{
color?: string;
ground?: 'screen' | 'print' | 'both';
}
string
Default stroke colour for every class.
number
Rungs walked on
PEN_LADDER_MM for every class.Record<string, ClassStyle>
Keyed by
ElementType (WALL, DOOR, SPACECONTAINER, …).Record<string, ClassStyle>
Composed on top of the class entry for an HLR edge class (
Hidden, VisibleCrease); the shipped
EDGE_CLASS_MODIFIER is already applied underneath, so these are deltas.'allow' | 'ignore'
Whether a producer’s explicit
style.fill reaches the paper. "allow" is resolvePen’s
behaviour and the default; presets say "ignore".Typography
HandProfile
Hand-drawn linework. Absent means ruled — every CAD preset.
PaperStyleRegistry
PageSpec
PageFormat
required
PageOrientation
required
{
width: number;
height: number;
}
required
Paper units = millimetres, top-left origin (A4 = 210 × 297).
number
required
Uniform inset from every edge. Still the only inset when
frame is absent, which is what keeps
existing documents rendering exactly as before.SheetFrameOptions
The printed drawing frame — border, asymmetric filing margin, centring marks and zone grid (ISO
5457). Absent means no printed frame, and
margin alone positions the title block.Annotation
Sheet annotations, in paper units (mm, top-left origin).TitleblockInstance
Placement of a title-block template on a sheet, with values bound to the template’s named fields (.spec/debt.md “Paper / drawing layer”).string
required
Record<string, string>
required
Values bound by name to the template’s fields.
ViewportBase
A live reference into model space, placed on a sheet. The package does not export this type by name.'vector' | 'raster'
Saved sections/elevations share one view definition across both outputs.
string
Explicit drawing number belonging to this sheet placement.
string
required
{
x: number;
y: number;
width: number;
height: number;
}
required
Placement rect on the sheet, in paper units (mm, top-left origin).
number
required
Dimensionless drawing ratio (paper ÷ real), e.g. 1:50 → 0.02.
string
Registered scale name (
NamedScale.id), e.g. “1:50” or “1/4in-1ft”.number
required
boolean
required
Point2
The model point (metres) placed at the centre of
frame.{
text?: string;
showScale?: boolean;
}
Title drawn beneath the viewport. Absent draws nothing.
PaperStyleId
This viewport’s style, outranking the sheet’s and the document’s — how a 1:20 detail hatches
differently from the 1:100 plan beside it.
PaperStyle
The narrowest overlay: layered over the document’s and the sheet’s.
ViewSource
What the viewport draws — resolved by the core drawing extractor (§7).SavedRasterIsometricView
Saved rendering intent, independent of generated pixels and sheet placement.string
required
string
required
'raster-iso'
required
ProjectionCamera & {
projection_mode: 'Orthographic';
}
required
RasterViewFrame
required
number
required
Camera-space clipping distance in metres; must exceed camera.near.
string[] | 'all'
string | null
required
Null means transparent; an opaque background is a #rrggbb colour.
SavedViewBase
The package does not export this type by name.PhysicalDrawingScope
Omitted scope means the entire model; an explicit list never silently drops unsupported IDs.WorldXZ
World XZ coordinates in metres, written as [x, z]. The package does not export this type by name.ProjectionCamera
Projection camera for the extractor.ClassStyle
One element class’s treatment.boolean
false drops the class before projection — it costs nothing downstream.number
An explicit lineweight in paper mm. Prefer ladderStep, which keeps the weight a rung on
PEN_LADDER_MM.number
Rungs to walk on
PEN_LADDER_MM. Steps SUM across the style, the class, its byKind entry and
the edge class.string
Stroke colour, as CSS.
number[] | 'none'
Dash runs in paper mm;
"none" makes the line continuous.string | 'none'
Poché fill for regions;
"none" removes it.string | HatchSpec | 'none'
Poché hatch: a key into
HATCH_PATTERNS, a literal spec, or "none".'butt' | 'round'
Partial<Record<PrimitiveKind, Omit<ClassStyle, 'byKind'>>>
Per primitive kind, merged over the class entry — how a door’s swing (an arc) is drawn lighter
than its leaf (a line) without a second class.
Typography
string
Always terminate the stack in
Helvetica, Arial, sans-serif: it is one of the PDF standard 14,
which is what the PDF sets in.number
Tracking, as a fraction of the text height (0.08 = +8 %).
'none' | 'uppercase'
number
Multiplier on text height. √2 (1.414) is one rung of the ISO 3098 ladder.
HandProfile
The character of hand-drawn linework.number
required
number
required
Peak displacement of the field, in mm. 0 draws ruled lines.
number
required
The weight the amplitude is quoted at; a stroke’s interior samples scale by √(weight /
weightRefMm), so heavier nibs wander more.
number
required
Cell size of the field. Two faces of a wall a few mm apart sample nearly the same value, so the
wall keeps its thickness; a long stroke crosses several cells and reads as a shallow S.
number
required
Strokes shorter than this are not subdivided (their ends still follow the field, so they stay
attached).
number
required
Sample spacing along a stroke, and the cap on samples per stroke.
number
required
{
amplitudeMm: number;
latticeMm: number;
}
A second, finer octave of the field laid over the bow — the nervous wander of a fineliner on a
napkin. Positional like the bow, so shared vertices still agree. Absent means the bow alone;
segmentLenMm must be a fraction of latticeMm for the wander to be sampled.number
required
Axial overrun past a corner: the start is placed, the finish is a lift.
number
required
number
required
A turn sharper than this is a corner (pen lifted); shallower is one stroke.
number
required
Share of corners drawn crossed; the rest stop short by an open gap. One decision per corner,
shared by every stroke that meets there.
number
required
number
required
Array<{
atOrAboveMm: number;
strikes: number;
}>
required
Strikes by weight band, e.g.
[{ atOrAboveMm: 0.35, strikes: 2 }].number
required
number
required
number
required
number
required
number
Each re-strike wanders on its own by this much (mm) instead of tracking the first pass exactly —
the passes cross and the line goes hairy.
number
required
A short stroke at the start at
startBeadWidthFactor × weight (a bead when > 1, a ramp when
< 1). 0 draws none. Only on strokes long enough to carry one.number
required
number
required
A short stroke at the end at
endTaperWidthFactor × weight. 0 draws none.number
required
number
required
± fraction of the nominal weight, one value per emitted stroke.
number
required
number
required
number
required
number
required
number
required
Extra arcs at a radial offset — how a pencil re-strikes a swing.
number
required
Pull the fill in from the outline by this much: the sliver of paper an inked poché leaves against
its line. 0 fills to the line.
boolean
Draw the hatch as continuous back-and-forth zigzags across each region — a scribbled poché, ONE
stroke per run, laid across the region’s long axis the way a hand scribbles a wall band — instead
of separate parallel lines.
number
Per-vertex jitter of a scribble’s pitch and tilt, as a fraction of the spacing — what keeps a
scribble from reading as ruled hatching.
number
required
Per-line angle jitter, and one drift per region, both in degrees.
number
required
number
required
± fraction of the spacing, one value per region (so lines stay in register within a region).
number
required
Each hatch line ends between
-short and +over of the boundary.number
required
number
required
number
required
number
required
When the predicted output would exceed this,
shedClasses are dropped BEFORE synthesis — a
decision about what is on the sheet, never about where a primitive sits in the array.string[]
required
HandReach
How far the hand reaches beyond the building. By default only viewport geometry is redrawn:
dimensions, the frame and the title block stay ruled, because a drawing that wobbles its
dimensions is a presentation, not an issue. A napkin sketch is exactly that presentation, and asks
for all three.
SheetFrameOptions
What a document may say about its frame.boolean
Draw the border rectangle. Default true once
frame is present at all.boolean
Zone reference grid. Default: on for A3-equivalent and larger.
boolean
Centring marks at the middle of each edge. Default true.
Partial<SheetMargins>
Override any of the four margins.
"left" | "top"
Which edge gets the wide filing margin. Default “left”.
TextAnnotation
DimensionAnnotation
The package does not export this type by name.string
required
"dimension"
required
string
Named style in
PaperDocument.dimensionStyles. Absent uses the default.Point2
required
Point2
required
number
required
Perpendicular offset of the dimension line from the start→end segment.
string
number
required
LeaderAnnotation
The package does not export this type by name.string
required
"leader"
required
string
Named style in
PaperDocument.dimensionStyles. Absent uses the default.Point2
required
Arrow tip — points at the thing being annotated.
Point2[]
required
Knee points from the target to the text anchor (last point).
string
required
number
required
ImageAnnotation
The package does not export this type by name.string
required
"image"
required
string
required
Data URL or remote URL; emitters must not require a DOM canvas.
{
x: number;
y: number;
width: number;
height: number;
}
required
ShapeAnnotation
The package does not export this type by name.string
required
"shape"
required
ShapeKind
required
Point2[]
required
line/polyline: vertices. rect: [topLeft, bottomRight]. circle: [center].
number
Required for
shape: 'circle'.string
number
string
PhysicalDrawingSettings
Shared appearance for technical vectors and raster presentation of one saved view.'visible' | 'cut-only'
Absent means actual cut plus visible context; cut-only applies to sections.
Absent means hidden lines are omitted from technical vectors.
string | null
Raster background. Absent means white; null means transparent.
{
datum: number;
unit: 'm' | 'ft';
}
Authored storey elevations, relative to this world-height datum in metres.
HandReach
The sheet furniture a hand profile may redraw, besides the building.boolean
Dimension, leader and view-title lines, and un-coloured shape annotations. Labels keep their
measured value; authored colours (a redline) stay ruled.
boolean
The drawing frame: border, zone ticks, centring marks.
boolean
The title block’s boxes and rules (a filled box stays ruled).