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

# Building

> The live mass that a project builds for each saved mass. Read it; change the mass with the project commands.

## Import

```typescript theme={null}
import { Building } from '@opengeometry/floorkit';
```

**Inheritance:** `extends OPElement implements IShape, IPlaceable, PlanVectorExportable`

## Constructor

```typescript theme={null}
constructor(config: Partial<Omit<BuildingOptions, "profile" | "height" | "segments">> & Pick<BuildingOptions, "segments">);
```

<ParamField path="config.type" type="ElementType.BUILDING" />

<ParamField path="config.color" type="number">
  Colour of the mass: of every part that has no `color` of its own.
</ParamField>

<ParamField path="config.ogid" type="string" />

<ParamField path="config.propertySets" type="PropertySets" />

<ParamField path="config.elevation" type="number">
  World Y of the bottom face of the first segment.
</ParamField>

<ParamField path="config.labelName" type="string" />

<ParamField path="config.use" type="BuildingUse">
  Programme of the whole mass; a segment or storey may override it.
</ParamField>

<ParamField path="config.showStoreys" type="boolean">
  Draw the storey boundaries on the solids.
</ParamField>

<ParamField path="config.segments" type="MassSegment[]" required>
  The stack, bottom-up. Each segment extrudes from the top of the one below and carries its storeys,
  which tile its height.
</ParamField>

## Properties

<ResponseField name="ogType" type="ElementType" />

<ResponseField name="ogid" type="string" />

<ResponseField name="subElements2D" type="Map<string, OPGeometry>" />

<ResponseField name="subElements3D" type="Map<string, OPGeometry>" />

<ResponseField name="selected" type="boolean" />

<ResponseField name="edit" type="boolean" />

<ResponseField name="locked" type="boolean" />

<ResponseField name="activeSegment" type="number">
  Which segment the `profile` / `height` / `extrudeHeight` accessors address.
</ResponseField>

<ResponseField name="propertySet" type="BuildingOptions" />

<ResponseField name="segments" type="MassSegment[]">
  Read-only. The stack, cloned.
</ResponseField>

<ResponseField name="activePart" type="string | undefined">
  The saved id of the active segment: the part that the editor grips, a move, a turn and Delete act
  on. Setting the id of a segment of this mass makes it active; any other id changes nothing. An
  editor reads it when it builds its grips and sets it again when one of its gestures begins, so two
  editors on one mass each edit the part whose grips they drag.
</ResponseField>

<ResponseField name="numberOfStoreys" type="number">
  Read-only.
</ResponseField>

<ResponseField name="footprintArea" type="number">
  Read-only.
</ResponseField>

<ResponseField name="grossFloorArea" type="number">
  Read-only.
</ResponseField>

<ResponseField name="labelName" type="string" />

<ResponseField name="profile" type="BuildingProfile" />

<ResponseField name="height" type="number">
  Height of the ACTIVE segment (the total is `quantities().height`).
</ResponseField>

<ResponseField name="extrudeBase" type="number">
  Read-only. Local Y of the bottom of the active segment: the plane of its footprint and the base of
  the push/pull grip, which for an upper segment is the top of the segments below it.
</ResponseField>

<ResponseField name="extrudeHeight" type="number">
  Push/pull alias for the GUIEditor — the extrude dimension is the active segment's height.
</ResponseField>

<ResponseField name="use" type="BuildingUse" />

<ResponseField name="showStoreys" type="boolean" />

<ResponseField name="color" type="number" />

<ResponseField name="elevation" type="number" />

<ResponseField name="outline" type="boolean" />

<ResponseField name="profileView" type="boolean" />

<ResponseField name="modelView" type="boolean" />

## Methods

### editableSchema

```typescript theme={null}
static editableSchema(): OPEditableSchema;
```

Self-describing editable surface.

### setSegment

```typescript theme={null}
setSegment(index: number, patch: Partial<Omit<MassSegment, "storeys">>): void;
```

Patch a segment of the live mass, as an editor does during a drag.

### selectPart

```typescript theme={null}
selectPart(object: THREE.Object3D): boolean;
```

Make the part that drew `object` the active segment, so that the editor grips, a move and a turn, and Delete act on that part.

### storeyElevations

```typescript theme={null}
storeyElevations(): Array<{
    storeyId: string;
    segmentId: string;
    elevation: number;
    height: number;
    use?: BuildingUse;
}>;
```

Every storey with its world floor elevation, bottom-up.

### quantities

```typescript theme={null}
quantities(options?: {
    grade?: number;
}): MassQuantities;
```

Quantities of the mass; `options.grade` is the world Y of the site grade (default 0).

### move

```typescript theme={null}
move(delta: Vec3): void;
```

Translate this element by `delta` (world-space, meters).

### rotate

```typescript theme={null}
rotate(angleDeg: number, axis?: Vec3, anchor?: Vec3): void;
```

