# Route a layout Start with the [first route](../../README.md#route-a-net), then replace the example ports and add your layout's constraints. ## Define the inputs 1. **Choose a coordinate unit.** Inire snaps port coordinates to an integer grid. Choose a unit fine enough to preserve narrow gaps, and use it for widths, radii, clearance, and bounds too. 2. **Set source and target headings.** Heading 0 points east and 90 points north. The source heading points along the launch. The target heading points along the arrival. If your device library labels the target port with its outward heading, reverse it by 180 degrees. 3. **Add a net for each connection.** Give each `NetSpec` a unique ID and the guide width. Set your process limits through `SearchOptions` and choose the required clearance on `RoutingProblem`. 4. **Add keepouts.** Supply Shapely polygons in `static_obstacles` and use `bounds` for the board rectangle. Leave enough access at the ports for the guide and its permitted bends. [Input fields](api-reference.md#layout-inputs) 5. **Run and check.** Call `route(problem, options=options)` and check each `result.is_valid`. Start with automatic mode for general layouts. [Read the result](tune-and-troubleshoot.md#read-the-result) ## Connect a preplaced crossing - Place the device and reserve its keepout first. - Leave openings in the keepout at the physical ports. - Define the external legs as separate nets. The placed cell supplies the internal connections. ![Four routed legs stop at labeled ports in the notched keepout of a preplaced crossing. Dashed links inside the cell indicate connections supplied by the device.](../figures/placed-crossing.png) Each leg meets a port at the end of an access slot. The dashed links show the device's internal connections schematically. The four external paths come from Inire's `crossing-single` fixture. [Crossing fixtures](../benchmark-fixtures.md#preplaced-crossings) ## Reuse an existing route - **Give the router a route it can move.** Put `result.as_seed()` in `initial_paths` under the net's ID. A seed uses the current start port, width, and geometry settings. A partial seed can suggest an approach. - **Hold a route fixed.** Add `result.locked_geometry` to `static_obstacles` while routing other nets. The next run applies its own clearance. To reuse the verified routes from a first problem as fixed obstacles, add them to a second problem that contains the remaining nets. ```python from dataclasses import replace from inire import route first = route(first_problem) locked = tuple( polygon for result in first.results_by_net.values() if result.is_valid for polygon in result.locked_geometry ) obstacles = ( next_problem.static_obstacles + locked ) second = route(replace( next_problem, static_obstacles=obstacles, )) ``` See the [locked-path example](../../examples/README.md#route-around-fixed-geometry) for the resulting detour and the [seed reference](api-reference.md#path-seeds) for building a hint by hand.