Skip to content

load_layout

load_layout(
filename,
technology=None,
layers=None,
cell_names=None,
library_properties=False,
post_load_function=None,
compact='auto',
temp_dir=None,
)

Load a layout file as components.

Args

  • filename (str): GDSII/OASIS file name to load.
  • technology (Technology | None): Technology used to create the layout. If not specified, the current default technology will be used.
  • layers (Iterable[tuple[int, int] | str] | None): If not empty, only these layers will be converted.
  • cell_names (Iterable[str] | None): If not empty, only these cells (and dependencies) will be converted.
  • library_properties (bool): If True, this function also returns any library properties the layout might have.
  • post_load_function (Callable[[Component], object] | None): Function called for each component after the layout is loaded from GDSII/OASIS file (see Note).
  • compact (bool | str): Recover exact rectangular repetitions from translated geometry and scalar references. Recovered geometry is stored in synthetic components named with the _PHOTONFORGE_COMPACT_ prefix; these are included in the returned dictionary and passed to post_load_function like any other component. "auto" (default) compacts only files that are at least 256 MiB on disk avoiding compaction overhead for small files while keeping large files bounded automatically.
  • temp_dir (str | None): Directory used for compact-mode spill files when the layout does not fit in the bounded in-memory workspace. Defaults to the system temporary directory.

Note

Polygons with fewer than three vertices after import conversion are skipped with a runtime warning. Zero-area polygons, explicit rectangles, and circles are retained.

GDSII defects that cannot change the layout geometry are recovered with a runtime warning instead of failing the load. This covers label presentation and transforms, element properties, and trailing tape data; out-of-range text anchors are clamped to their default. Coordinates, layers, path widths and types, reference names and arrays, and the library framing records remain strict.

The post_load_function is called once for each component after the layout is imported, in case, for example, pins or ports need to be automatically registered and created or in-place modification or analysis is needed. The provided function operates on components without copying them, which means that modifications done using this callback are implemented in-place. If the layout has a hierarchy, the callback is applied through the hierarchy as well, therefore traversing through the component tree is not needed.

Returns

dict[str, Component] | tuple[dict[str, Component], Properties]: Dictionary of components indexed by name. If library_properties == True, also returns those properties.

See Also

Importing a GDSII/OASIS Layout