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

# Arrange blocks

> Align, distribute and repeat placed blocks as one undo step.

## Import

```typescript theme={null}
import {
  alignMembers,
  arrangementSupports,
  distributeMembers,
  repeatTransform,
  applyArrangement,
  applyRepeat,
  arrangementCommand,
  repeatCommand,
} from '@opengeometry/floorkit';
```

## alignMembers

Moves that bring each eligible member's edge or centre onto the anchor's, along one frame axis.

```typescript theme={null}
function alignMembers(
  members: readonly ArrangementMember[],
  edge: 'start' | 'centre' | 'end',
  axis: ArrangementAxis,
  anchorId: string,
  frameAngle?: number,
): Arrangement;
```

## arrangementSupports

Whether members of a family can be aligned, distributed and repeated; only placed blocks can.

```typescript theme={null}
function arrangementSupports(family: ArrangementFamily): boolean;
```

## distributeMembers

Equal clear gaps or equal centre pitches along one frame axis, in order of centre (ties by id).

```typescript theme={null}
function distributeMembers(
  members: readonly ArrangementMember[],
  axis: ArrangementAxis,
  mode: 'clear-gap' | 'centre-pitch',
  value?: number,
  frameAngle?: number,
): Distribution;
```

## repeatTransform

Footprints of `count` copies, each one more step (a translation, or a turn about a pivot) on.

```typescript theme={null}
function repeatTransform(member: ArrangementMember, step: RepeatStep, count: number): RepeatPreview;
```

## applyArrangement

Apply arrangementCommand as one history step.

```typescript theme={null}
function applyArrangement(
  session: BuildingSession,
  at: ArrangementPlace,
  moves: readonly ArrangementMove[],
): ArrangementCommit;
```

## applyRepeat

Apply repeatCommand as one history step; `ids` are the new copies.

```typescript theme={null}
function applyRepeat(
  session: BuildingSession,
  at: ArrangementPlace,
  sourceId: string,
  step: RepeatStep,
  count: number,
): ArrangementCommit;
```

## arrangementCommand

One batch that moves placed blocks of a storey; each move saves whole millimetres, and a member that is not a placed block throws `BmEditError` `invalid-target`.

```typescript theme={null}
function arrangementCommand(
  model: BuildingModel,
  at: ArrangementPlace,
  moves: readonly ArrangementMove[],
): BatchCommand;
```

## repeatCommand

One batch that adds `count` copies of a placed block, each one more step on, with ids unused anywhere in the model.

```typescript theme={null}
function repeatCommand(
  model: BuildingModel,
  at: ArrangementPlace,
  sourceId: string,
  step: RepeatStep,
  count: number,
): {
  command: BatchCommand;
  ids: string[];
};
```

## Types

### Arrangement

```typescript theme={null}
interface Arrangement {
  translations: ArrangementMove[];
  members: ArrangementMemberStatus[];
}
```

### ArrangementAxis

```typescript theme={null}
type ArrangementAxis = 'u' | 'v';
```

### ArrangementFamily

```typescript theme={null}
type ArrangementFamily = 'instance' | 'hosted-opening' | 'wall' | 'datum';
```

### ArrangementMember

```typescript theme={null}
interface ArrangementMember {
  id: string;
  footprint: Footprint;
  family: ArrangementFamily;
}
```

### ArrangementMemberStatus

```typescript theme={null}
interface ArrangementMemberStatus {
  id: string;
  status: 'fixed' | 'moved' | 'ineligible';
  reason?: string;
}
```

### ArrangementMove

```typescript theme={null}
interface ArrangementMove {
  id: string;
  translation: [number, number];
}
```

### Distribution

```typescript theme={null}
interface Distribution extends Arrangement {
  spacings: number[];
}
```

### RepeatPreview

```typescript theme={null}
interface RepeatPreview {
  id: string;
  status: 'repeats' | 'ineligible';
  reason?: string;
  footprints: Footprint[];
}
```

### RepeatStep

```typescript theme={null}
type RepeatStep =
  | readonly [number, number]
  | {
      pivot: readonly [number, number];
      angle: number;
    };
```

### ArrangementPlace

```typescript theme={null}
interface ArrangementPlace {
  buildingId: string;
  storeyId: string;
}
```

## Related

* [`BuildingSession`](https://docs.ploterr.com/floorkit/api/editor/building-session)
* [`ArrangementCommit`](https://docs.ploterr.com/floorkit/api/editor/managed-plan-editor#arrangementcommit)
* [`BatchCommand`](https://docs.ploterr.com/floorkit/api/editor/building-session#batchcommand)
* [`BuildingModel`](https://docs.ploterr.com/floorkit/api/architecture/validate-building-model#buildingmodel)
* [`Footprint`](https://docs.ploterr.com/floorkit/api/editor/managed-plan-editor#footprint)


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