write_layout

photonforge.write_layout(filename, *components, paths_to_polygons=True, compression_level=9, fracture_limit=0, library_name='LIBRARY', library_properties=None, pre_export_function=None)

Export this component as a GDSII or OASIS file.

The layout format is defined by the file name extension: “.gds” or “.oas” for GDSII or OASIS files, respectively.

Parameters:
  • filename (str) – Output file name.

  • *components (Component) – Components to write to the layout file.

  • paths_to_polygons (bool) – If True, all Path structures will be stored as polygonal contours.

  • compression_level (int) – Level of compression of the file. Disabled if set to 0. Maximal compression level is 9. (OASIS only)

  • fracture_limit (int) – Polygons with a number of vertices above this limit will be fractured into multiple polygons. The limit is ignored if not above 4. (GDSII only)

  • library_name (str) – Name of the library. (GDSII only)

  • library_properties (Properties | None) – Properties to be included in the exported library (OASIS only).

  • pre_export_function (Callable[[Component], Any] | None) – Function called for each component before exporting the layout (see note).

Note

The pre_export_function is called once for each component to be exported, in case, for example, we are required to add some marker or geometry to identify ports. The provided function is called with a single positional argument: a shallow copy of the original component. That means that any changes made to the component directly (such as adding or removing geometry and labels) will be stored in the layout, but will not affect the original component.