gdstk.GdsWriter

class gdstk.GdsWriter(outfile, name='library', unit=1e-6, precision=1e-9, max_points=199, timestamp=None)

Multi-step GDSII stream file writer.

When a design is too large to be completely created in memory, it is not possible to create a gdstk.Library to save it as a GDSII file. In such cases, it might be possible to still create the desired design creating, saving and deleting one cell at a time. Saving one cell at a time can be done thru this class.

Parameters:
  • outfile (str or pathlib.Path) – Name of the output file.

  • unit – User units in meters.

  • precision – Desired precision to store the units once written to a GDSII file.

  • max_points – Maximal number of vertices per polygon. Polygons with more vertices that this are automatically fractured.

  • timestamp (datetime object) – Timestamp to be stored in the GDSII file. If None, the current time is used.

Eaxmples:
>>> writer = gdstk.GdsWriter()
>>> cell1 = some_function_that_creates_a_huge_cell()
>>> writer.write(cell1)
>>> del cell1
>>> cell2 = some_function_that_creates_a_huge_cell()
>>> writer.write(cell2)
>>> del cell2
>>> writer.close()

Methods

close()

Finish writing the output file and close it.

write(*cells)

Write cells to the output file.

close() None

Finish writing the output file and close it.

write(*cells) self

Write cells to the output file.