Rotate this element by `angleDeg` around `axis` (default Y-up), pivoted at `anchor` (default the element's own centroid).

### setOPGeometry

```typescript theme={null}
setOPGeometry(): void;
```

Draw the stack.

### getExportRoots

```typescript theme={null}
getExportRoots(view: PlanExportView): THREE.Object3D[];
```

### toDrawing

```typescript theme={null}
toDrawing(view: PlanExportView): DrawingPrimitive[];
```

One region per segment plus a `"&#123;n&#125;F · &#123;use&#125;"` label at the top segment's centroid.

### setOPMaterial

```typescript theme={null}
setOPMaterial(): void;
```

Draw again the parts whose colour changed; each colour keeps its own shared materials.

### getOPConfig

```typescript theme={null}
getOPConfig(): BuildingOptions;
```

### setOPConfig

```typescript theme={null}
setOPConfig(config: Partial<BuildingOptions>): void;
```

Merge a partial config into the live mass.

### dispose

```typescript theme={null}
dispose(): void;
```

## Types

### BuildingOptions

```typescript theme={null}
interface BuildingOptions extends HasPropertySets {
  ogid?: string;
  labelName: string;
  type: ElementType.BUILDING;
  profile: BuildingProfile;
  height: number;
  segments: MassSegment[];
  use: BuildingUse;
  showStoreys: boolean;
  color: number;
  elevation: number;
}
```

### MassSegment

```typescript theme={null}
interface MassSegment {
  id: string;
  name?: string;
  footprint: PolygonProfile;
  height: number;
  use?: BuildingUse;
  color?: number;
  storeys: MassStorey[];
}
```

<ResponseField name="id" type="string" required />

<ResponseField name="name" type="string" />

<ResponseField name="footprint" type="PolygonProfile" required>
  Footprint in the world XZ plane; holes are courtyards.
</ResponseField>

<ResponseField name="height" type="number" required>
  Extrusion height, metres. Always equals the sum of `storeys[].height`.
</ResponseField>

<ResponseField name="use" type="BuildingUse" />

<ResponseField name="color" type="number">
  Colour of this part, `0xrrggbb`; absent draws it in the colour of the mass.
</ResponseField>

<ResponseField name="storeys" type="MassStorey[]" required>
  Explicit storeys, bottom-up, tiling `height` exactly.
</ResponseField>

### BuildingUse

Programme of a mass, a segment, or a storey.

```typescript theme={null}
type BuildingUse =
  | 'residential'
  | 'office'
  | 'retail'
  | 'hotel'
  | 'civic'
  | 'industrial'
  | 'parking'
  | 'mixed'
  | 'other'
  | `custom:${string}`;
```

### MassQuantities

```typescript theme={null}
interface MassQuantities {
  footprintArea: number;
  grossFloorArea: number;
  grossFloorAreaByUse: Record<string, number>;
  grossFloorAreaByKind: Record<AreaKind, number>;
  grossVolume: number;
  height: number;
  numberOfStoreys: number;
  facadeAreaFlat: number;
  storeys: StoreyQuantity[];
}
```

<ResponseField name="footprintArea" type="number" required>
  `Qto_BuildingBaseQuantities.FootPrintArea` — net area of the ground segment.
</ResponseField>

<ResponseField name="grossFloorArea" type="number" required>
  `Qto_BuildingBaseQuantities.GrossFloorArea` — Σ storey plates.
</ResponseField>

<ResponseField name="grossFloorAreaByUse" type="Record<string, number>" required />

<ResponseField name="grossFloorAreaByKind" type="Record<AreaKind, number>" required />

<ResponseField name="grossVolume" type="number" required>
  `Qto_BuildingBaseQuantities.GrossVolume` — Σ netArea × segment height.
</ResponseField>

<ResponseField name="height" type="number" required>
  `Qto_BuildingBaseQuantities.Height` — top of the stack minus `elevation`.
</ResponseField>

<ResponseField name="numberOfStoreys" type="number" required>
  `Pset_BuildingCommon.NumberOfStoreys`.
</ResponseField>

<ResponseField name="facadeAreaFlat" type="number" required>
  Σ (outer + hole perimeters) × height per segment — every face is vertical.
</ResponseField>

<ResponseField name="storeys" type="StoreyQuantity[]" required />

### BuildingProfile

Polygon profile for a Building — alias of PolygonProfile.

```typescript theme={null}
type BuildingProfile = PolygonProfile;
```

### StoreyQuantity

```typescript theme={null}
interface StoreyQuantity {
  storeyId: string;
  segmentId: string;
  elevation: number;
  height: number;
  use?: BuildingUse;
  areaKind: AreaKind;
  grossFloorArea: number;
  perimeter: number;
}
```

<ResponseField name="storeyId" type="string" required />

<ResponseField name="segmentId" type="string" required />

<ResponseField name="elevation" type="number" required>
  World Y of the storey's floor.
</ResponseField>

<ResponseField name="height" type="number" required />

<ResponseField name="use" type="BuildingUse" />

<ResponseField name="areaKind" type="AreaKind" required />

<ResponseField name="grossFloorArea" type="number" required>
  Net plate area (footprint minus courtyards), m².
</ResponseField>

<ResponseField name="perimeter" type="number" required>
  Outer footprint perimeter, m.
</ResponseField>

## Related

* [`OPElement`](/floorkit/api/architecture/op-element)
* [`AreaKind`](/floorkit/api/architecture/massing-helpers#areakind)
* [`DrawingPrimitive`](/floorkit/api/drawings/draw-project-view#drawingprimitive)
* [`ElementType`](/floorkit/api/architecture/op-element#elementtype)
* [`HasPropertySets`](/floorkit/api/architecture/op-element#haspropertysets)
* [`IPlaceable`](/floorkit/api/architecture/op-element#iplaceable)
* [`IShape`](/floorkit/api/shapes/cuboid-shape#ishape)
* [`MassStorey`](/floorkit/api/architecture/massing-helpers#massstorey)
* [`OPEditableSchema`](/floorkit/api/architecture/op-element#opeditableschema)
* [`OPGeometry`](/floorkit/api/architecture/opening#opgeometry)
* [`PlanExportView`](/floorkit/api/shapes/cylinder-shape#planexportview)
* [`PlanVectorExportable`](/floorkit/api/shapes/cylinder-shape#planvectorexportable)
* [`PolygonProfile`](/floorkit/api/primitives/polygon-maths#polygonprofile)
* [`Vec3`](/floorkit/api/architecture/wall#vec3)


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