KiCAD library for Python¶
This package provides support to generate and manipulate schematic symbols and layout footprints for KiCAD.
Note
Most of the documentation here is directly stolen from the KiCAD fileformat documetation.
This documentation is a work in progress. Feedback and revisions are most welcome!
KiCAD is an opensource EDA program.
Easiest way to install is to use pip:
$ pip install canopen
KiCAD symbols¶
Symbol types¶
Examples¶
Types used in symbol classes.
API¶
Specific¶
KiCAD symbol types.
-
class
pykicadlib.symbol.types.
Direction
¶ Pin direction (flipped in opposition to KiCAD documentation).
-
down
= 'U'¶ Down
-
left
= 'R'¶ Left
-
right
= 'L'¶ Right
-
up
= 'D'¶ Up
-
-
class
pykicadlib.symbol.types.
Electric
¶ Electric pin type.
-
bidirectional
= 'B'¶ Bidirectional
-
input
= 'I'¶ Input
-
not_connected
= 'N'¶ Not connected
-
open_collector
= 'C'¶ Open collector
-
open_emitter
= 'E'¶ Open emitter
-
output
= 'O'¶ Output
-
passive
= 'P'¶ Passive
-
power_input
= 'W'¶ Power input
-
power_output
= 'w'¶ Power output
-
tristate
= 'T'¶ Tristate
-
unspecified
= 'U'¶ Unspecified
-
-
class
pykicadlib.symbol.types.
Field
¶ Symbol field type.
-
document
= 3¶ Document field
-
footprint
= 2¶ Footprint field
-
manufacturer
= 4¶ Manufacturer field
-
model
= 8¶ Model field
-
name
= 1¶ Name field
-
power
= 10¶ Power field
-
reference
= 0¶ Reference field
-
temperature
= 7¶ Temperature range field
-
tolerance
= 6¶ Tolerance field
-
value
= 5¶ Value field
-
voltage
= 9¶ Voltage field
-
-
class
pykicadlib.symbol.types.
Fill
¶ Element fill.
-
background
= 'f'¶ Background
-
foreground
= 'F'¶ Foreground
-
none
= 'N'¶ None
-
-
class
pykicadlib.symbol.types.
Flag
¶ Flag normal or power symbol.
-
normal
= 'N'¶ Normal symbol
-
power
= 'P'¶ Power symbol
-
-
class
pykicadlib.symbol.types.
HJustify
¶ Field horizontal justify.
-
center
= 'C'¶ Center
-
left
= 'L'¶ Left
-
right
= 'R'¶ Right
-
-
class
pykicadlib.symbol.types.
Italic
¶ Text element italic.
-
off
= 'Normal'¶ Normal
-
on
= 'Italic'¶ Italic
-
-
class
pykicadlib.symbol.types.
Orientation
¶ Field orientation.
-
horizontal
= 'H'¶ Horizontal orientation
-
vertical
= 'V'¶ Vertical orientation
-
-
class
pykicadlib.symbol.types.
Representation
Symbol representation.
-
both
= 0¶ Both
-
morgan
= 2¶ Morgan
-
normal
= 1¶ Normal
-
-
class
pykicadlib.symbol.types.
Shape
¶ Pin shape.
Note: Add ‘N’ before characters, to create an invisible pin.
-
clock
= 'C'¶ Clock
-
clock_low
= 'CL'¶ Clock low
-
falling_edge_clock
= 'F'¶ Falling-edge clock
-
input_low
= 'L'¶ Input low
-
inverted
= 'I'¶ Inverted
-
inverted_clock
= 'CI'¶ Inverted clock
-
invisible
= 'N'¶ Invisible
-
line
= ''¶ Line
-
non_logic
= 'X'¶ Non logic
-
output_low
= 'V'¶ Output low
-
-
class
pykicadlib.symbol.types.
Style
¶ Field style.
-
bold
= 'NB'¶ Bold
-
italic
= 'IN'¶ Italic
-
italic_bold
= 'IB'¶ Italic and Bold
-
none
= 'NN'¶ None
-
-
class
pykicadlib.symbol.types.
Units
¶ Symbol units swappable or locked.
-
locked
= 'L'¶ Locked
-
swappable
= 'F'¶ Swappable
-
-
class
pykicadlib.symbol.types.
Visibility
¶ Field visibility.
-
invisible
= 'I'¶ Invisible
-
visible
= 'V'¶ Visible
-
Symbol elements¶
Symbols consist of multiple elements. These are well known elements like lines, circles and arcs. Additionally elements are added, the help construct symbols out of element primitives.
Examples¶
Here is a simple example:
>>> element = pykicadlib.symbol.elements.Rectangle(10, 10, 20, 20, 5, pykicadlib.symbol.types.Fill.none)
>>> print(element)
S 10 10 20 20 0 1 5 N
API¶
Alias¶
Field¶
-
class
pykicadlib.symbol.elements.
Field
(type_, x, y, value)¶ Component field.
Parameters: - type (types.Field) – Type of
Field
- value (str) – Value of
Field
text - x (int) – X coordinate
- y (int) – Y coordinate
- size (int) – Text size
- orientation (Orientation) – Text orientation
- visibility (Visibility) – Text visibility
- hjustify (HJustify) – Horizontal text justify
- vjustify (VJustify) – Vertical text justify
- style (Style) – Text style
-
x
= None¶ X coordinate
-
y
= None¶ Y coordinate
-
size
= None¶ Text size
-
orientation
= None¶ Text orientation
-
visibility
= None¶ Text visibility
-
hjustify
= None¶ Horizontal text justify
-
vjustify
= None¶ Vertical text justify
-
style
= None¶ Text style
-
class
HJustify
¶ Field horizontal justify.
-
class
Orientation
¶ Field orientation.
-
class
Style
¶ Field style.
-
Type
¶ alias of
pykicadlib.symbol.types.Field
-
class
VJustify
¶ Field vertical justify.
-
class
Visibility
¶ Field visibility.
- type (types.Field) – Type of
Graphics¶
-
class
pykicadlib.symbol.elements.
Arc
(x, y, radius, start_x, start_y, end_x, end_y, start_angle, end_angle)¶ Arc with center at
x
/y
andradius
.Parameters: - x (int) – X coordinate
- y (int) – Y coordinate
- start_x (int) – Start X coordinate
- start_y (int) – Start Y coordinate
- end_x (int) – End X coordinate
- end_y (int) – End Y coordinate
- start_angle (int) – Start angle (?..?)
- end_angle (int) – End angle (?..?)
- radius (int) – Arc radius
- thickness (int) – Thickness of outline
- fill (Fill) – Fill type
- unit (int) – Unit index
- representation (Representation) – Representation type
-
x
= None¶ X coordinate
-
y
= None¶ Y coordinate
-
radius
= None¶ Arc radius
-
start_x
= None¶ Start X coordinate
-
start_y
= None¶ Start Y coordinate
-
end_x
= None¶ End X coordinate
-
end_y
= None¶ End Y coordinate
-
start_angle
= None¶ Start angle
-
end_angle
= None¶ End angle
-
thickness
= None¶ Thickness of outline
-
fill
= None¶ Fill type
-
class
Boundary
(x1, y1, x2, y2)¶ Element/symbol boundary class.
Parameters: - x1 (int) – X1 coordinate
- y1 (int) – Y1 coordinate
- x2 (int) – X2 coordinate
- y2 (int) – Y2 coordinate
-
class
Fill
¶ Element fill.
-
class
Representation
¶ Symbol representation.
-
priority
¶ Element priority.
Type: int
-
class
pykicadlib.symbol.elements.
Circle
(x, y, radius)¶ Circle with center at
x
/y
andradius
.Parameters: - x (int) – X coordinate
- y (int) – Y coordinate
- radius (int) – Circle radius
- thickness (int) – Thickness of outline
- fill (Fill) – Fill type
- unit (int) – Unit index
- representation (Representation) – Representation type
-
x
= None¶ X coordinate
-
y
= None¶ Y coordinate
-
radius
= None¶ Circle radius
-
thickness
= None¶ Thickness of outline
-
fill
= None¶ Fill type
-
class
Boundary
(x1, y1, x2, y2)¶ Element/symbol boundary class.
Parameters: - x1 (int) – X1 coordinate
- y1 (int) – Y1 coordinate
- x2 (int) – X2 coordinate
- y2 (int) – Y2 coordinate
-
class
Fill
¶ Element fill.
-
class
Representation
¶ Symbol representation.
-
priority
¶ Element priority.
Type: int
-
class
pykicadlib.symbol.elements.
Pin
(x, y, name, number)¶ Pin at
x
/y
withname
/number
.Parameters: - x (int) – X coordinate
- y (int) – Y coordinate
- name (str) – Pin name
- number (str) – Pin number
- length (int) – Pin length
- direction (Direction) – Pin direction
- name_size (int) – Pin name size
- number_size (int) – Pin number size
- electric (Electric) – Electric type
- shape (Shape) – Shape type
- visible (bool) – Visibility
- unit (int) – Unit index
- representation (Representation) – Representation type
-
x
= None¶ X coordinate
-
y
= None¶ Y coordinate
-
name
= None¶ Pin name
-
number
= None¶ Pin number
-
length
= None¶ Pin length
-
direction
= None¶ Pin direction
-
name_size
= None¶ Pin name size
-
number_size
= None¶ Pin number size
-
electric
= None¶ Electric type
-
shape
= None¶ Shape type
-
visible
= None¶ Visibility
-
priority
¶ Element priority.
Type: int
-
class
Boundary
(x1, y1, x2, y2)¶ Element/symbol boundary class.
Parameters: - x1 (int) – X1 coordinate
- y1 (int) – Y1 coordinate
- x2 (int) – X2 coordinate
- y2 (int) – Y2 coordinate
-
class
Direction
¶ Pin direction (flipped in opposition to KiCAD documentation).
-
class
Electric
¶ Electric pin type.
-
class
Fill
¶ Element fill.
-
class
Representation
¶ Symbol representation.
-
class
Shape
¶ Pin shape.
Note: Add ‘N’ before characters, to create an invisible pin.
-
class
pykicadlib.symbol.elements.
Polygon
¶ Polygon.
Parameters: - thickness (int) – Thickness of outline
- fill (Fill) – Fill type
- unit (int) – Unit index
- representation (Representation) – Representation type
-
thickness
= None¶ Thickness of outline
-
fill
= None¶ Fill type
-
points
= None¶ Outline points
-
priority
¶ Element priority.
Type: int
-
remove
(index)¶ Remove element from polygon.
Parameters: index (int) – Index of point to remove
-
class
Boundary
(x1, y1, x2, y2)¶ Element/symbol boundary class.
Parameters: - x1 (int) – X1 coordinate
- y1 (int) – Y1 coordinate
- x2 (int) – X2 coordinate
- y2 (int) – Y2 coordinate
-
class
Fill
¶ Element fill.
-
class
Point
(x, y)¶ Point helper.
Parameters: - x (int) – X coordinate
- y (int) – Y coordinate
-
class
Representation
¶ Symbol representation.
-
class
pykicadlib.symbol.elements.
Rectangle
(x1, y1, x2, y2)¶ Rectangle from
x1
/y1
tox2
/y2
.Parameters: - x1 (int) – X1 coordinate
- y1 (int) – Y1 coordinate
- x2 (int) – X2 coordinate
- y2 (int) – Y2 coordinate
- thickness (int) – Thickness of outline
- fill (Fill) – Fill type
- unit (int) – Unit index
- representation (Representation) – Representation type
-
x1
= None¶ X1 coordinate
-
x2
= None¶ X2 coordinate
-
y1
= None¶ Y1 coordinate
-
y2
= None¶ Y2 coordinate
-
thickness
= None¶ Thickness of outline
-
class
Boundary
(x1, y1, x2, y2)¶ Element/symbol boundary class.
Parameters: - x1 (int) – X1 coordinate
- y1 (int) – Y1 coordinate
- x2 (int) – X2 coordinate
- y2 (int) – Y2 coordinate
-
class
Fill
¶ Element fill.
-
class
Representation
¶ Symbol representation.
-
fill
= None¶ Fill type
-
priority
¶ Element priority.
Type: int
-
class
pykicadlib.symbol.elements.
Text
(x, y, value, size)¶ Text at
x
/y
withvalue
,size
,angle
and multiple style options.New format since 2.4?
Parameters: - x (int) – X coordinate
- y (int) – Y coordinate
- value (str) – Text value
- size (int) – Text size
- angle (int) – Text angle
- italic (Italic) – Text italic style
- bold (Bold) – Text bold style
- hjustify (HJustify) – Horizontal text justify
- vjustify (VJustify) – Vertical text justify
- unit (int) – Unit index
- representation (Representation) – Representation type
-
x
= None¶ X coordinate
-
y
= None¶ Y coordinate
-
value
= None¶ Text value
-
size
= None¶ Text size
-
angle
= None¶ Text angle
-
italic
= None¶ Text italic style
-
bold
= None¶ Text bold style
-
hjustify
= None¶ Horizontal text justify
-
vjustify
= None¶ Vertical text justify
-
class
Bold
¶ Text element bold.
-
class
Boundary
(x1, y1, x2, y2)¶ Element/symbol boundary class.
Parameters: - x1 (int) – X1 coordinate
- y1 (int) – Y1 coordinate
- x2 (int) – X2 coordinate
- y2 (int) – Y2 coordinate
-
class
Fill
¶ Element fill.
-
class
HJustify
¶ Field horizontal justify.
-
class
Italic
¶ Text element italic.
-
class
Representation
¶ Symbol representation.
-
class
VJustify
¶ Field vertical justify.
-
priority
¶ Element priority.
Type: int