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

# Draw the existing and the proposed state

> Give elements a phase, then draw the building before the work and after it from one model.

An alteration needs two sets of drawings: the building as it is, and the building after the work. Floorkit makes both from one model. Each element has a phase, and each view has a phase filter.

[Live example](https://floorkit-examples.ploterr.com/floorkit/guides/existing-and-proposed?embed=1)

## Before you start

You have the house of [Cut a section](https://docs.ploterr.com/floorkit/guides/cut-a-section.md): a room of walls with a door, a window, a floor slab and a roof, and a project with a plan view.

## Give the elements a phase

The phase is `existing`, `new` or `demolished`. An element with no phase is new. Here the walls, the floor and the roof stand today, the door is to be removed, and the window is new: it keeps no phase.

```typescript theme={null}
import {
  drawProjectView,
  type BuildingSession,
  type ProjectFile,
  type SavedDrawingView,
} from '@opengeometry/floorkit';

export function setHousePhases(session: BuildingSession): void {
  session.apply(
    {
      kind: 'set-phase',
      buildingId: 'building',
      elementIds: ['room-walls', 'ground-floor', 'main-roof'],
      phase: 'existing',
    },
    session.revision,
  );
  session.apply(
    { kind: 'set-phase', buildingId: 'building', elementIds: ['entry-door'], phase: 'demolished' },
    session.revision,
  );
}
```

## Save an existing and a proposed plan

`phaseFilter: 'existing'` draws the building before the work. `phaseFilter: 'proposed'` draws it after the work.

```typescript theme={null}
export const existingPlan: SavedDrawingView = {
  id: 'existing-plan',
  name: 'Existing ground floor',
  kind: 'plan',
  storeyId: 'ground',
  cutHeightAboveStorey: 1.2,
  phaseFilter: 'existing',
};

export const proposedPlan: SavedDrawingView = {
  id: 'proposed-plan',
  name: 'Proposed ground floor',
  kind: 'plan',
  storeyId: 'ground',
  cutHeightAboveStorey: 1.2,
  phaseFilter: 'proposed',
};

export function addPhasePlans(project: ProjectFile): ProjectFile {
  return { ...project, views: [...project.views, existingPlan, proposedPlan] };
}

export function drawBothStates(project: ProjectFile, session: BuildingSession) {
  return {
    existing: drawProjectView(project, 'existing-plan', { session }),
    proposed: drawProjectView(project, 'proposed-plan', { session }),
  };
}
```

The existing plan has the door and no window: the wall is drawn whole where the window will go. The proposed plan has the door and the window.

The wall stays, so the proposed plan closes it where the door was: the cut of the wall runs across the old opening. That closing part, the infill, is new work. It draws with the hatch of the wall and the pen of the `new` phase, and the demolished door draws over it with its dashed pen.

A room exists in one phase. The proposed plan does not draw a demolished room, its name or its details, so an old and a new room in the same place do not print two labels. The existing plan draws the demolished room and not the new one.

## Draw the finished building

`phaseFilter: 'complete'` draws the building as it is when the work is done: the existing and the new elements, and no demolished element. A demolished door leaves no hole in its wall. Use it where a drawing shows only the result, such as the proposed elevations of a UK planning application or a plan for the client. Use `proposed` where the drawing must show what is removed, and `existing` for the drawings of the building as it is today. A complete view draws every element with its usual pens, as the plan of a building with no phases.

## Ink each phase

In a view with `phaseFilter: 'proposed'`, each line and fill of an element carries the phase of the element, and the sheet inks it with the pen of that phase. These are the default pens:

| Phase | Pen |
| - | - |
| `existing` | The outline only, with no fill and no hatch |
| `new` | The usual pen: a cut wall keeps its poché |
| `demolished` | Dashed, 1.5 mm dash and 0.75 mm gap, with no fill and no hatch |

This is how UK planning drawings tell the work apart: new work is filled, kept work is plain, and work to be removed is dashed. An existing and a complete view have no phase pens: the existing plan draws the building as it stands with the usual pens, cut walls with their poché, the same as a plan of a model of the building before the work.

The demolished dash is short, so the end of a wall and the jamb of a door show a gap at 1:100. An edge shorter than one dash, such as the end of a 100 mm wall at 1:100, draws as one dash.

The `phases` entries of a paper style change the pens of a phase. Each entry takes the fields of a class entry, such as `fill`, `hatch`, `dash` and `ink`. This style greys the kept work and draws the removed work with a longer dash:

```typescript theme={null}
import type { PaperStyle, Sheet } from '@opengeometry/floorkit';

export const phaseStyle: PaperStyle = {
  phases: {
    existing: { ink: '#808080' },
    demolished: { dash: [2, 1] },
  },
};
```

A `classes` entry in a phase gives one element type its own pens in that phase. `visible: false` there leaves that type of that phase out of the drawing. This style fills the new walls, hatches the kept walls in light grey and draws the removed walls red and dashed. It leaves the removed doors, windows, stairs, floors and chimneys out of the plan; the removed walls stay. New floors, stairs and rooms keep their usual pens:

```typescript theme={null}
export const workStyle: PaperStyle = {
  phases: {
    new: { classes: { WALL: { fill: '#d9c4a0' } } },
    existing: {
      classes: {
        WALL: { hatch: { angleDeg: 45, spacingMm: 1.5, weightMm: 0.13, color: '#b3b3b3' } },
      },
    },
    demolished: {
      classes: {
        WALL: { ink: '#c00000', dash: [1, 0.5] },
        DOOR: { visible: false },
        WINDOW: { visible: false },
        STAIR: { visible: false },
        SLAB: { visible: false },
        CHIMNEY: { visible: false },
      },
    },
  },
};
```

## Put both states on one sheet

Each viewport draws its view in the state of the view's filter, so one sheet holds the existing and the proposed plan of one model.

```typescript theme={null}
export const phaseSheet: Sheet = {
  id: 'sheet-a201',
  name: 'Existing and proposed',
  number: 'A-201',
  page: {
    format: 'A3',
    orientation: 'landscape',
    size: { width: 420, height: 297 },
    margin: 10,
  },
  viewports: [
    {
      id: 'existing-viewport',
      viewId: 'existing-plan',
      drawingNumber: '1',
      frame: { x: 20, y: 20, width: 185, height: 230 },
      scale: 0.02,
      rotationDeg: 0,
      clip: true,
      title: { text: 'Existing ground floor', showScale: true },
    },
    {
      id: 'proposed-viewport',
      viewId: 'proposed-plan',
      drawingNumber: '2',
      frame: { x: 215, y: 20, width: 185, height: 230 },
      scale: 0.02,
      rotationDeg: 0,
      clip: true,
      title: { text: 'Proposed ground floor', showScale: true },
    },
  ],
  annotations: [],
};

export function addPhaseSheet(project: ProjectFile, styled: boolean): ProjectFile {
  const sheet = styled ? { ...phaseSheet, styleOverride: phaseStyle } : phaseSheet;
  return { ...project, paper: { ...project.paper, sheets: [...project.paper.sheets, sheet] } };
}
```

## Rules

* `phase` is on walls, doors, windows, voids, slabs, roofs, rooflights, dormers, chimneys, columns, beams, stairs, railings, ramps, rooms and placed blocks. It is not on annotations, room separators, model objects, masses or the site.
* `set-phase` sets the phase of elements of one building, hosted openings included. `phase: null` removes the field, so the element is new again.
* A view with `phaseFilter: 'existing'` leaves out each new element. A new opening leaves no hole in its wall. A demolished element draws as an existing one.
* A view with `phaseFilter: 'complete'` leaves out each demolished element. A demolished opening leaves no hole in its wall.
* A view with `phaseFilter: 'proposed'` draws every element but the demolished rooms, with the phase pens. A view with no `phaseFilter` draws every element and has no phase pens.
* A proposed plan closes each demolished door, window or void in a wall that is not demolished. The infill is the cut of the wall over the opening, with the hatch of the wall and the `new` phase. A new opening that the plan cuts stays open, also where it lies inside the width of a demolished one. A plan with no `phaseFilter` does not close a demolished opening, so there it differs from the proposed plan. An arc wall is not closed yet: the opening stays open and the drawing's `warnings` name the wall.
* Only a proposed view has phase pens. An existing or a complete view draws each element with its usual pens.
* A room exists in one phase: a demolished room draws only in an existing view or a view with no `phaseFilter`. A demolished room with no `height` has no ceiling height line. A demolished and a new room that overlap give no `room-overlap` warning, as they never stand together.
* The phase pen of a line or fill comes from the element that `sourceRef` or `sourceRefs` names. Door, window and wall tags, room names and their detail lines, dimensions and other annotations keep their own pens.
* A phase pen is drawn over the class and edge-class entries of a paper style, and a `phases` entry over the default pen of its phase. The default `existing` and `demolished` pens, and a `phases` entry with a `fill` or a `hatch`, also replace the poché that the drawing gives a cut. The seen surfaces of an elevation keep their fill and material hatch: a phase changes only their lines.
* A `phases` entry applies to every element of that phase: walls, floors, roofs, rooms, columns and the rest. A `fill` there fills each of them, so ink and dash suit most styles. To fill only the walls, put the `fill` in `phases.<phase>.classes.WALL`.
* A `fill: 'paper'` fills with the paper colour of the sheet, and only a cut that has a poché. `phases: { existing: { fill: 'paper' } }` paints the existing cut walls and columns in the paper colour and leaves the floors and the seen surfaces with no fill.
* A `phases.<phase>.classes` entry is drawn over the `phases.<phase>` entry, with its `byKind` and `parts` entries. Its `visible: false` removes that type in that phase only, after `classes.<type>.visible`. A phase class entry with a `fill` or a `hatch` also replaces the poché of a cut.
* Walls of different phases do not join into one outline. Each phase draws its own outline and poché, so the joint between an existing wall and a new or demolished one shows as a line, as it does in Revit. This holds in every view, with or without `phaseFilter`, except in an existing view, where a demolished wall joins the existing walls. A model with no phases draws as before.
* A wall with `joinsAcrossPhases: false` does not join a wall on the other side of demolished and new: a demolished wall and a new wall keep their full lengths, with no trim, mitre or T at each other, when either of the two has `false`. A demolished wall still joins an existing wall and another demolished wall. Where walls of several phases meet at one end, the walls of the same phase join first; a wall of another phase then joins them only if it may join each of them, so a demolished wall never joins a new wall through a third wall. Without the field, walls join as before.
* A proposed plan leaves open the holes of the demolished openings of a demolished wall. A demolished wall with `demolishedOpenings: 'closed'` draws whole over them instead, dashed and hatched as the rest of the wall, with no line at the jambs.
* Sheets, their SVG and PDF exports and the sheet renderer draw the paper phase pens. The plan editor of a proposed view draws demolished work with a screen dash of 4 px and 3 px and existing work with no poché.
* An existing cut wall has no fill, and nothing shows through it: a plan stops the lines under a cut wall at its faces. A slab edge, a room separation line, the site boundary and a line above the cut end at the faces of every cut wall, and a wall face line ends at the edge of a cut column or chimney of the storey, or of a chimney of a lower storey that reaches the cut.
* Plans, roof plans, sections and elevations take `phaseFilter`. On a sheet, each viewport draws its view in the state of its filter, a raster viewport of a section or an elevation too.
* In the existing and the complete state, an element goes with the element that carries it: an opening with its wall, a rooflight or a dormer with its roof, a railing with its stair.
* A link of an existing element to a new one is not drawn in the existing state. A wall that follows only new roofs keeps its own height. A stair loses the link to the hole of a new slab. A dimension that follows only new walls or slabs is not drawn; a dimension that follows a new and an existing element keeps the saved point of the new end. A join setting of a junction with a new wall is not used. In the complete state, the same holds for links to demolished elements.
* `elementIds` of an existing or a complete view leaves out the ids of the elements that the state leaves out. When it names only such elements, the draw is refused with `unknown-element`.
* With a session, the existing and the complete state are each built once for each saved step of the model, when a view of that state is drawn first. An edit does no work for them. Without a session, a draw or a sheet export builds each state that it draws once and disposes it at the end.
* The plan editor edits the proposed model. It refuses a view with `phaseFilter: 'existing'` or `'complete'` with `ProjectDrawingError` code `phase-view-not-editable`.
* A demolition plan is not a filter yet.

## Next

> [card] [Compose a sheet](https://docs.ploterr.com/floorkit/guides/compose-a-sheet.md)
>
> Put the existing and the proposed plan on one sheet.

> [card] [Cut a section](https://docs.ploterr.com/floorkit/guides/cut-a-section.md)
>
> Sections and elevations take the same filter.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.