Common

class edea.kicad.common.StrokeType(value)

Bases: StrEnum

Available stroke types that can be used for lines, outlines, etc.

KiCad stroke definition

DEFAULT = 'default'

Stroke type.

DASH = 'dash'

Evenly spaced dashes.

DASH_DOT = 'dash_dot'

Alternating dashes and dots.

DASH_DOT_DOT = 'dash_dot_dot'

Alternating dashes and double dots.

DOT = 'dot'

Evenly spaced dots.

SOLID = 'solid'

Continuous solid.

class edea.kicad.common.Stroke(width: float = 0, type: StrokeType = 'default', color: Annotated[tuple[int, int, int, float], 'kicad_omits_default'] = (0, 0, 0, 0.0))

Bases: KicadExpr

Properties of a stroke used within KiCad expressions.

KiCad stroke definition

Parameters:
  • width – The line width of the graphic object.

  • type – The line style of the graphic object.

  • color – The red, green, blue, and alpha color settings.

width: float = 0
type: StrokeType = 'default'
color: Annotated[tuple[int, int, int, float], 'kicad_omits_default'] = (0, 0, 0, 0.0)
kicad_expr_tag_name: ClassVar[Literal['stroke']] = 'stroke'
classmethod from_list(exprs: list[str | QuotedStr | list[str | QuotedStr | SExprList]]) Self

Turns an s-expression list of arguments into an EDeA dataclass. Note that you omit the tag name in the s-expression so e.g. for (symbol “foo” (pin 1)) you would pass [“foo”, [“pin”, 1]] to this method.

Returns:

An instance of the ‘KicadExpr’ created from the KiCad expression data.

class edea.kicad.common.PaperFormat(value)

Bases: StrEnum

Various standard paper formats like A series A0, A1, B series, etc.

KiCad paper format

A0 = 'A0'
A1 = 'A1'
A2 = 'A2'
A3 = 'A3'
A4 = 'A4'
A5 = 'A5'
A = 'A'
B = 'B'
C = 'C'
D = 'D'
E = 'E'
US_LETTER = 'USLetter'
US_LEDGER = 'USLedger'
class edea.kicad.common.PaperOrientation(value)

Bases: StrEnum

The two common paper shown modes: landscape and portrait.

KiCad paper format

LANDSCAPE = ''

The default value (empty string), represents horizontal orientation.

PORTRAIT = 'portrait'

Represents vertical orientation.

class edea.kicad.common.PaperUser(format: Annotated[Literal['User'], 'kicad_no_kw', 'kicad_always_quotes'] = 'User', width: Annotated[float, 'kicad_no_kw'] = 0, height: Annotated[float, 'kicad_no_kw'] = 0)

Bases: KicadExpr

A custom KiCad paper size definition.

Parameters:
  • format – Always set to “User” to indicate a custom format.

  • width – The width of the paper in KiCad units.

  • height – The height of the paper in KiCad units

Variables:

kicad_expr_tag_name – The KiCad expression tag name for this element (“paper”).

format: Annotated[Literal['User'], 'kicad_no_kw', 'kicad_always_quotes'] = 'User'
width: Annotated[float, 'kicad_no_kw'] = 0
height: Annotated[float, 'kicad_no_kw'] = 0
kicad_expr_tag_name: ClassVar[Literal['paper']] = 'paper'
as_dimensions_mm() tuple[float, float]

Calculates the paper dimensions based on the user-defined width and height.

Returns:

A tuple containing the width and height of the paper.

class edea.kicad.common.PaperStandard(format: Annotated[PaperFormat, 'kicad_no_kw', 'kicad_always_quotes'] = 'A4', orientation: Annotated[PaperOrientation, 'kicad_no_kw', 'kicad_omits_default'] = '')

Bases: KicadExpr

A standard KiCad paper size.

KiCad paper format

Parameters:
  • format – The paper format from the PaperFormat enum.

  • orientation – The paper orientation from the PaperOrientation enum.

