# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://modeltrainscript.gitbook.io/docs/manual/automation/scripts/action/layout-control.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
