KFactory
KFactory is a Python layout framework built on KLayout. It is the backend for gdsfactory and can be used as a standalone photonic/electronic layout tool.
KFactory exposes KLayout's full geometry engine (boolean regions, Minkowski expansions, DRC) through a clean Python API while adding cell caching, enclosures, all-angle routing, and schematic-driven design.
-
Getting Started
Install kfactory and build your first component in under 5 minutes.
-
Core Concepts
Understand KCells, layers, ports, instances, and the DBU ↔ µm coordinate systems.
-
Routing
Optical and electrical bundle routing, Manhattan primitives, all-angle, and path-length matching.
-
Components
Straight waveguides, euler/circular bends, tapers, Bezier S-bends, and the factory pattern.
-
Enclosures
Layer enclosures via Minkowski sums, cross-sections, and KCell-level cladding.
-
Utilities
Grid layout, packing, DRC fixing, fill, and regression testing.
-
PDK
Bundle layers, factories, cross-sections, and technology into a reusable PDK.
-
Schematics
Schematic-driven layout, netlist extraction, LVS, and YAML/JSON round-trips.
-
How-To Guides
Common patterns, best practices, and a comprehensive FAQ.
Key Features
- Cell caching —
@kf.celldeduplicates identical components automatically - DBU + µm APIs —
KCell(integer DBU) andDKCell(float µm) work side by side - Enclosures — Minkowski-sum cladding and annular boolean layers, tile-parallelised
- Bundle routing — optical and electrical, all-angle, path-length matching, obstacle avoidance
- Cross-sections — registered per
KCLayout; composable with enclosures - Schematics — place-and-connect workflow with netlist extraction and LVS
- KLayout integration — full access to
kdb.Region,kdb.Polygon, DRC, and GDS/OASIS I/O - klive — live preview in KLayout while editing notebooks
Comparison with gdsfactory
See gdsfactory.md for a side-by-side feature comparison and migration notes.