Variables:

kicad_expr_tag_name – The KiCad expression tag name for this element (“paper”).

format: Annotated[PaperFormat, 'kicad_no_kw', 'kicad_always_quotes'] = 'A4'
orientation: Annotated[PaperOrientation, 'kicad_no_kw', 'kicad_omits_default'] = ''
kicad_expr_tag_name: ClassVar[Literal['paper']] = 'paper'
as_dimensions_mm() tuple[float, float]

Calculates dimensions of the paper in millimeters based on the standard.

Returns:

A tuple containing the width and height of the paper.

class edea.kicad.common.PolygonArc(start: tuple[float, float], mid: tuple[float, float], end: tuple[float, float])

Bases: KicadExpr

A polygonal arc KiCad expression element.

KiCad arc

Parameters:
  • start – The starting X-Y coordinates of the arc.

  • mid – The midpoint X-Y coordinates of the arc.

  • end – The ending X-Y coordinates of the arc.

Variables:

kicad_expr_tag_name – The KiCad expression tag name for this element (“arc”).

start: tuple[float, float]
mid: tuple[float, float]
end: tuple[float, float]
kicad_expr_tag_name: ClassVar[Literal['arc']] = 'arc'
class edea.kicad.common.XY

Bases: KicadExpr

A 2D coordinate point.

KiCad coordinate point list

Parameters:
  • x – The X coordinate of the point.

  • y – The Y coordinate of the point.

x: Annotated[float, 'kicad_no_kw']
y: Annotated[float, 'kicad_no_kw']
kicad_expr_tag_name: ClassVar[Literal['xy']] = 'xy'
class edea.kicad.common.Pts

Bases: KicadExpr

A collection of points and arcs.

KiCad coordinate point list, KiCad arc

Parameters:
  • xys – A list of XY instances representing points.

  • arcs – A list of PolygonArc instances representing arcs.

xys: list[XY]
arcs: list[PolygonArc]
kicad_expr_tag_name: ClassVar[Literal['pts']] = 'pts'
classmethod from_list(exprs: list[str | QuotedStr | list[str | QuotedStr | SExprList]]) Self

Turns an s-expression list of arguments into an EDeA dataclass. Note that you omit the tag name in the s-expression so e.g. for (symbol “foo” (pin 1)) you would pass [“foo”, [“pin”, 1]] to this method.

Returns:

An instance of the ‘KicadExpr’ created from the KiCad expression data.

to_list() list[str | QuotedStr | list[str | QuotedStr | SExprList]]

Turns a a KicadExpr into an s-expression list. Note that the initial keyword is omitted in the return of this function. It can be retrieved by accessing .kicad_expr_tag_name.

Returns:

A list representing the KiCad expression data structure generated from the object.

class edea.kicad.common.Image(at: tuple[float, float], scale: float | None = None, uuid: ~uuid.UUID = <factory>, data: list[str] = <factory>)

Bases: KicadExpr

An embedded image in a KiCad expression.

KiCad image

Parameters:
  • at – The X-Y coordinates specifying the image placement.

  • scale – The scale factor of the image.

  • uuid – The unique identifier (UUID) for the image.

  • data – The image data in the portable network graphics format (PNG) encoded with MIME type base64.

at: tuple[float, float]
scale: float | None = None
uuid: UUID
data: list[str]
kicad_expr_tag_name: ClassVar[Literal['image']] = 'image'
class edea.kicad.common.TitleBlockComment(number: Annotated[int, 'kicad_no_kw'] = 1, text: Annotated[str, 'kicad_no_kw', 'kicad_always_quotes'] = '')

Bases: KicadExpr

A comment within a KiCad title block.

KiCad title block

Parameters:
  • number – A sequential comment number.

  • text – The comment text content.

Variables:

kicad_expr_tag_name – The KiCad expression tag name for this element (“comment”).

