Skip to main content
It does the maths only. Your tool converts the pointer position and draws the indicator.

Import

Example

Notes

  • Give the points, the grid spacing and the radius in the same unit. Paper tools use millimetres.
  • snap() tries the nearest target first, then the grid. If it finds none, it returns your point with snapped: false.
  • snapToTargets() does not use the grid.
  • Convert screen pixels to your unit before the call.

Constructor

Methods

snap

Snap a point.

snapToTargets

Endpoint-only snap (NO grid): the nearest target within snapRadius, else the point unchanged.

setGridSpacing

setSnapRadius

Set the snap radius (paper mm).

drawingSnapTargets

Snap candidates from a drawing’s primitives: line ends, arc centres, region corners, and optionally segment midpoints.

drawingIntersections

planSnapTargets

placementSnap

Where a placement ghost goes for one cursor position.

placedOutline

The outline placed, as the placement ghost draws it: turned by rotation (radians, counter-clockwise seen from above, as PlacementSnap.rotation) about the origin and moved to at.

snappedMove

Snap a body move the way a placement snaps its ghost: the outline corners (drawing metres) moved by [dx, dy] lock a corner onto a snap point, else land flush on a wall face.

workingGridToWorld

workingGridToLocal

workingGridNode

nearestWorkingGridNode

pickWorkingGridNode

alignWorkingGridToEdge

workingGridToProjectAxes

Types

SnapResult

SnapTargetOptions

The points in a drawing that a snap can lock onto — the geometry a dimension or a dragged vertex should land exactly on.
boolean
Include the midpoint of every segment as well as its ends.
string
Skip primitives belonging to this element — a vertex must not snap to the very geometry it is dragging.

DrawingSnapPoint

The package does not export this type by name.

SnapIntersectionOptions

The package does not export this type by name.

DrawingIntersections type

The package does not export this type by name.

SnapTarget

SnapFeature
DrawingSourceRef
readonly (readonly Point2[])[]
The wall face edges that the frame of this opening stands back from: a nearer one wins over it.

PlacementSnapInput

The package does not export this type by name.
XZ
required
readonly XZ[]
required
The footprint about the insertion point, unturned, in plan metres.
number
required
Radians, counter-clockwise seen from above, as PlacementSnap.rotation.
number
required
boolean
required
A door or a window: centre on the nearest wall axis and turn to it.
readonly PlacementWall[]
required
BodyAlignmentContext

XZ

The package does not export this type by name.

PlacementWall

A wall’s axis and thickness on the plan, in plan XZ metres: what a placement snaps against.

SnapOutcome

The package does not export this type by name.
Point2
required
boolean
required
False when nothing was near enough and point is the cursor unchanged.
PlanSnapResult

BodyAlignmentContext

The package does not export this type by name.

BodyAlignment

The package does not export this type by name.

WorkingGridNode type

SnapPointKind

The package does not export this type by name.

SnapFeature

PlanSnapResult

Point2
required
number
SnapFeature
required
'coincident' | 'projected' | 'locked' | 'hosted' | 'free'
required
readonly SnapSource[]
required
readonly SnapWitness[]
required
readonly SnapWitness[]
The gap brackets of an equal-gap result: each clear gap, face to face, along its axis.
SnapConstraint
ResolvedHostPlacement
string
{ kind: 'length' | 'gap' | 'grid' | 'shift' | 'clearance'; metres: number; }
The length that label writes, in metres, so that a host can say the same number: a draft’s run (length), an equal clear gap (gap), a square working grid’s step (grid), the move of an opening to fit (shift) or a measured clearance (clearance).

AlignmentNeighbour

The package does not export this type by name.

AxisAlignment

The package does not export this type by name.

SnapSource

SnapConstraint

Feature

The package does not export this type by name.

AlignmentWitness

The package does not export this type by name.
Last modified on November 30, 2026