gdsfactory.routing.route_ports_to_side

gdsfactory.routing.route_ports_to_side#

gdsfactory.routing.route_ports_to_side(ports: dict[str, ~gdsfactory.port.Port] | list[~gdsfactory.port.Port] | ~gdsfactory.component.Component | ~gdsfactory.component_reference.ComponentReference, side: str = 'north', x: float | None = None, y: float | None = None, routing_func: ~collections.abc.Callable = <function get_route>, **kwargs) tuple[list[Route], list[Port]][source]#

Routes ports to a given side.

Parameters:
  • 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.

  • routing_func – the routing function. By default uses get_route.

Keyword Arguments:
  • radius – in um.

  • separation – in um.

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

  • routing.

Returns:

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)
    c.add(dummy_ref)
    routes, ports = gf.routing.route_ports_to_side(dummy_ref, side, layer=(1, 0))
    for route in routes:
        c.add(route.references)
    for i, p in enumerate(ports):
        c.add_port(name=f"{side[0]}{i}", port=p)

c.plot()

(Source code, png, hires.png, pdf)

../_images/gdsfactory-routing-route_ports_to_side-1.png