number: Annotated[int, 'kicad_no_kw'] = 1
text: Annotated[str, 'kicad_no_kw', 'kicad_always_quotes'] = ''
kicad_expr_tag_name: ClassVar[Literal['comment']] = 'comment'
class edea.kicad.common.TitleBlock(title: ~typing.Annotated[str, ('kicad_omits_default',)] = '', date: ~typing.Annotated[str, ('kicad_omits_default',)] = '', rev: ~typing.Annotated[str, ('kicad_omits_default',)] = '', company: ~typing.Annotated[str, ('kicad_omits_default',)] = '', comments: ~typing.Annotated[list[~edea.kicad.common.TitleBlockComment], ('kicad_omits_default',)] = <factory>)

Bases: KicadExpr

The contents of a KiCad title block.

KiCad title block

Parameters:
  • title – The title of the document.

  • date – The document date using the YYYY-MM-DD format.

  • rev – The revision number of the document.

  • company – The company name associated with the document.

  • comments – The document comments where N is a number from 1 to 9 and COMMENT is a quoted string.

title: Annotated[str, 'kicad_omits_default'] = ''
date: Annotated[str, 'kicad_omits_default'] = ''
rev: Annotated[str, 'kicad_omits_default'] = ''
company: Annotated[str, 'kicad_omits_default'] = ''
comments: Annotated[list[TitleBlockComment], 'kicad_omits_default']
kicad_expr_tag_name: ClassVar[Literal['title_block']] = 'title_block'
class edea.kicad.common.Font(face: str | None = None, size: tuple[float, float] = (1.27, 1.27), thickness: Annotated[float | None, 'kicad_omits_default'] = None, bold: Annotated[bool, 'kicad_kw_bool'] = False, italic: Annotated[bool, 'kicad_kw_bool'] = False, color: Annotated[tuple[int, int, int, float], 'kicad_omits_default'] = (0, 0, 0, 1.0))

Bases: KicadExpr

The font style for KiCad expressions.

KiCad text effects

Parameters:
  • face – The font face name. Defaults to None.

  • size – The font size (width, height) in KiCad units. Defaults to (1.27, 1.27).

  • thickness – The font thickness.

  • bold – Whether the font is bold or not.

  • italic – Whether the font is italic or not.

  • color – The font color as a 4-tuple of integers (R, G, B, A).

face: str | None = None
size: tuple[float, float] = (1.27, 1.27)
thickness: Annotated[float | None, 'kicad_omits_default'] = None
bold: Annotated[bool, 'kicad_kw_bool'] = False
italic: Annotated[bool, 'kicad_kw_bool'] = False
color: Annotated[tuple[int, int, int, float], 'kicad_omits_default'] = (0, 0, 0, 1.0)
kicad_expr_tag_name: ClassVar[Literal['font']] = 'font'
class edea.kicad.common.Effects(font: ~edea.kicad.common.Font = <factory>, justify: ~typing.Annotated[list[~typing.Literal['left', 'right', 'top', 'bottom', 'mirror']], ('kicad_omits_default',)] = <factory>, hide: ~typing.Annotated[bool, ('kicad_kw_bool',)] = False, href: ~typing.Annotated[str | None, ('kicad_always_quotes',)] = None)

Bases: KicadExpr

The text effects for KiCad expressions.

KiCad text effects

Parameters:
  • font – How the text is shown.

  • justify – Text justified horizontally right or left and/or vertically top or bottom and/or mirrored.

  • hide – Whether to hide the text element or not.

  • href – A hyperlink reference.

font: Font
justify: Annotated[list[Literal['left', 'right', 'top', 'bottom', 'mirror']], 'kicad_omits_default']
hide: Annotated[bool, 'kicad_kw_bool'] = False
href: Annotated[str | None, 'kicad_always_quotes'] = None
kicad_expr_tag_name: ClassVar[Literal['effects']] = 'effects'
exception edea.kicad.common.VersionError

Bases: ValueError

Source file was produced with an unsupported KiCad version.