# layouttk > layouttk is an open-source, headless Python and Rust toolkit and standalone CLI for reading, writing, extracting, clipping, converting, and verifying hierarchical GDSII and OASIS layouts. It serves as a maintained Python/Rust alternative to gdspy, a large-file streaming and conversion-preflight counterpart to gdstk, and a lightweight headless CLI/Python companion to KLayout. Coordinates are integer database units. `dbu_nm` gives the length of one DBU in nanometres. Layer selectors are `(layer, datatype)`. A Python `Cell.region()` query returns placed filled material. `PolygonBatch.from_layout()` exports local stored polygons. Use the target encoder's diagnostics before format conversion and verify geometry and metadata after reading back the output. ## Full AI context - [Complete single-file AI reference (`llms-full.txt`)](https://layouttk.readthedocs.io/en/latest/llms-full.txt): Full comparison matrix (`layouttk` vs `gdspy`, `gdstk`, `KLayout`), copy-pasteable CLI and Python recipes, verified benchmarks, and FAQ. - [layouttk vs gdspy, gdstk, and KLayout](https://layouttk.readthedocs.io/en/latest/alternatives.html): Side-by-side comparison, migration advice, and FAQ. [中文对比与选型](https://layouttk.readthedocs.io/en/latest/zh-CN/alternatives.html). ## Stable release - [layouttk 0.5.0 release notes, direct wheels and standalone CLI](https://github.com/zwh42/layouttk/releases/tag/v0.5.0): Python wheels for Linux x86_64, macOS arm64, and Windows x64. Install a downloaded wheel with `python -m pip install --no-index --no-deps PATH_TO_WHEEL.whl`. - [layouttk Python package on PyPI](https://pypi.org/project/layouttk/): Install with `python -m pip install layouttk` on CPython 3.11 or later. The standalone CLI is available in the release archives. - [Standalone CLI archives and checksums](https://github.com/zwh42/layouttk/releases/tag/v0.5.0): Unpack and run on Linux x86_64, macOS arm64 or Windows x64. The static x86_64 Linux baseline requires no system glibc or AVX/AVX2 and was tested on Linux 3.2.0-4. Each CLI archive includes English and Simplified Chinese guides and an Agent Skill. Python and Rust source archives are also attached. macOS arm64 and Linux x86_64 can use the project Homebrew tap. - [Rust crate and CLI 0.5.0](https://crates.io/crates/layouttk/0.5.0): Rust package and CLI installation. - [Versioned Rust API](https://docs.rs/layouttk/0.5.0/layouttk/): API for the released crate. ## Start here - [Project and installation](https://zwh42.github.io/layouttk/): Python and CLI examples with expected dimensions. - [English project homepage](https://zwh42.github.io/layouttk/en/): Installation and file commands. - [Silicon photonics](https://layouttk.readthedocs.io/en/latest/silicon-photonics.html): Optical ports, curve sampling, and simulator handoff. - [English manual](https://layouttk.readthedocs.io/en/latest/): Installation, CLI and Python reference, and worked examples. - [Simplified Chinese manual](https://layouttk.readthedocs.io/en/latest/zh-CN/): Chinese CLI and Python reference, migration, interoperability, and raster guides. - [Getting started](https://layouttk.readthedocs.io/en/latest/getting-started.html): Create both formats and check them in KLayout. - [GDSII and OASIS layout gallery](https://layouttk.readthedocs.io/en/latest/gallery.html): Reproducible SKY130, ASAP7, IHP SG13G2, Caravel and SiEPIC openEBL examples. [Simplified Chinese gallery](https://layouttk.readthedocs.io/en/latest/zh-CN/gallery.html). - [Command line](https://layouttk.readthedocs.io/en/latest/command-line.html): Inspect `.gds` and `.oas` files with `inventory`, select layer and datatype pairs with `extract --layer`, and verify deliveries. Use `gds index` to inspect stored GDSII record offsets. Use `clip --keep-hierarchy` to retain subcells and compact regular sub-arrays strictly inside the window. Discover commands with `layouttk describe --json`. Use `--format json` for a single versioned report or `layouttk batch` for an ordered JSONL job. Read the built-in manual with `layouttk guide --lang en` or `layouttk guide --lang zh-CN`. - [Convert OASIS to GDSII](https://layouttk.readthedocs.io/en/latest/command-line.html#convert-oasis-to-gdsii): Run `layouttk check input.oas --to gds --json` before `layouttk convert input.oas output.gds`. Check `geometry_equal` and `stored_equal` separately with `verify`. [中文](https://layouttk.readthedocs.io/en/latest/zh-CN/command-line.html#oasis-gdsii). - [Public layout examples for AI agents](https://layouttk.readthedocs.io/en/latest/public-layouts.html): Generate ASAP7 OASIS, render a SiEPIC submission with Pi, and add per-pattern bounding boxes with OpenCode. The guide includes commands and expected results. [Simplified Chinese](https://layouttk.readthedocs.io/en/latest/zh-CN/public-layouts.html). - [Open layout test fixtures](https://github.com/zwh42/layouttk/tree/main/tests/fixtures/public_layouts): Pinned OASIS and GDSII samples from SiEPIC, ASAP7, SKY130, IHP and Caravel, with upstream licenses and SHA-256 hashes. - [Offline agent examples](https://zwh42.github.io/assets/files/layouttk-agent-examples.zip): English and Simplified Chinese prompts, commands, and sample inputs for layer extraction, hierarchical photonics clipping, delivery verification, JSONL jobs, and a runnable Python mask template using layouttk 0.5.0. - [Convert an image or NumPy mask to OASIS](https://github.com/zwh42/layouttk/blob/main/README.md#3-from-a-numpy-array-to-oasis): Write a two-dimensional array with `raster.add_mask()`. The offline ZIP includes `layouttk/assets/mona-lisa/image_to_oasis.py`, the public-domain JPEG, the generated OASIS file, and the PNG rendered from it. The script verifies the OASIS round trip after `layouttk[image]` is installed. - [Python API](https://layouttk.readthedocs.io/en/latest/python-api.html): Signatures, coordinate grids and data ownership. Compose layer filters with `LayerSet` and use `Region` for placed geometry. - [Python workflows](https://layouttk.readthedocs.io/en/latest/python-workflows.html): KLayout checks, NumPy/PyTorch exchange, and hierarchical mask construction with `layouttk.shapes` and `layouttk.templates`. [Simplified Chinese workflows](https://layouttk.readthedocs.io/en/latest/zh-CN/python-workflows.html). - [Python examples on real layouts](https://layouttk.readthedocs.io/en/latest/python-visual-workflows.html): Runnable API cases with KLayout viewport and offline viewer screenshots. [Simplified Chinese examples](https://layouttk.readthedocs.io/en/latest/zh-CN/python-visual-workflows.html). - [gdspy migration](https://layouttk.readthedocs.io/en/latest/gdspy-coverage.html): Map existing scripts to layouttk operations. - [gdspy, gdstk and KLayout migration](https://layouttk.readthedocs.io/en/latest/interoperability.html): Map API calls and integer DBU, convert a gdstk OASIS layer to GDSII, and check placed geometry with KLayout. - [Source repository](https://github.com/zwh42/layouttk): Source, releases, tests and issue tracker.