Advanced multi-layer routing for GDSFactory layouts — single waveguides, multi-wire bundles, fan-in/fan-out, and obstacle-aware A* pathfinding, built on top of the kfactory geometry kernel with a Rust-based pathfinding engine.

When to use it

Reach for DoRoutes when the routing built into gdsfactory hits its limits:

  • the bundle router can't fit because of tight pitches, mismatched port spacings, or non-axis-aligned port orientations,
  • you need an obstacle-aware route — a wire or bundle that has to navigate around components placed earlier in the layout,
  • you're describing a circuit declaratively from a YAML netlist and want pluggable routing strategies registered on your PDK.

Quickstart

import doroutes as dr
import gdsfactory as gf
from gdsfactory.gpdk import get_generic_pdk

PDK = get_generic_pdk()

c = gf.Component()
ref = c << dr.pcells.field1()
dr.add_route_astar(
    component=c,
    start=ref.ports["o1"],  # routable end of field1's "in" sub-instance
    stop=ref.ports["o2"],   # routable end of field1's "out" sub-instance
    straight="straight",
    bend={"component": "bend_euler", "settings": {"radius": 5}},
    layers=["WG"],          # obstacles to avoid
    grid_unit=500,          # A* grid pitch (dbu)
)

That's a single waveguide routed between two ports, avoiding everything else on the WG layer. From here the API scales up to multi-wire bundles, custom fan-in strategies, and YAML-driven circuit construction.

Where to start

The tutorials are organised in four tiers, walking from the simplest single-wire case up to declarative circuit construction:

Single Routing — one waveguide between two ports.

Bundle Routing — N parallel wires between port arrays.

  • Fan-In — the building block: how N spread-out ports get compressed onto a single bundle line, with three strategy choices.
  • Bundle From Corners — deterministic bundle shapes via corners or relative steps.
  • A* Bundle Routing — obstacle-aware bundles.

Patterns & Integration — applied recipes.

Advanced — under-the-hood mechanics.

  • Discretization — how A* projects layout geometry onto its search grid, and what grid_unit actually controls.

If you're new, start with Corners Routing — the simplest mental model — and follow the "Next steps" links at the bottom of each tutorial.

Reference

The full API surface (function signatures, types, and docstrings) lives in the API and Types pages.