kigadgets.board

Classes

Board

Module Contents

class kigadgets.board.Board(wrap=None)

Bases: object

property native_obj
static wrap(instance)

Wraps a C++/old api BOARD object, and returns a Board.

add(obj)

Adds an object to the Board.

Tracks, Drawings, Modules, etc…

property footprints

Provides a list of the board Footprint objects.

footprint_by_ref(ref)

Returns the footprint that has the reference ref. Returns None if there is no such footprint.

property modules

Alias footprint to module

module_by_ref(ref)

Alias footprint to module

property vias

A list of via objects

property tracks

A list of track objects

property rule_areas

A list of both zone and keepout objects

property zones
property keepouts
property drawings

List of drawings, including all shapes and text

property items

Everything on the board

static from_editor()

Provides the board object from the editor.

static load(filename)

Loads a board file.

save(filename=None)

Save the board to a file. The filename should have .kicad_pcb extention, but it is not enforced. If filename=None, the board’s GetFileName value is used.

copy()
property filename

Name of the board file.

geohash()

Geometric hash

add_footprint(ref, pos=(0, 0))

Create new module on the board

add_module(ref, pos=(0, 0))

Same as add_footprint

property default_width
add_track_segment(start, end, layer='F.Cu', width=None)

Create a track segment.

get_layer_id(name)
get_layer_name(layer_id)
add_track(coords, layer='F.Cu', width=None)

Create a track polyline.

Create track segments from each coordinate to the next.

property default_via_size
property default_via_drill
add_via(coord, size=None, drill=None, layer_pair=None)

Create a via on the board.

Parameters:
  • coord – Position of the via.

  • layer_pair – Tuple of the connected layers (for example (‘B.Cu’, ‘F.Cu’)).

  • size – size of via in mm, or None for current selection.

  • drill – size of drill in mm, or None for current selection.

Returns:

the created Via

add_line(start, end, layer='F.SilkS', width=0.15)

Create a graphic line on the board

add_polyline(coords, layer='F.SilkS', width=0.15)

Create a graphic polyline on the board

add_circle(center, radius, layer='F.SilkS', width=0.15)

Create a graphic circle on the board

add_arc(center, radius, start_angle, stop_angle, layer='F.SilkS', width=0.15)

Create a graphic arc on the board

add_text(position, text, layer='F.SilkS', size=1.0, thickness=0.15, mirrored=False)
remove(element, permanent=False)

Makes it so Ctrl-Z works. Keeps a reference to the element in the python pcb object, so it persists for the life of that object

restore_removed()
deselect_all()
property selected_items

This useful for duck typing in the interactive terminal Suppose you want to set some drill radii. Iterating everything would cause attribute errors, so it is easier to just select the vias you want, then use this method for convenience.

To get one item that you selected, use

>>> xx = pcb.selected_items[0]
fill_zones()

fills all zones in this board