> For the complete documentation index, see [llms.txt](https://modeltrainscript.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://modeltrainscript.gitbook.io/docs/manual/automation/scripts/action/layout-control.md).

# Layout control

This chapter describes the actions available for controlling layout accessories such as signals, turnouts, and other DCC accessories.

## Set accessory <a href="#set-accessory" id="set-accessory"></a>

Sets a layout accessory to a specific state. All DCC accessories — turnouts, signals, decouplers, and more — are controlled the same way through their address and state.

You can configure the accessory in two ways:

* **From layout** — Tap "select from layout" to pick a device you previously configured in the [layout](/docs/manual/layout.md). All available accessories are highlighted with a blue border. The address and available states are filled in automatically.
* **Manual** — Enter the DCC address and desired state directly.

The action supports both standard DCC accessories (address + on/off) and extended accessories (address + value). Multi-address accessories (e.g., multi-aspect signals) are handled automatically when linked to a layout item.

## Set route <a href="#set-route" id="set-route"></a>

Sets multiple accessories at once according to a predefined [route](/docs/manual/automation/routes.md). Select the route from your configured routes, and all its accessory states are applied in sequence.

This is useful when you need to set several turnouts and signals together — for example, to prepare a path through a station throat.

## Set path <a href="#set-path" id="set-path"></a>

Automatically finds and sets a path through your layout, similar to GPS navigation. You define where the train should go, and Model Train Script calculates which turnouts to set.

| Setting                | Description                                                                                                                         |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| **Start position**     | The starting layout item. Select from your layout.                                                                                  |
| **End position**       | The destination layout item. Select from your layout.                                                                               |
| **Waypoints**          | Optional intermediate points the path must pass through.                                                                            |
| **Path strategy**      | How to choose between multiple valid paths: **shortest** (fewest steps), **first** (first found), or **random** (random selection). |
| **Require free path**  | Only set the path if all segments along the route are unoccupied (based on feedback sensor state).                                  |
| **Wait for free path** | When combined with "require free path", the action waits until a free path becomes available instead of continuing immediately.     |
| **Show notification**  | Display an in-app notification showing the path that was set, or a warning if no path was found.                                    |

{% hint style="info" %}
The path finder uses the physical connections between layout items to calculate valid routes. Make sure your layout is fully connected for this action to work correctly.
{% endhint %}
