[add_route_manual][doroutes.add_route_manual] with steps= is the relative-coordinate sibling of [add_route_manual][doroutes.add_route_manual] with corners=. Instead of giving absolute (x, y) corner points, you describe each leg of the route as a one-axis step. The big advantage: the same step recipe works at any placement, so it's a natural way to write reusable routing patterns.

Each step contributes one corner. The four supported forms are:

Key Meaning
dx move by Δx µm from the previous corner (manhattan east/west)
dy move by Δy µm from the previous corner (manhattan north/south)
x absolute x in µm, or a "inst,port" string that resolves to a port's x
y absolute y in µm, or a "inst,port" string that resolves to a port's y

All distances are in microns (float allowed). Interior steps must use exactly one axis (horizontal or vertical). The first and last steps may combine both axes to set the fan-in/out anchor.

This is optical routing: bends are bend_euler at the PDK minimum radius (5 µm for gdsfactory.gpdk).

Imports

import gdsfactory as gf
from gdsfactory.gpdk import PDK

import doroutes as dr

PDK.activate()

Z-Detour Described as Steps

The same field1 layout, routed with a step recipe that mixes relative and absolute moves and ends by anchoring the y-coordinate to the output port directly.

c = gf.Component()
ref = c << dr.pcells.field1()

start = ref.ports["o1"]  # routable end of field1's "in" sub-instance
stop = ref.ports["o2"]  # routable end of field1's "out" sub-instance

steps = [
    {"dx": 41.5},  # head east 41.5 µm from the input
    {"dy": 32.5},  # turn north 32.5 µm
    {"x": 2.0},  # turn west, land at absolute x = 2 µm
    {"y": stop.dcenter[1]},  # turn north, land at the y (µm) of the output port
]

dr.add_route_manual(
    component=c,
    start=start,
    stop=stop,
    steps=steps,
    straight="straight",
    bend={"component": "bend_euler", "settings": {"radius": 5}},
)
dr.util.show_cell(c)

Next steps

  • Prefer absolute corner points? See Corners Routing.
  • The bundle version of this routing style is add_bundle_manual(steps=...), demonstrated in Array Routing.
  • For obstacle-aware routing without writing the shape yourself, see A* Single Route.