Skip to content

grid_layout

grid_layout(
objects: collections.abc.Sequence[
photonforge.Component
| photonforge.Reference
| photonforge.Circle
| photonforge.Path
| photonforge.Polygon
| photonforge.Rectangle
],
gap: float | collections.abc.Sequence[float] = 0,
shape: collections.abc.Sequence[int] | None = None,
align_x: Literal['left', 'right', 'center', 'origin'] | None = 'center',
align_y: Literal['bottom', 'top', 'center', 'origin'] | None = 'center',
direction: Literal[
'lr-bt',
'lr-tb',
'rl-bt',
'rl-tb',
'bt-lr',
'tb-lr',
'bt-rl',
'tb-rl',
] = 'lr-bt',
include_ports: bool = True,
layer: tuple[int] = (0, 0),
name: str | None = None,
) -> photonforge.Component

Arrange components or other structures in a grid layout.

Args

  • objects: Sequence of objects to arrange. They can be instances of Component, Reference, or 2D structures.
  • gap: Horizontal and vertical gaps added between objects.
  • shape: Grid shape, specified as (columns, rows).
  • align_x: Horizontal alignment within the grid cell.
  • align_y: Vertical alignment within the grid cell.
  • direction: Placement order in the grid. Must be a combination of "lr" (left-to-right) or "rl" (right-to-left), and "bt" (bottom-to-top) or "tb" (top-to-bottom), as in "lr-bt", "rl-tb", "tb-lr", etc.
  • include_ports: Whether or not to include ports when computing component bounds.
  • layer: If arraging geometrical structures, add them to this layer.
  • name: Name of the resulting component.

Returns

Component with the objects arranged in a grid.