Skip to content

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.

    Installation  ·  Quickstart

  • Core Concepts


    Understand KCells, layers, ports, instances, and the DBU ↔ µm coordinate systems.

    KCell  ·  Layers  ·  Ports

  • Routing


    Optical and electrical bundle routing, Manhattan primitives, all-angle, and path-length matching.

    Overview  ·  Optical  ·  All-Angle

  • Components


    Straight waveguides, euler/circular bends, tapers, Bezier S-bends, and the factory pattern.

    Overview  ·  PCells  ·  Factories

  • Enclosures


    Layer enclosures via Minkowski sums, cross-sections, and KCell-level cladding.

    Cross-Sections  ·  Layer Enclosure

  • Utilities


    Grid layout, packing, DRC fixing, fill, and regression testing.

    Grid  ·  DRC Fix  ·  Fill

  • PDK


    Bundle layers, factories, cross-sections, and technology into a reusable PDK.

    Creating a PDK  ·  Layer Stack

  • Schematics


    Schematic-driven layout, netlist extraction, LVS, and YAML/JSON round-trips.

    Overview  ·  Netlist & I/O

  • How-To Guides


    Common patterns, best practices, and a comprehensive FAQ.

    Best Practices  ·  FAQ


Key Features

  • Cell caching@kf.cell deduplicates identical components automatically
  • DBU + µm APIsKCell (integer DBU) and DKCell (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.