Repository navigation
Text roles, views, viewports, inserts and dimensions from a standard - #42
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.