> ## 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.

# Add a storey

> Put a second floor on top of the first one.

export const LiveExample = ({path, title = 'Live example', height = 460}) => {
  return <Frame>
      <iframe src={`https://floorkit-examples.ploterr.com/floorkit/${path}?embed=1`} ref={frame => {
    if (!frame || !['localhost', '127.0.0.1'].includes(window.location.hostname)) return;
    const local = `http://localhost:5555/${path}?embed=1`;
    if (frame.src !== local) frame.src = local;
  }} title={title} loading="lazy" allow="fullscreen" style={{
    width: '100%',
    height: `${height}px`,
    border: 0,
    display: 'block'
  }} />
    </Frame>;
};

A storey is one level of the building. It has an elevation, a height and its own elements. To make a building with two floors, add a second storey at the height where the first one ends.

<LiveExample path="guides/add-a-storey" />

## Before you start

You have a session from [Start a building](/floorkit/guides/start-a-building). The ground storey is 3 metres high.

## Write the storey

The new storey starts at 3 metres. It has its own walls and its own floor slab.

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

export const firstFloor: BmStorey = {
  id: 'first',
  name: 'First floor',
  elevation: 3,
  height: 3,
  walls: [
    {
      id: 'first-walls',
      points: [
        [0, 0],
        [6, 0],
        [6, 4],
        [0, 4],
      ],
      closed: true,
      thickness: 0.2,
    },
  ],
  slabs: [
    {
      id: 'first-floor-slab',
      profile: {
        outerRing: [
          [-0.1, -0.1],
          [6.1, -0.1],
          [6.1, 4.1],
          [-0.1, 4.1],
        ],
      },
      thickness: 0.2,
      baseOffset: -0.2,
    },
  ],
};
```

## Add it to the building

```typescript theme={null}
export function addStorey(session: BuildingSession): void {
  session.apply(
    { kind: 'add-storey', buildingId: 'building', storey: firstFloor },
    session.revision,
  );
}
```

The `add-storey` command adds the storey with its elements, and the session builds it. You keep the session and its undo history. The command rejects a storey id that the building has.

`replace-storey-settings` sets the name, the elevation, the height and the usage of a storey, and `remove-storey` removes a storey. See [Editing and history](/floorkit/concepts/editing-and-history#add-replace-and-remove).

## Rules

* `elevation` is the height of the storey floor in the world. It is the only world height in a storey.
* The elements in a storey use offsets from that elevation. You do not add the elevation to them.
* Each storey has its own walls. Walls on different storeys do not join.
* Ids are unique in the full model, not only in one storey.

## Use the storey in commands

Each edit command names its storey. To add a door to the new walls, use `storeyId: 'first'` and `wallId: 'first-walls'`.

## Next

<CardGroup cols={2}>
  <Card title="Move and reshape" icon="arrows-up-down-left-right" href="/floorkit/guides/move-and-reshape">
    Change the elements that you made.
  </Card>

  <Card title="Create a plan view" icon="compass-drafting" href="/floorkit/guides/create-a-plan-view">
    Make a plan of one storey.
  </Card>
</CardGroup>


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