GDSII Tool Kit (gdstk)

1.0.0 · active · verified Thu Apr 16

gdstk is a C++/Python library designed for the creation and manipulation of GDSII and OASIS files, commonly used in microelectronics design. It serves as a modern successor to the Gdspy library, offering key features such as Boolean operations, polygon offsetting, and efficient point-in-polygon queries. The current version is 1.0.0, with an irregular release cadence, focusing on robust geometric operations for CAD layouts. [1, 3, 7]

Common errors

Warnings

Install

Imports

Quickstart

This quickstart creates a simple GDSII file named 'first.gds' containing a library with a single cell named 'FIRST'. This cell contains a rectangle on layer 1 and a triangle (polygon) on layer 2. It demonstrates the basic steps of creating a library, adding a cell, adding geometric shapes, and writing the output to a GDSII file. [6, 9]

import gdstk

# Create a new library
lib = gdstk.Library()

# Create a new cell and add it to the library
cell = lib.new_cell('FIRST')

# Create a rectangle and add it to the cell
rectangle = gdstk.rectangle((0, 0), (2, 2), layer=1, datatype=0)
cell.add(rectangle)

# Create a polygon from vertices and add it to the cell
polygon_points = [(3, 0), (5, 2), (5, 0)]
polygon = gdstk.Polygon(polygon_points, layer=2)
cell.add(polygon)

# Save the library to a GDSII file
lib.write_gds('first.gds')

print("Generated first.gds with a rectangle and a polygon.")

view raw JSON →