Export
The ExportOperations module handles generating manufacturing outputs.
board = kicad.get_board()
export = board.export
Gerber Files
gerbers(output_dir, ...)
Generates Gerber files for all layers.
board.export.gerbers("/path/to/output/")
gerbers_with_options(output_dir, **options)
Generates Gerbers with custom options.
board.export.gerbers_with_options(
"/path/to/output/",
format="gerber_x2", # or "gerber_rs274x"
use_protel_extensions=True,
include_edge_cuts=True,
include_netlist=True,
plot_references=True,
plot_values=True,
plot_footprint_mode="plot" # or "none", "sketch"
)
Drill Files
drill(output_dir, ...)
Generates drill files.
board.export.drill("/path/to/output/")
drill_with_options(output_dir, **options)
Generates drill files with custom options.
board.export.drill_with_options(
"/path/to/output/",
format="excellon", # or "gerber_x2"
units="mm", # or "inches"
zeros="decimal", # or "leading", "trailing"
merge_pth_npth=False, # Separate plated/non-plated
minimal_header=False
)
Position File (Pick and Place)
position(output_path, ...)
Generates component position file.
board.export.position("/path/to/output/positions.csv")
position_with_options(output_path, **options)
Generates position file with options.
board.export.position_with_options(
"/path/to/output/positions.csv",
format="csv", # or "gerber", "ascii"
units="mm",
side="both", # or "front", "back"
exclude_through_hole=False,
exclude_smd=False
)
BOM (Bill of Materials)
bom(output_path, ...)
Generates bill of materials.
board.export.bom("/path/to/output/bom.csv")
bom_with_options(output_path, **options)
Generates BOM with options.
board.export.bom_with_options(
"/path/to/output/bom.csv",
format="csv",
group_by="value", # or "footprint"
include_dnp=False,
sort_by="reference"
)
3D Model
step(output_path)
Exports 3D STEP model.
board.export.step("/path/to/output/board.step")
step_with_options(output_path, **options)
Exports STEP with options.
board.export.step_with_options(
"/path/to/output/board.step",
include_tracks=True,
include_zones=True,
include_silkscreen=True,
substitute_models=True
)
DRC Report
drc_report(output_path)
Generates DRC report.
board.export.drc_report("/path/to/output/drc.txt")
PDF/SVG
pdf(output_path, layers)
Exports layers as PDF.
from kipy.board import BoardLayer
board.export.pdf(
"/path/to/output/board.pdf",
layers=[BoardLayer.BL_F_Cu, BoardLayer.BL_F_SilkS]
)
svg(output_path, layers)
Exports layers as SVG.
board.export.svg(
"/path/to/output/board.svg",
layers=[BoardLayer.BL_F_Cu]
)
Example: Full Manufacturing Export
from kipy import KiCad
import os
kicad = KiCad()
board = kicad.get_board()
# Create output directory
output_dir = "/path/to/fab_output"
os.makedirs(output_dir, exist_ok=True)
# Generate Gerbers
board.export.gerbers_with_options(
output_dir,
format="gerber_x2",
use_protel_extensions=True
)
print("Gerbers generated")
# Generate drill files
board.export.drill_with_options(
output_dir,
format="excellon",
units="mm",
merge_pth_npth=False
)
print("Drill files generated")
# Generate position file
board.export.position_with_options(
os.path.join(output_dir, "positions.csv"),
format="csv",
units="mm"
)
print("Position file generated")
# Generate BOM
board.export.bom_with_options(
os.path.join(output_dir, "bom.csv"),
format="csv",
group_by="value"
)
print("BOM generated")
# Generate 3D model
board.export.step(os.path.join(output_dir, "board.step"))
print("3D model generated")
print(f"\nManufacturing files exported to: {output_dir}")
Example: Generate Review PDFs
from kipy.board import BoardLayer
# Front side review
board.export.pdf(
"/path/to/review_front.pdf",
layers=[
BoardLayer.BL_F_Cu,
BoardLayer.BL_F_SilkS,
BoardLayer.BL_Edge_Cuts
]
)
# Back side review
board.export.pdf(
"/path/to/review_back.pdf",
layers=[
BoardLayer.BL_B_Cu,
BoardLayer.BL_B_SilkS,
BoardLayer.BL_Edge_Cuts
]
)
# Assembly drawing
board.export.pdf(
"/path/to/assembly.pdf",
layers=[
BoardLayer.BL_F_Fab,
BoardLayer.BL_F_CrtYd,
BoardLayer.BL_Edge_Cuts
]
)
File Extensions
Standard Gerber file extensions:
| Layer | Extension |
|---|---|
| Front Copper | .gtl or F_Cu.gbr |
| Back Copper | .gbl or B_Cu.gbr |
| Front Mask | .gts or F_Mask.gbr |
| Back Mask | .gbs or B_Mask.gbr |
| Front Silk | .gto or F_SilkS.gbr |
| Back Silk | .gbo or B_SilkS.gbr |
| Edge Cuts | .gm1 or Edge_Cuts.gbr |
| Drill | .drl or .xln |