Gdspy
Python module for creating GDSII stream files, usually CAD layouts.
Install / Use
/learn @heitzmann/GdspyREADME
GDSPY README
Gdspy is a Python module for creation and manipulation of GDSII stream files. Key features for the creation of complex CAD layouts are included:
- Boolean operations on polygons (AND, OR, NOT, XOR) based on clipping algorithm
- Polygon offset (inward and outward rescaling of polygons)
- Efficient point-in-polygon solutions for large array sets
Gdspy also includes a simple layout viewer.
Typical applications of Gdspy are in the fields of electronic chip design, planar lightwave circuit design, and mechanical engineering.
Future of Gdspy
In trying to improve the performance of Gdspy for large layouts, we ended up concluding that the best way to reach our goal was to rewrite the critical parts of the library as a C extension. It turns out that beside obvious functions, method calling has a big impact in performance due to the overhead it introduces. The best solution was to re-design the whole project as a C++ library with a thin Python wrapper: thus was born Gdstk, the GDSII Tool Kit.
Therefore, version 1.6 will be the last major release of Gdspy, with development focused only on bug fixes. Users are encouraged to move from Gdspy to Gdstk: although their API is not 100% compatible, the new module should be familiar enough to allow a quick transition.
Installation
Dependencies:
- Python (tested with versions 2.7, 3.6, 3.7, and 3.8)
- Numpy
- C compiler (needed only if built from source)
- Tkinter (optional: needed for the
LayoutViewerGUI) - Sphinx (optional: to build the documentation)
Linux / OS X
Option 1: using pip:
python -m pip install --user gdspy
Option 2: download the source from github and build/install with:
python setup.py install
Windows
The preferred option is to install pre-compiled binaries from here.
Installation via pip and building from source as above are also possible, but an appropriate build environment is required for compilation of the C extension modules.
Documentation
The complete documentation is available here.
The source files can be found in the docs directory.
Support
Help support Gdspy development by donating via PayPal or sponsoring me on GitHub
History of changes
Version 1.6.13 (Apr 26, 2023)
- Allow ill-formed GDSII label anchors to be correctly loaded.
Version 1.6.12 (Jun 2, 2022)
- Fix in
Cell.get_texttypes. - Allow labels to inherit transforms through
get_labels.
Version 1.6.11 (Jan 14, 2022)
- Fix in
Cell.write_svgwhen missing references. - Speed improvements in
Cell.remove_polygons(thanks Troy for the contribution).
Version 1.6.10 (Nov 14, 2021)
- Fix in
Cell.get_polygons
Version 1.6.9 (Sep 23, 2021)
- Fix in
Cell.get_polygonswith specified layer and datatype. - Raise error for duplicate cells when reading a GDSII file.
Version 1.6.8 (Aug 2, 2021)
- Fix in
booleanfor complex geometries that freeze the operation.
Version 1.6.7 (Jul 14, 2021)
- Fixes in
booleanfor bugs with self-intersecting holes and holes horizontal edges. - Fix bug in warning message.
Version 1.6.6 (Jun 09, 2021)
- Fix error in
Path.smoothnot finding_hobbyfunction. - Allow precision specification in SVG output.
Version 1.6.5 (Jun 08, 2021)
- Support GDSII files with 0-padding at the end.
- Allow fixing and modifying GDSII file timestamps.
- Thanks Troy Tamas and Joaquin Matres for the fixes
Version 1.6.4 (Apr 23, 2021)
- Fix missing module import (thanks Troy Tamas for the fix).
Version 1.6.3 (Dec 28, 2020)
- Fix bounding box edge case (thanks Troy Tamas for the fix).
Version 1.6.2 (Dec 18, 2020)
- More efficient bounding box calculation (thanks to Troy Tamas for the contribution).
- Fix Label creation bug.
Version 1.6.1 (Oct 22, 2020)
- Fix SVG output when
Labelcontains special characters.
Version 1.6 (Aug 12, 2020)
- Added support for element properties.
- Added transformation support to
Cell.copy. - Layer/datatype filtering in
get_polygonsforCell,CellReferenceandCellArray. - Layer/datatype filtering in
LayoutViewer. - Removed global cache
_bounding_boxes. Only cells cache their bounding boxes. - Bug fixes (thanks Daniel Hwang for the contributions).
- Bug fix in
Cell.copywhere the whole dependency tree would be copied on a deep copy creation.
Version 1.5.2 (Feb 01, 2020)
- Added support for importing GDSII files containing BOX elements.
- Bug fix in
GdsLibrary.extract(thanks collineps for finding the problem).
Version 1.5 (Dec 20, 2019)
- New
Cell.write_svgfunction to export an SVG image of the cell. - New
GdsLibrary.new_cellfunction to quickly create and add cells to a library. GdsLibrary.addcan update references when a cell is overwritten.- Added
GdsLibrary.removeto allow cells to be properly removed from libraries. - Added
GdsLibrary.rename_cellto rename cells in libraries. - Added
GdsLibrary.replace_referencesto easily replace referenced cells in libraries. GdsLibrary.addcan add dependencies recursively.- Iterating over
GdsLibraryobjects yields all its cells. - Iterating over
Cellobjects yield all its polygons, paths, labels and references. - Breaking change to
*.to_gdsfunctions in order to improve write efficiency (this should not be a problem for most users, sincegdspy.write_gdsandCell.write_gdsremain the same). - Breaking change: renamed
GdsLibrary.cell_dicttoGdsLibrary.cells. - Deprecated:
gdspy.current_library,gdspy.write_gds,gdspy.fast_boolen,GdsLibrary.extract. - Bug fixes and better tests for
FlexPathandRobustPath.
Version 1.4.3 (Nov 11, 2019)
- Bug fix for
FlexPathandRobustPathreferences.
Version 1.4.2 (Oct 01, 2019)
- Bug fix in
FlexPath.
Version 1.4.1 (Sep 20, 2019)
- Bug fixes (thanks to DerekK88 and Sequencer for the patches).
Version 1.4 (May 18, 2019)
- Revised documentation.
- New
FlexPathandRobustPathclasses: more efficient path generation when using the original GDSII path specification. - New
Curveclass: SVG-like polygon creation. - Added
PolygonSet.mirror(thanks to Daan Waardenburg for the contribution). - Added
Path.bezierto create paths based on Bézier curves. - Added
Path.smoothto create paths based on smooth interpolating curves. - Added
get_gds_unitsto get units used in a GDSII file without loading. - Added
get_binary_cellsto load only the binary GDSII representation of cell from a file. - Added argument
tolerancetoRound,Path.arc,Path.turn, andPath.parametricto automatically control the number of points in the final polygons. - Added argument
binary_cellsto GDSII writing functions to supportget_binary_cells. - Added argument
rename_templatetoGdsLibrary.read_gdsfor flexible cell renaming (thanks to @yoshi74ls181 for the contribution). - Changed return value of
sliceto avoid creating emptyPolygonSet. - Added argument
timestampto GDSII writing functions. - Improved
Roundto support creating ellipses. - Added support for unlimited number of points per polygon.
- Added support for BGNEXTN and ENDEXTN when reading a GDSII file.
- Polygon creation warnings are now controlled by
poly_warnings. - Incorrect
anchorinLabelnow raises an error, instead of emitting a warning. - Added correct support for radius in
PolygonSet.filleton a per-vertex basis. - Speed improvements in GDSII file generation (thanks to @fbeutel for the contribution) and geometry creation.
- Font rendering example using matplotlib (thanks Hernan Pastoriza for the contribution).
- Expanded test suite.
Version 1.3.2 (Mar 14, 2019)
- Small fix for building on Mac OS X Mojave.
Version 1.3.1 (Jun 29, 2018)
PolygonSetbecomes the base class for all polygons, in particularPolygonandRectangle.- Added
Cell.remove_polygonsandCell.remove_labelsfunctions to allow filtering a cell contents based, for example, on each element's layer. - Added
PolygonSet.scaleutility method. - Added
PolygonSet.get_bounding_boxutility method. - Added argument
timestamptoCell.to_gds,GdsLibrary.write_gdsandGdsWriter. - Added
unitandprecisionarguments toGdsLibraryinitialization and removed from itswrite_gdsmethod. - Changed the meaning of argument
unitinGdsLibrary.read_gds. - Improved
sliceto avoid errors when slicing in multiple positions at once. - Improved
PolygonSet.fractureto reduce number of function calls. - Removed incorrect absolute flags for magnification and rotation in
CellReferenceandCellArray. - Minor bug fixes.
- Documentation fixes.
- Removed deprecated classes and functions.
Version 1.2.1 (Dec 5, 2017)
GdsLibrarycan be created directly from a GDSII
