> ## 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 soil stack

> Stand a soil and vent pipe beside a wall face, from the ground to its vent terminal, and see it in plans, elevations, sections and IFC.

A soil stack is a vertical soil and vent pipe beside the outer face of a wall. It stands in a storey, from the site ground or a set height up to its top, and can end in a vent terminal. Plans draw it as a circle, elevations and sections see it, and IFC exports it as a pipe segment.

## Before you start

You have the house of [Add a roof](https://docs.ploterr.com/floorkit/guides/add-a-roof.md): a room of walls from x 0 to 6 and z 0 to 4, whose outer faces are 0.1 metres outside the wall path, and a gable roof with its eaves 2.83 metres above the storey.

## Write the stack

This stack stands against the east wall, whose outer face is at x 6.1. The pipe is 0.11 metres across, so its centre is a radius plus a 0.04 metre bracket gap off the face, at x 6.195. It rises from the site ground to 2.7 metres above the storey, under the eave, and ends in a wire balloon.

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

export const eastStack: BmSoilStack = {
  id: 'east-stack',
  at: [6.195, 3.2],
  diameter: 0.11,
  top: 2.7,
  terminal: { kind: 'cage' },
};
```

## Add it to the storey

A soil stack is an entry in the `soilStacks` list of its storey.

```typescript theme={null}
export function addSoilStack(session: BuildingSession): void {
  session.apply(
    {
      kind: 'add-element',
      buildingId: 'building',
      storeyId: 'ground',
      list: 'soilStacks',
      element: eastStack,
    },
    session.revision,
  );
}
```

`replace-element` changes it and `remove-element` takes it away. This one starts 0.15 metres above the storey and ends in a capped vent.

```typescript theme={null}
export function replaceSoilStack(session: BuildingSession): void {
  session.apply(
    {
      kind: 'replace-element',
      buildingId: 'building',
      storeyId: 'ground',
      list: 'soilStacks',
      elementId: eastStack.id,
      element: { ...eastStack, baseOffset: 0.15, terminal: { kind: 'cowl', height: 0.2 } },
    },
    session.revision,
  );
}

export function removeSoilStack(session: BuildingSession): void {
  session.apply(
    {
      kind: 'remove-element',
      buildingId: 'building',
      storeyId: 'ground',
      list: 'soilStacks',
      elementId: eastStack.id,
    },
    session.revision,
  );
}
```

## Rules

* `at` is the plan centre of the pipe in world x and z (`bad-point`). `diameter` is the outside diameter in metres above zero (`bad-diameter`); the default is 0.11.
* `top` is the metres from the storey elevation to the top of the pipe, the terminal not included (`bad-top`). `baseOffset` is the metres from the storey elevation to the foot (`bad-base-offset`), below `top` (`stack-top-below-base`). With no `baseOffset` the foot is on the site ground under `at`: on the ground surface of the site where it has `groundPoints`, else at the site elevation.
* A foot that the ground puts at or above `top` builds no pipe and warns `stack-under-ground`.
* `terminal.kind` is `open`, `cage` or `cowl` (`bad-terminal`); `terminal.height` is metres above zero (`bad-terminal`), default 0.15. `open` and no terminal leave the pipe end open. `cage` is a wire balloon 1.4 times the pipe across. `cowl` is a vent the size of the pipe under a cap 1.8 times the pipe across, the cap a quarter of the height.
* A soil stack cuts no roof and no slab. Where it passes a roof, the roof plan draws the roof over it.
* A plan draws one circle of the pipe on the plan of its storey and on the plan of each storey above whose cut plane the pipe passes.
* Elevations see the pipe and its terminal, and sections cut them. The drawings take the stack's own `phase`; `set-phase` marks it, and a copied storey copies it with a new id.
* IFC exports a soil stack as one `IfcPipeSegment` of predefined type `RIGIDSEGMENT`; its terminal is part of the same element.

## Next

> [card] [Add a roof](https://docs.ploterr.com/floorkit/guides/add-a-roof.md)
>
> Gutters and downpipes on the roof edges.

> [card] [Draw the existing and the proposed state](https://docs.ploterr.com/floorkit/guides/existing-and-proposed.md)
>
> Mark a stack to be removed.


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