gdsfactory.routing.route_ports_to_side(component: Component, ports: list[Port] | Component | list[Port] | None = None, side: str = 'north', x: float | None = None, y: float | None = None, **kwargs) tuple[list[OpticalManhattanRoute], list[Port]][source]#

Routes ports to a given side.

  • component – component to route.

  • ports – list/dict/Component/ComponentReference to route to a side.

  • side – ‘north’, ‘south’, ‘east’ or ‘west’.

  • x – position to route ports for east/west. None, uses most east/west value.

  • y – position to route ports for south/north. None, uses most north/south value.

  • kwargs – additional arguments to pass to the routing function.

Keyword Arguments:
  • radius – in um.

  • separation – in um.

  • routing. (extend_left, extend_right for south/north)

  • routing.


with routing elements. List of ports: of the new ports.

Return type:

List of routes

import gdsfactory as gf

c = gf.Component('sample_route_sides')
dummy = gf.components.nxn(north=2, south=2, west=2, east=2)
sides = ["north", "south", "east", "west"]
d = 100
positions = [(0, 0), (d, 0), (d, d), (0, d)]

for pos, side in zip(positions, sides):
    dummy_ref = dummy.ref(position=pos)
    routes, ports = gf.routing.route_ports_to_side(dummy_ref, side, layer=(1, 0))
    for route in routes:
    for i, p in enumerate(ports):
        c.add_port(name=f"{side[0]}{i}", port=p)


(Source code)