Skip to main content

kicad-pycbnew is a Python module for creating printed circuit boards designs compatible with KiCad's pcbnew,

Project description

kicad-pycbnew - Python Library for KiCad PCB Creation from Scratch

kicad-pycbnew is a Python library that provides a programmatic interface for creating and manipulating KiCad PCB designs. kicad-pycbnew works without requiring KiCad to be installed. It allows you to generate complex PCB layouts using Python code, making it easier to create parametric designs, automate repetitive tasks, and integrate PCB design into your Python workflows.

Features

  • Create KiCad PCB projects programmatically
  • Define, place and manipulate PCB elements:
    • Footprints and pads
    • Nets and logical connections between footprint pads
    • Traces and vias
    • Zones and keepout areas
    • Graphic elements (lines, text, polygons)
  • Geometric utilities for PCB design
  • Support for S-expressions (KiCad's file format)
  • Integration with KiCad CLI

Installation

pip install kicad-pycbnew

Project Structure

The library is organized into three main packages:

Primitives

Basic building blocks for KiCad PCB elements:

  • kicad.py: Base classes and utilities
  • project.py: Project management
  • footprint.py: Footprint and pad handling
  • layer.py: Layer definitions
  • net.py: Net management
  • segment.py: Track segments and arcs
  • via.py: Via definitions
  • zone.py: Copper zones
  • gr_elements.py: Graphic elements (text, lines, arcs, rectangles)
  • sexpressions.py: some convenient S-expression utilities

Composites

Higher-level constructs built from primitives:

  • abstract_path.py: Base path class
  • gr_line_path.py: Paths with graphic lines and arcs
  • segment_path.py: Paths with track segments and arcs

Utils

Utility functions and geometric classes:

  • geometry.py: Point, Vector, Arc, Rectangle, Polygon classes
  • bernstein.py: Bernstein polynomial functions

Usage Example

from pycbnew.primitives.project import KProject
from pycbnew.primitives.footprint import KFootprint
from pycbnew.primitives.net import KNet
from pycbnew.utils.geometry import Point

# Create a new KiCadObject project
project = KProject(filename="my_project.kicad_pcb", copper_layers=2)

# Create a net
gnd_net = KNet(1, "GND")
project.add(gnd_net)

# Add a footprint
footprint = KFootprint("Resistor_SMD:R_0805_2012Metric",
                       at=Point(100, 100),
                       side=KFootprint.Side.Front,
                       default_net=gnd_net)
project.add(footprint)

# Save the project
project.save()

Advanced usage

See the examples directory.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kicad_pycbnew-0.1.0.post1.tar.gz (42.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kicad_pycbnew-0.1.0.post1-py3-none-any.whl (48.8 kB view details)

Uploaded Python 3

File details

Details for the file kicad_pycbnew-0.1.0.post1.tar.gz.

File metadata

  • Download URL: kicad_pycbnew-0.1.0.post1.tar.gz
  • Upload date:
  • Size: 42.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for kicad_pycbnew-0.1.0.post1.tar.gz
Algorithm Hash digest
SHA256 a62b07bda1ddd7368c8f90ae4afba21d9ce27545a65b2f1693a0e5cd4b8b7471
MD5 19b4bc91652d520505d44dad340c5f48
BLAKE2b-256 1124b97f54ba6475f3fce2e6d8fb854214de3933d1e0b938216623d511fc2765

See more details on using hashes here.

File details

Details for the file kicad_pycbnew-0.1.0.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for kicad_pycbnew-0.1.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 bbdad19080ceae53e32b7a648b9d6088918d668a12af3bb2c24419110b69e48d
MD5 38e61523e8e2ca11c78cd1fc3d6c13cc
BLAKE2b-256 0e19863450290236fe533b1e06e0822e5ffdfef3d42e7322b3f9d23360c549d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page