gdstk.Repetition

class gdstk.Repetition(columns=None, rows=None, spacing=None, v1=None, v2=None, offsets=None, x_offsets=None, y_offsets=None)

Repetition object that creates multiple identical elements.

A repetition can be set in any polygon, path, label or reference to indicate that the element should be copied to multiple positions. Repetitions can be of 5 different types, depending on which arguments are set:

  • Rectangular: requires columns, rows and spacing. Creates a rectangular array of copies.

  • Regular: requires columns, rows, v1 and v2. Creates an array of copies along the specified direction vectors.

  • Explicit: requires offsets. Creates copies at the specified position offsets. The original element at offset (0, 0) is always present, so it should not be specified in the offsets array.

  • X-explicit: requires x-offsets. Creates a linear array of copies at the given x coordinates. Coordinate 0 is always included, so it should not be specified.

  • Y-explicit: requires y-offsets. Creates a linear array of copies at the given y coordinates. Coordinate 0 is always included, so it should not be specified.

Parameters:
  • columns (int) – Number of copies in the x direction (rectangular) or along v1 (regular).

  • rows (int) – Number of copies in the y direction (rectangular) or along v2 (regular).

  • spacing (coordinate pair or complex) – Step sizes in x and y directions for rectangular array.

  • v1 (coordinate pair or complex) – First vector defining the shape of a regular array.

  • v2 (coordinate pair or complex) – Second vector defining the shape of a regular array.

  • offsets (sequence of points) – Explicit offsets for copies.

  • x_offsets (sequence of numbers) – Explicit x coordinates for copies.

  • y_offsets (sequence of numbers) – Explicit y coordinates for copies.

Examples

>>> ref_array = gdstk.Reference("Some Cell")
>>> # Create an array of 3 by 2 references:
>>> ref_array.repetition = gdstk.Repetition(
...     offsets=[(10, 10), (20, 0), (10, -10)]
... )

Notes

All attributes of Repetition objects are read-only.

Methods

get_offsets()

Calculate all offsets generated by this repetition.

Attributes

columns

Number of columns in a rectangular or regular array.

offsets

Offsets for an explicit array.

rows

Number of rows in a rectangular or regular array.

size

Number of offsets generated by this repetition.

spacing

Spacing in a rectangular array.

v1

First vector defining a regular array.

v2

Second vector defining a regular array.

x_offsets

X coordinates for an x-explicit array.

y_offsets

Y coordinates for a y-explicit array.

columns

Number of columns in a rectangular or regular array.

get_offsets() numpy.ndarray

Calculate all offsets generated by this repetition.

Returns:

Offsets generated by this repetition.

offsets

Offsets for an explicit array.

rows

Number of rows in a rectangular or regular array.

size

Number of offsets generated by this repetition.

spacing

Spacing in a rectangular array.

v1

First vector defining a regular array.

v2

Second vector defining a regular array.

x_offsets

X coordinates for an x-explicit array.

y_offsets

Y coordinates for a y-explicit array.