grid_layout¶
- photonforge.grid_layout(objects, gap=0, shape=None, align_x='center', align_y='center', direction='lr-bt', include_ports=True, layer=(0, 0), name=None)¶
Arrange components or other structures in a grid layout.
- Parameters:
objects (Sequence[Component | Reference | Circle | Path | Polygon | Rectangle]) – Sequence of objects to arrange. They can be instances of
Component
,Reference
, or 2D structures.gap (float | Sequence[float]) – Horizontal and vertical gaps added between objects.
shape (Sequence[int] | None) – Grid shape, specified as
(columns, rows)
.align_x (Literal['left', 'right', 'center', 'origin'] | None) – Horizontal alignment within the grid cell.
align_y (Literal['bottom', 'top', 'center', 'origin'] | None) – Vertical alignment within the grid cell.
direction (Literal['lr-bt', 'lr-tb', 'rl-bt', 'rl-tb', 'bt-lr', 'tb-lr', 'bt-rl', 'tb-rl']) – 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 (bool) – Whether or not to include ports when computing component bounds.
layer (tuple[int]) – If arraging geometrical structures, add them to this layer.
name (str | None) – Name of the resulting component.
- Returns:
Component with the objects arranged in a grid.
- Return type: