Skip to content

Text roles, views, viewports, inserts and dimensions from a standard - #42

Merged
sc-frederick merged 1 commit into
mainfrom
export
Nov 13, 2026
Merged

sc-frederick merged 1 commit into
mainfrom
export

Conversation

@tsdraft-export

Copy link
Copy Markdown
Contributor

This pull request was opened by the export from tsdraft's development repository. Each commit
here is one change made there.

Merge it with squash, or with rebase to keep one commit per change. Don't push to this branch:
the next export replaces anything that did not come from it.

A drawing drawn to a standard takes its texts' sizes, its views and its dimension styles from
the standard:

- `text()` and `attribute()` take `role`, a text role of the standard, which gives the text its
  text style, named after the role (`NOTE` for `note`), and the height it plots at. On a layout
  and in a block the text is at the role's height. In model space it names the `view` it is read
  in, and its height is `view.paper(role.height)`.
- `d.view(id, { scale })` declares a view: a scale of the standard under an id of the drawing. It
  returns a `View`, `{ id, scale, label, ratio, paper(length) }`, where `paper` turns a length on
  paper, in the standard's paper units, into drawing units at the scale's ratio, as `fromPaper`
  does. A length `fromPaper` refuses throws a `DrawingError` under `geometry`, with the call.
- Under a standard, `sheet.viewport(corner, width, height, { view, center })` shows a view. The
  viewport takes the view's id and its scale's ratio, and one viewport shows a view.
- `insert(name, at, { view })` in model space scales the insert by `view.paper(1)`, so a symbol
  drawn in paper units plots at its size. An insert in model space of a block whose texts have
  roles names a view.
- `linearDimension` and `alignedDimension` take `style`, a dimension style of the standard by its
  id, which defaults to the standard's `defaultDimensionStyle`, and in model space `view`. The
  drawing gets the dimension style on first use, with the standard's paper sizes, its role's text
  style and height, and the writing of the units it is drawn in: `DIMS-1in-10ft` for the style
  `dims` in a view at `1in-10ft`, scaled by `view.paper(1)`, and `DIMS` on a layout. Two views at
  one scale share it.
- The builder refuses what the standard does not give, at compile time for a literal with the
  message it throws: a role the standard lacks, a role with `height` or `style`, a text of model
  space with a role and no view, a text in a block or on a layout with one, and an insert's
  `view` with `scale` (`role`); `view()` with a scale the standard lacks
  (`scale-outside-standard`); a viewport's `ratio` or `id` beside `view`, or a view the drawing
  did not declare (`viewport`); `dimensionStyle()`, a dimension style the standard lacks, or
  `standard`, which no standard holds (`dimension-style-outside-standard`); and a dimension in
  units its style's writing lacks (`dimension-style`). A message about a missing name says how
  to add it. When the code runs, it also refuses `textStyle()` with the name of a role's text
  style, before the role is used or after (`text-style`), and a layout on a paper that is not in
  the standard's paper units (`layout`).
- `LintRule` gains `role`, `scale-outside-standard` and `dimension-style-outside-standard`. A
  `switch` over it that is checked to be exhaustive stops compiling. `Sheet` gains a type
  parameter with a default. `TextOptions`, `AttributeOptions` and `InsertOptions` gain type
  parameters with defaults and are type aliases now, not interfaces: under a standard each is a
  union of whole shapes, so each branch of a conditional, such as
  `flag ? { view } : { scale: 2 }`, is checked as written. The new types are `View`,
  `StandardViewportOptions`, `StandardLinearDimensionOptions` and
  `StandardAlignedDimensionOptions`.
- A drawing without a standard is built, linted and written as before.
- The example sheet draws its text, symbols and dimensions by role and view, and
  `sitePlan(scale)` takes a scale of its standard, such as `"1in-20ft"`.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@sc-frederick
sc-frederick merged commit b79a11b into main Nov 13, 2026
3 checks passed
@sc-frederick
sc-frederick deleted the export branch November 13, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant