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

class pykicadlib.symbol.elements.Alias

Aliases

Field

class pykicadlib.symbol.elements.Field(type, value, x, y, size, orientation, visibility, hjustify, vjustify, style)

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
__str__()

Return Field in KiCAD format

type = None

Type of Field

value = None

Value of Field text

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

Graphics

class pykicadlib.symbol.elements.Arc(x, y, start_x, start_y, end_x, end_y, start_angle, end_angle, radius, thickness, fill, unit=0, representation=<Representation.normal: 1>)

Arc with center at x/y and radius.

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
__eq__(other)

Compare Arc instances

__str__()

Return Arc in KiCAD format

x = None

X coordinate

y = None

Y coordinate

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

radius = None

Arc radius

thickness = None

Thickness of outline

fill = None

Fill type

bounds

Element boundary.

Type:Boundary
priority

Element priority depending on order and unit.

Type:int
class pykicadlib.symbol.elements.Circle(x, y, radius, thickness, fill, unit=0, representation=<Representation.normal: 1>)

Circle with center at x/y and radius.

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
__eq__(other)

Compare Circle instances

__str__()

Return Circle in KiCAD format

x = None

X coordinate

y = None

Y coordinate

radius = None

Circle radius

thickness = None

Thickness of outline

fill = None

Fill type

bounds

Element boundary.

Type:Boundary
priority

Element priority depending on order and unit.

Type:int
class pykicadlib.symbol.elements.Pin(x, y, name, number, length, direction, name_size, number_size, electric=<Electric.input: 'I'>, shape=<Shape.line: ''>, visible=True, unit=0, representation=<Representation.normal: 1>)

Pin at x/y with name/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
__eq__(other)

Compare Pin instances

__str__()

Return Pin in KiCAD format

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 depending on order and unit.

Type:int
bounds

Element boundary.

Type:Boundary
class pykicadlib.symbol.elements.Polygon(thickness, fill, unit=0, representation=<Representation.normal: 1>)
Parameters:
  • thickness (int) – Thickness of outline
  • fill (Fill) – Fill type
  • unit (int) – Unit index
  • representation (Representation) – Representation type
__eq__(other)

Compare Polygon instances

__str__()

Return Polygon in KiCAD format

thickness = None

Thickness of outline

fill = None

Fill type

points = None

Outline points

priority

Element priority depending on order and unit.

Type:int
bounds

Element boundary.

Type:Boundary
add(point)

Add point to polygon

Parameters:point (Point) – Point to add
remove(index)

Remove element from polygon

Parameters:index (int) – Index of point to remove
class pykicadlib.symbol.elements.Rectangle(x1, y1, x2, y2, thickness, fill, unit=0, representation=<Representation.normal: 1>)

Rectangle from x1/y1 to x2/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
__eq__(other)

Compare Rectangle instances

__str__()

Return Rectangle in KiCAD format

x1 = None

X1 coordinate

x2 = None

X2 coordinate

y1 = None

Y1 coordinate

y2 = None

Y2 coordinate

thickness = None

Thickness of outline

fill = None

Fill type

bounds

Element boundary.

Type:Boundary
priority

Element priority depending on order and unit.

Type:int
class pykicadlib.symbol.elements.Text(x, y, value, size, angle, italic=<Italic.off: 'Normal'>, bold=<Bold.off: 0>, hjustify=<HJustify.center: 'C'>, vjustify=<VJustify.center: 'C'>, unit=0, representation=<Representation.normal: 1>)

Text at x/y with value, 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
__eq__(other)

Compare Text instances

__str__()

Return Text in KiCAD format

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

bounds

Element boundary.

Type:Boundary
priority

Element priority depending on order and unit.

Type:int

Helper

pykicadlib.symbol.elements.from_str(string)

Generate elements out of string statements. Used to load a KiCAD symbol file line by line.

>>> element = pykicadlib.symbol.elements.from_str("S 10 10 20 20 0 1 5 N")
>>> type(element)
<class 'pykicadlib.symbol.elements.Rectangle'>
>>> print(element)
S 10 10 20 20 0 1 5 N
Parameters:string (str) – KiCAD symbol line to parse.
Returns:Element object depending on input string.
Return type:symbol.elements.Arc, symbol.elements.Circle, symbol.elements.Field, symbol.elements.Pin, symbol.elements.Polygon, symbol.elements.Rectangle, symbol.elements.Text
Raises:KeyError, ValueError
class pykicadlib.symbol.elements.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
__add__(other)

Merge boundary from other object with own boundary.

Parameters:other (Boundary) – Object to merge with
Returns:Boundary of both merged objects
Return type:Boundary
x1 = None

X1 coordinate

y1 = None

Y1 coordinate

x2 = None

X2 coordinate

y2 = None

Y2 coordinate

class pykicadlib.symbol.elements.Point(x, y)

Point helper

Parameters:
  • x (int) – X coordinate
  • y (int) – Y coordinate
Attributes:
  • x (int) - X cord
__eq__(other)

Compare Point instances

Returns:True, if other == Point and all attributes match. Otherwise False.
__str__()

Return Point in KiCAD format

x = None

X coordinate

y = None

Y coordinate