> ## Documentation Index
> Fetch the complete documentation index at: https://docs.loft.build/llms.txt
> Use this file to discover all available pages before exploring further.

# duplex

The `duplex` example as shipped in [`examples/duplex/`](https://github.com/loftlang/loft/tree/main/examples/duplex) — 12 files, one project. Every file compiles in CI; a folder here navigates, never scopes.

## `datums/grids.loft`

```loft theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/loft.json","/languages/loft-fragment.json"]}}
units imperial

# The stacked duplex: one unit per story. Each level's story is worked out
# from the level above it (edit L2's elev and both stories follow); L4 is a
# datum to build to, not a story anyone occupies, so it states its own height.
level L1 elev 0'
level L2 elev 11'-0"
level L3 elev 22'-0"               # the roof level — the stair bulkhead's story
level L4 elev 31'-0" height 2'-0"  # T.O. stair bulkhead

grid A vertical at 0'
grid B vertical at grid.A + 14'-0"
grid C vertical at grid.B + 10'-0"
grid 1 horizontal at 0'
grid 2 horizontal at grid.1 + 9'-0"
grid 3 horizontal at grid.2 + 11'-0"
```

## `types/types.loft`

```loft theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/loft.json","/languages/loft-fragment.json"]}}
units imperial

walltype EXT layers [stucco 7/8", core: stud 5-1/2", gyp 5/8"]
walltype STUD4 width 4-1/2" note "3-5/8 stud + gyp ea side"
walltype SHAFT-2HR layers [gyp 5/8", gyp 5/8", core: stud 3-5/8", gyp 5/8", gyp 5/8"] note "2-hr stair shaft"

doortype 3070 width 3'-0" height 7'-0"
windowtype W-4030 width 4'-0" height 3'-0"
```

## `unit-a/walls.loft`

```loft theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/loft.json","/languages/loft-fragment.json"]}}
units imperial

# Everything in this file sits on L1 — the file states its level once.
level L1

# perimeter, clockwise, justify left — the outside faces out
wall EXT A1 from (grid.A, grid.1) to (grid.A, grid.3) justify left
wall EXT A2 from wall.A1.end to (grid.C, grid.3) justify left
wall EXT A3 from wall.A2.end to (grid.C, grid.1) justify left
wall EXT A4 from wall.A3.end to (grid.A, grid.1) justify left

# the bedroom partition
wall STUD4 A5 from (grid.A, grid.2) to (grid.C, grid.2)

# the entry garden wall: 3' tall, so even unit A's own plan draws it in
# the projection pen (below the cut plane) — and unit B's plan reaches it
# through its viewtype's depth, one story down
wall EXT A6 from (grid.B + 1', grid.1 - 5') to (grid.C - 1', grid.1 - 5') height 3'

door 3070 in wall.A4 at 4' past grid.B swing left

room 101 name "LIVING" at (grid.A + 7', grid.1 + 4')
room 102 name "KITCHEN" at (grid.B + 5', grid.1 + 4')
room 103 name "BED 1" at (grid.A + 7', grid.2 + 5')
```

## `unit-b/openings.loft`

```loft theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/loft.json","/languages/loft-fragment.json"]}}
units imperial

# Openings follow their hosts; the file still states its level — the
# default for anything here that needs a base.
level L2

door 3070 in wall.B5 at 2' past grid.B swing left
window W-4030 in wall.B1 at 4' past grid.1 sill 3'-6"
window W-4030 in wall.B3 at 6' past grid.3 sill 3'-6"
```

## `unit-b/walls.loft`

```loft theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/loft.json","/languages/loft-fragment.json"]}}
units imperial

# Everything in this file sits on L2 unless it says otherwise.
level L2

# perimeter — unit B stacks on unit A
wall EXT B1 from (grid.A, grid.1) to (grid.A, grid.3) justify left
wall EXT B2 from wall.B1.end to (grid.C, grid.3) justify left
wall EXT B3 from wall.B2.end to (grid.C, grid.1) justify left
wall EXT B4 from wall.B3.end to (grid.A, grid.1) justify left

# the bedroom partition
wall STUD4 B5 from (grid.A, grid.2) to (grid.C, grid.2)

# the stair shaft wall is ONE element through every story: base and top say
# where it lives — it draws CUT in every plan whose cut plane it crosses
wall SHAFT-2HR SH1 from (grid.B, grid.1) to (grid.B, grid.2) base level.L1 top level.L4

# the dropped bulkhead over the kitchen run — wholly above the cut plane,
# so unit B's plan draws it dashed (the ABOVE class), never authored
wall STUD4 B6 from (grid.B, grid.1 + 6') to (grid.C, grid.1 + 6') base level.L2 + 7'

room 201 name "LIVING" at (grid.A + 7', grid.1 + 4')
room 202 name "KITCHEN" at (grid.B + 5', grid.1 + 4')
room 203 name "BED 2" at (grid.A + 7', grid.2 + 5')
```

## `views/L1-plan.loft`

```loft theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/loft.json","/languages/loft-fragment.json"]}}
# Unit A's story — one view per file: this page is the L1 plan.
view A-PLAN L1-plan of level.L1 name "Unit A — Floor Plan"
```

## `views/L2-plan.loft`

```loft theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/loft.json","/languages/loft-fragment.json"]}}
# Unit B's story, through B-PLAN — the template whose depth shows unit A
# below in the projection pen. What this plan shows is the query's answer.
view B-PLAN L2-plan of level.L2 name "Unit B — Floor Plan"
```

## `views/L3-plan.loft`

```loft theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/loft.json","/languages/loft-fragment.json"]}}
# The roof level's plan — the shaft still crosses its cut plane.
view A-PLAN L3-plan of level.L3 name "Roof Plan"
```

## `views/L4-plan.loft`

```loft theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/loft.json","/languages/loft-fragment.json"]}}
# The bulkhead datum's plan — a stub story; the shaft tops out below its cut.
view A-PLAN L4-plan of level.L4 name "Bulkhead Plan"
```

## `views/building-section.loft`

```loft theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/loft.json","/languages/loft-fragment.json"]}}
# The building section — a horizontal plane between grids 1 and 2, looking
# north as far as grid 3: the shaft wall SH1 draws CUT in one stroke, L1 to
# L4; the kitchen bulkhead frames beyond; the garden wall sits behind the
# viewer and stays out of the drawing.
units imperial

view section S1 at grid.1 + 4'-0" to grid.3 name "Building Section"
```

## `views/south-elevation.loft`

```loft theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/loft.json","/languages/loft-fragment.json"]}}
# The south elevation — the same machine as the section, its plane outside
# the envelope: everything projects in the beyond pen, openings as
# rectangles on the faces, levels as datum lines with their elevations.
units imperial

view elevation E1 at grid.1 - 10'-0" to grid.3 name "South Elevation"
```

## `views/templates.loft`

```loft theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/loft.json","/languages/loft-fragment.json"]}}
project "Stacked Duplex"
units imperial

# The templates — shared defaults the plan files apply; each view lives in
# its own file beside these. Unit B's template looks one story down
# (`depth -11'`), so unit A's walls read beyond — the projection pen,
# computed by the view, never authored.
viewtype plan A-PLAN scale 1/4" cut 4'-0"
viewtype plan B-PLAN scale 1/4" cut 4'-0" depth -11'-0"
```
