kiutils.items package
Board items (kiutils.items.brditems)
Classes to manage KiCad board items
- Author:
Marvin Mager - @mvnmgrx - 2022
- License identifier:
GPL-3.0
- Major changes:
20.02.2022 - created
- Documentation taken from:
- class kiutils.items.brditems.GeneralSettings(thickness: float = 1.6)
Bases:
objectThe
generaltoken define general information about the board- thickness: float = 1.6
The
thicknesstoken attribute defines the overall board thickness
- classmethod from_sexpr(exp: list) GeneralSettings
Convert the given S-Expresstion into a GeneralSettings object
- Args:
exp (list): Part of parsed S-Expression
(general ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not general
- Returns:
GeneralSettings: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.brditems.LayerToken(ordinal: int = 0, name: str = 'F.Cu', type: str = 'signal', userName: str | None = None)
Bases:
objectIntermediate type used for the
layerstoken in a board- ordinal: int = 0
The layer
ordinalis an integer used to associate the layer stack ordering. This is mostly to ensure correct mapping when the number of layers is increased in the future
- name: str = 'F.Cu'
The
nameis the layer name defined for internal board use
- type: str = 'signal'
The layer
typedefines the type of layer and can be defined asjumper,mixed,power,signal, oruser.
- userName: str | None = None
The optional
userNameattribute defines the custom user name
- classmethod from_sexpr(exp: list) LayerToken
Convert the given S-Expresstion into a LayerToken object
- Args:
exp (list): Part of parsed S-Expression
(<nr> "<name>" <type>)
- Raises:
Exception: When given parameter’s type is not a list or the length of the list is not 3 - 4
Exception: When the first item of the list is not kicad_pcb
- Returns:
LayerToken: Object of the class initialized with the given S-Expression
- to_sexpr(indent=4, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 4.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.brditems.StackupSubLayer(thickness: float = 0.1, material: str | None = None, epsilonR: float | None = None, lossTangent: float | None = None)
Bases:
objectThe
StackupSubLayertoken defines a sublayer used when stacking dielectrics in a PCB- thickness: float = 0.1
The
thicknesstoken defines the thickness of the sublayer. Defaults to 0.1
- material: str | None = None
The optional
materialtoken defines a string that describes the sublayer material
- epsilonR: float | None = None
The optional
epsilonRtoken defines the dielectric constant of the sublayer material
- lossTangent: float | None = None
The optional layer
lossTangenttoken defines the dielectric loss tangent of the sublayer
- classmethod from_sexpr(exp: list) StackupSubLayer
This class cannot be derived from an S-Expression as the format currently used in KiCad board files does not match the usual convention. Assign member values manually when using this object.
- Raises:
NotImplementedError
- to_sexpr(indent=0, newline=False) str
Generate the S-Expression representing this object. The representation differs from the normal form of an S-Expression as this uses no opening and closing parenthesis.
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 0.
newline (bool): Adds a newline to the end of the output. Defaults to False.
- Returns:
str: S-Expression of this object
- class kiutils.items.brditems.StackupLayer(name: str = '', type: str = '', color: str | None = None, thickness: float | None = None, material: str | None = None, epsilonR: float | None = None, lossTangent: float | None = None, subLayers: ~typing.List[~kiutils.items.brditems.StackupSubLayer] = <factory>)
Bases:
objectThe
layertoken defines the stack up setting of a single layer in the board stack up settings.- name: str = ''
The
nameattribute is either one of the canonical copper or technical layer names ordielectric IDif it is dielectric layer
- type: str = ''
The
typetoken defines a string that describes the layer
- color: str | None = None
The optional
colortoken defines a string that describes the layer color. This is only used on solder mask and silkscreen layers
- thickness: float | None = None
The optional
thicknesstoken defines the thickness of the layer where appropriate
- material: str | None = None
The optional
materialtoken defines a string that describes the layer material where appropriate
- epsilonR: float | None = None
The optional
epsilonRtoken defines the dielectric constant of the layer material
- lossTangent: float | None = None
The optional layer
lossTangenttoken defines the dielectric loss tangent of the layer
- subLayers: List[StackupSubLayer]
The
sublayerstoken defines a list of zero or more sublayers that are used to create stacks of dielectric layers. Does not apply to copper-type layers.
- classmethod from_sexpr(exp: list) StackupLayer
Convert the given S-Expresstion into a StackupLayer object
- Args:
exp (list): Part of parsed S-Expression
(layer ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not layer
- Returns:
StackupLayer: Object of the class initialized with the given S-Expression
- to_sexpr(indent=6, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 6.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.brditems.Stackup(layers: ~typing.List[~kiutils.items.brditems.StackupLayer] = <factory>, copperFinish: str | None = None, dielectricContraints: str | None = None, edgeConnector: str | None = None, castellatedPads: bool = False, edgePlating: bool = False)
Bases:
objectThe
stackuptoken defines the board stack up settings and is defined in the setup section.- layers: List[StackupLayer]
The ``layers``token is a list of layer settings for each layer required to manufacture a board including the dielectric material between the actual layers defined in the board editor.
- copperFinish: str | None = None
The optional
copperFinishtoken is a string that defines the copper finish used to manufacture the board
- dielectricContraints: str | None = None
The optional
dielectricContraintstoken define if the board should meet all dielectric requirements. Valid values areyesandno.
- edgeConnector: str | None = None
The optional
edgeConnectortoken defines if the board has an edge connector (value:yes) and if the edge connector is bevelled (value:bevelled)
- castellatedPads: bool = False
The
castellatedPadstoken defines if the board edges contain castellated pads
- edgePlating: bool = False
The
edgePlatingtoken defines if the board edges should be plated.
- classmethod from_sexpr(exp: list) Stackup
Convert the given S-Expresstion into a Stackup object
- Args:
exp (list): Part of parsed S-Expression
(stackup ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not stackup
- Returns:
Stackup: Object of the class initialized with the given S-Expression
- to_sexpr(indent=4, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 4.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.brditems.PlotSettings(layerSelection: str = '', plotOnAllLayersSelection: str | None = None, disableApertMacros: bool = False, useGerberExtensions: bool = False, useGerberAttributes: bool = False, useGerberAdvancedAttributes: bool = False, createGerberJobFile: bool = False, dashedLineDashRatio: float | None = None, dashedLineGapRatio: float | None = None, svgUseInch: bool | None = None, svgPrecision: float = 0.0, excludeEdgeLayer: bool | None = None, plotFameRef: bool = False, viasOnMask: bool = False, mode: int = 1, useAuxOrigin: bool = False, hpglPenNumber: int = 0, hpglPenSpeed: int = 0, hpglPenDiameter: float = 0.0, dxfPolygonMode: bool = False, dxfImperialUnits: bool = False, dxfUsePcbnewFont: bool = False, psNegative: bool = False, psA4Output: bool = False, plotReference: bool = False, plotValue: bool = False, plotInvisibleText: bool = False, sketchPadsOnFab: bool = False, subtractMaskFromSilk: bool = False, outputFormat: int = 0, mirror: bool = False, drillShape: int = 0, scaleSelection: int = 1, outputDirectory: str = '')
Bases:
objectThe
pcbplotparamstoken defines the plotting and printing settings used for the last plot and is defined in the set up section.- layerSelection: str = ''
The
layerSelectiontoken defines a hexadecimal bit set of the layers to plot
- plotOnAllLayersSelection: str | None = None
The
plotOnAllLayersSelectiontoken defines a hexadecimal bit set of layers where all selected layers shall be plotted.Available and required since KiCad v7
- disableApertMacros: bool = False
The
disableApertMacrostoken defines if aperture macros are to be used in gerber plots
- useGerberExtensions: bool = False
The
useGerberExtensionstoken defines if the Protel layer file name extensions are to be used in gerber plots
- useGerberAttributes: bool = False
The
useGerberAttributestoken defines if the X2 extensions are used in gerber plots
- useGerberAdvancedAttributes: bool = False
The
useGerberAdvancedAttributestoken defines if the netlist information should be included in gerber plots
- createGerberJobFile: bool = False
The
createGerberJobFiletoken defines if a job file should be created when plotting gerber files
- dashedLineDashRatio: float | None = None
The
dashedLineDashRatiotoken’s documentation is still missing ..Available and required since KiCad v7
- dashedLineGapRatio: float | None = None
The
dashedLineGapRatiotoken’s documentation is still missing ..Available and required since KiCad v7
- svgUseInch: bool | None = None
The
svgUseInchtoken defines if inch units should be use when plotting SVG files.Required until KiCad v6, removed since KiCad v7
- svgPrecision: float = 0.0
The
svgPrecisiontoken defines the units precision used when plotting SVG files
- excludeEdgeLayer: bool | None = None
The
excludeEdgeLayertoken defines if the board edge layer is plotted on all layers.Required until KiCad v6, removed since KiCad v7
- plotFameRef: bool = False
The
plotFameReftoken defines if the border and title block should be plotted
- viasOnMask: bool = False
The
viasOnMasktoken defines if the vias are to be tented
- mode: int = 1
The
modetoken defines the plot mode. An attribute of 1 plots in the normal mode and an attribute of 2 plots in the outline (sketch) mode.
- useAuxOrigin: bool = False
The
useAuxOrigintoken determines if all coordinates are offset by the defined user origin
- hpglPenNumber: int = 0
The
hpglPenNumbertoken defines the integer pen number used for HPGL plots
- hpglPenSpeed: int = 0
The
hpglPenSpeedtoken defines the integer pen speed used for HPGL plots
- hpglPenDiameter: float = 0.0
The
hpglPenDiametertoken defines the floating point pen size for HPGL plots
- dxfPolygonMode: bool = False
The
dxfPolygonModetoken defines if the polygon mode should be used for DXF plots
- dxfImperialUnits: bool = False
The
dxfImperialUnitstoken defines if imperial units should be used for DXF plots
- dxfUsePcbnewFont: bool = False
The
dxfUsePcbnewFonttoken defines if the Pcbnew font (vector font) or the default font should be used for DXF plots
- psNegative: bool = False
The
psNegativetoken defines if the output should be the negative for PostScript plots
- psA4Output: bool = False
The
psA4Outputtoken defines if the A4 page size should be used for PostScript plots
- plotReference: bool = False
The
plotReferencetoken defines if hidden reference field text should be plotted
- plotValue: bool = False
The
plotValuetoken defines if hidden value field text should be plotted
- plotInvisibleText: bool = False
The
plotInvisibleTexttoken defines if hidden text other than the reference and value fields should be plotted
- sketchPadsOnFab: bool = False
The
sketchPadsOnFabtoken defines if pads should be plotted in the outline (sketch) mode
- subtractMaskFromSilk: bool = False
The
subtractMaskFromSilktoken defines if the solder mask layers should be subtracted from the silk screen layers for gerber plots
- outputFormat: int = 0
The
outputFormattoken defines the last plot type. The following values are defined: - 0: gerber - 1: PostScript - 2: SVG - 3: DXF - 4: HPGL - 5: PDF
- mirror: bool = False
The
mirrortoken defines if the plot should be mirrored
- drillShape: int = 0
The
drillShapetoken defines the type of drill marks used for drill files
- scaleSelection: int = 1
The
scaleSelectionis not documented yet (as of 20.02.2022)
- outputDirectory: str = ''
The
drillShapetoken defines the path relative to the current project path where the plot files will be saved
- classmethod from_sexpr(exp: list) PlotSettings
Convert the given S-Expresstion into a PlotSettings object
- Args:
exp (list): Part of parsed S-Expression
(pcbplotparams ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not pcbplotparams
- Returns:
PlotSettings: Object of the class initialized with the given S-Expression
- to_sexpr(indent=4, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 4.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.brditems.SetupData(stackup: Stackup | None = None, packToMaskClearance: float = 0.0, solderMaskMinWidth: float | None = None, padToPasteClearance: float | None = None, padToPasteClearanceRatio: float | None = None, auxAxisOrigin: Position | None = None, gridOrigin: Position | None = None, plotSettings: PlotSettings | None = None)
Bases:
objectThe setup token is used to store the current settings such as default item sizes and other options used by the board
- stackup: Stackup | None = None
The optional
stackupdefine the parameters required to manufacture the board
- packToMaskClearance: float = 0.0
The
packToMaskClearancetoken defines the clearance between footprint pads and the solder mask
- solderMaskMinWidth: float | None = None
The optional
solderMaskMinWidthdefines the minimum solder mask width. If not defined, the minimum width is zero.
- padToPasteClearance: float | None = None
The optional
padToPasteClearancedefines the clearance between footprint pads and the solder paste layer. If not defined, the clearance is zero
- padToPasteClearanceRatio: float | None = None
The optional
padToPasteClearanceRatiois the percentage (from 0 to 100) of the footprint pad to make the solder paste. If not defined, the ratio is 100% (the same size as the pad).
- auxAxisOrigin: Position | None = None
The optional
auxAxisOrigindefines the auxiliary origin if it is set to anything other than (0,0).
- gridOrigin: Position | None = None
The optional
gridOrigindefines the grid original if it is set to anything other than (0,0).
- plotSettings: PlotSettings | None = None
The optional
plotSettingsdefine how the board was last plotted.
- classmethod from_sexpr(exp: list) SetupData
Convert the given S-Expresstion into a SetupData object
- Args:
exp (list): Part of parsed S-Expression
(setup ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not setup
- Returns:
SetupData: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.brditems.Segment(start: ~kiutils.items.common.Position = <factory>, end: ~kiutils.items.common.Position = <factory>, width: float = 0.1, layer: str = 'F.Cu', locked: bool = False, net: int = 0, tstamp: str = '')
Bases:
objectThe
segmenttoken defines a track segment in a KiCad board- width: float = 0.1
The
widthtoken defines the line width
- layer: str = 'F.Cu'
The
layertoken defines the canonical layer the track segment resides on
- locked: bool = False
The
lockedtoken defines if the line cannot be edited
- net: int = 0
The
nettoken defines by the net ordinal number which net in the net section that the segment is part of
- tstamp: str = ''
The
tstamptoken defines the unique identifier of the line object
- classmethod from_sexpr(exp: list) Segment
Convert the given S-Expresstion into a Segment object
- Args:
exp (list): Part of parsed S-Expression
(segment ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not segment
- Returns:
Segment: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.brditems.Via(type: str | None = None, locked: bool = False, position: ~kiutils.items.common.Position = <factory>, size: float = 0.0, drill: float = 0.0, layers: ~typing.List[str] = <factory>, removeUnusedLayers: bool = False, keepEndLayers: bool = False, free: bool = False, net: int = 0, tstamp: str | None = None)
Bases:
objectThe
viatoken defines a track via in a KiCad board- type: str | None = None
The optional
typeattribute specifies the via type. Valid via types areblindandmicro. If no type is defined, the via is a through hole type
- locked: bool = False
The
lockedtoken defines if the line cannot be edited
- size: float = 0.0
The
sizetoken define the diameter of the via annular ring
- drill: float = 0.0
The
drilltoken define the drill diameter of the via
- layers: List[str]
The
layerstoken define the canonical layer set the via connects as a list of strings
- removeUnusedLayers: bool = False
The
removeUnusedLayerstoken is undocumented (as of 20.02.2022)
- keepEndLayers: bool = False
The
keepEndLayerstoken is undocumented (as of 20.02.2022)
- free: bool = False
The
freetoken indicates that the via is free to be moved outside it’s assigned net
- net: int = 0
The
nettoken defines by net ordinal number which net in the net section that the via is part of
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the via
- classmethod from_sexpr(exp: list) Via
Convert the given S-Expresstion into a Via object
- Args:
exp (list): Part of parsed S-Expression
(via ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not via
- Returns:
Via: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.brditems.Arc(start: ~kiutils.items.common.Position = <factory>, mid: ~kiutils.items.common.Position = <factory>, end: ~kiutils.items.common.Position = <factory>, width: float = 0.2, layer: str = 'F.Cu', locked: bool = False, net: int = 0, tstamp: str | None = None)
Bases:
objectThe
arctoken defines a track arc, which will be generated when using the length-matching feature on differential pairs.- width: float = 0.2
The
widthtoken defines the line width of the arc. Defaults to 0,2.
- layer: str = 'F.Cu'
The
layertoken defiens the canonical layer the track arc resides on. Defaults to F.Cu.
- locked: bool = False
The
lockedtoken defines if the arc cannot be edited. Defaults to False.
- net: int = 0
The
nettoken defines the net ordinal number which net in the net section that arc is part of. Defaults to 0.
- tstamp: str | None = None
The optional
tstamptoken defines the unique identifier of the arc
- classmethod from_sexpr(exp: list) Arc
Convert the given S-Expresstion into a Arc object
- Args:
exp (list): Part of parsed S-Expression
(arc ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not
arc
- Returns:
Arc: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.brditems.Target(type: str = 'plus', position: ~kiutils.items.common.Position = <factory>, size: float = 0, width: float = 0.1, layer: str = 'F.Cu', tstamp: str | None = None)
Bases:
objectThe
targettoken defines a target marker on the PCB- Documentation:
Not found in KiCad docu - 15.06.2022
- type: str = 'plus'
The
typetoken specifies the shape of the marker. Valid types areplusandx.
- size: float = 0
The
sizetoken sets the marker’s size
- width: float = 0.1
The
widthtoken sets the marker’s line width
- layer: str = 'F.Cu'
The
layertoken sets the canonical layer where the target marker resides
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the target
- classmethod from_sexpr(exp: list) Target
Convert the given S-Expresstion into a Target object
- Args:
exp (list): Part of parsed S-Expression
(target ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not target
- Returns:
Target: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
Common items (kiutils.items.common)
- Defines all syntax that is shared across the symbol library, footprint library,
schematic, board and work sheet file formats.
- Author:
Marvin Mager - @mvnmgrx - 2022
- License identifier:
GPL-3.0
- Major changes:
02.02.2022 - created
- Documentation taken from:
https://dev-docs.kicad.org/en/file-formats/sexpr-intro/index.html#_common_syntax
- class kiutils.items.common.Position(X: float = 0.0, Y: float = 0.0, angle: float | None = None, unlocked: bool = False)
Bases:
objectThe
positiontoken defines the positional coordinates and rotation of an object.- Documentation:
https://dev-docs.kicad.org/en/file-formats/sexpr-intro/index.html#_position_identifier
- X: float = 0.0
The
Xattribute defines the horizontal position of the object
- Y: float = 0.0
The
Yattribute defines the vertical position of the object
- angle: float | None = None
The optional
angleattribute defines the rotational angle of the object. Not all objects have rotational position definitions. Symbol text angles are stored in tenths of a degree. All other angles are stored in degrees.
- unlocked: bool = False
The
unlockedtoken’s description has to be defined yet ..
- classmethod from_sexpr(exp: list) Position
Convert the given S-Expresstion into a Position object
- Args:
exp (list): Part of parsed S-Expression
(xxx ...)
- Raises:
- Exception: When the given expression is not of type
listor the list is less than 3 items long
- Exception: When the given expression is not of type
- Returns:
Position: Object of the class initialized with the given S-Expression
- to_sexpr() str
This object does not have a direct S-Expression representation.
- class kiutils.items.common.Coordinate(X: float = 0.0, Y: float = 0.0, Z: float = 0.0)
Bases:
objectThe
coordinatetoken defines a three-dimentional position- X: float = 0.0
The
Xtoken defines the position of the object on the x-axis
- Y: float = 0.0
The
Ytoken defines the position of the object on the y-axis
- Z: float = 0.0
The
Ztoken defines the position of the object on the z-axis
- classmethod from_sexpr(exp: list) Coordinate
Convert the given S-Expresstion into a Coordinate object
- Args:
exp (list): Part of parsed S-Expression
(xyz ...)
- Raises:
Exception: When given parameter’s type is not a list or the list is not 4 items long
Exception: When the first item of the list is not xyz
- Returns:
Coordinate: Object of the class initialized with the given S-Expression
- to_sexpr(indent=0, newline=False) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 0.
newline (bool): Adds a newline to the end of the output. Defaults to False.
- Returns:
str: S-Expression of this object
- class kiutils.items.common.ColorRGBA(R: int = 0, G: int = 0, B: int = 0, A: int = 0, precision: int | None = None)
Bases:
objectThe
colortoken defines a RGBA color- R: int = 0
The
Rtoken defines the red channel of the color
- G: int = 0
The
Gtoken defines the green channel of the color
- B: int = 0
The
Btoken defines the blue channel of the color
- A: int = 0
The
Atoken defines the alpha channel of the color
- precision: int | None = None
Wether the output of
to_sexpr()should have a set number of precision after the decimal point of theself.Aattribute
- classmethod from_sexpr(exp: list) ColorRGBA
Convert the given S-Expresstion into a ColorRGBA object
- Args:
exp (list): Part of parsed S-Expression
(color ...)
- Raises:
Exception: When given parameter’s type is not a list or the list is not 5 items long
Exception: When the first item of the list is not color
- Returns:
ColorRGBA: Object of the class initialized with the given S-Expression
- to_sexpr(indent=0, newline=False) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 0.
newline (bool): Adds a newline to the end of the output. Defaults to False.
- Returns:
str: S-Expression of this object
- class kiutils.items.common.Stroke(width: float = 0.0, type: str | None = None, color: ColorRGBA | None = None)
Bases:
objectThe
stroketoken defines how the outlines of graphical objects are drawn.- width: float = 0.0
The
widthtoken attribute defines the line width of the graphic object
- type: str | None = None
The optional
typetoken attribute defines the line style of the graphic object. Valid stroke line styles are: -dash,dash_dot,dash_dot_dot(since KiCad v7),dot,default,solid
- color: ColorRGBA | None = None
The
colortoken attributes define the line red, green, blue, and alpha color settings. Defaults toNoneand was made optional since KiCad 7.
- classmethod from_sexpr(exp: list) Stroke
Convert the given S-Expresstion into a Stroke object
- Args:
exp (list): Part of parsed S-Expression
(stroke ...)
- Raises:
Exception: When given parameter’s type is not a list or the list is not 4 items long
Exception: When the first item of the list is not stroke
- Returns:
Stroke: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.common.Font(face: str | None = None, height: float = 1.0, width: float = 1.0, thickness: float | None = None, bold: bool = False, italic: bool = False, lineSpacing: float | None = None, color: ColorRGBA | None = None)
Bases:
objectThe
fonttoken attributes define how text is shown.- face: str | None = None
The optional ‘face’ token indicates the font family. It should be a TrueType font family name or “KiCad Font” for the KiCad stroke font. (Kicad version 7)
- height: float = 1.0
The ‘height’ token attributes define the font’s height
- width: float = 1.0
The ‘width’ token attributes define the font’s width
- thickness: float | None = None
The ‘thickness’ token attribute defines the line thickness of the font
- bold: bool = False
The ‘bold’ token specifies if the font should be bold
- italic: bool = False
The ‘italic’ token specifies if the font should be italicized
- lineSpacing: float | None = None
The ‘line_spacing’ token specifies the spacing between lines as a ratio of standard line-spacing. (Not yet supported)
- color: ColorRGBA | None = None
The optional
colortoken specifies the color of the text elementAvailable since KiCad v7
- classmethod from_sexpr(exp: list) Font
Convert the given S-Expresstion into a Font object
- Args:
exp (list): Part of parsed S-Expression
(font ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not font
- Returns:
Font: Object of the class initialized with the given S-Expression
- to_sexpr(indent=0, newline=False) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 0.
newline (bool): Adds a newline to the end of the output. Defaults to False.
- Returns:
str: S-Expression of this object
- class kiutils.items.common.Justify(horizontally: str | None = None, vertically: str | None = None, mirror: bool = False)
Bases:
objectThe
justifytoken defines the justification of a text object- horizontally: str | None = None
The
horizontallytoken sets the horizontal justification. Valid values arerightorleft
- vertically: str | None = None
The
verticallytoken sets the vertical justification. Valid values aretoporbottom
- mirror: bool = False
The
mirrortoken defines if the text is mirrored or not
- classmethod from_sexpr(exp: list) Justify
Convert the given S-Expresstion into a Justify object
- Args:
exp (list): Part of parsed S-Expression
(justify ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not justify
- Returns:
Justify: Object of the class initialized with the given S-Expression
- to_sexpr(indent=0, newline=False) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 0.
newline (bool): Adds a newline to the end of the output. Defaults to False.
- Returns:
str: S-Expression of this object or an empty string (depending on given indentation and newline settings) if no justification is given. This will cause the text to be horizontally and vertically aligend
- class kiutils.items.common.Effects(font: ~kiutils.items.common.Font = <factory>, justify: ~kiutils.items.common.Justify = <factory>, hide: bool = False, href: str | None = None)
Bases:
objectAll text objects can have an optional effects section that defines how the text is displayed.
- hide: bool = False
The optional
hidetoken defines if the text is hidden
- href: str | None = None
The optional
hreftoken specifies a link that the text element represents.Available since KiCad v7
- classmethod from_sexpr(exp: list) Effects
Convert the given S-Expresstion into a Effects object
- Args:
exp (list): Part of parsed S-Expression
(effects ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not effects
- Returns:
Effects: Object of the class initialized with the given S-Expression
- to_sexpr(indent=0, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 0.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.common.Net(number: int = 0, name: str = '')
Bases:
objectThe
nettoken defines the number and name of a net- number: int = 0
The
numbertoken defines the integer number of the net
- name: str = ''
The
nametoken defines the name of the net
- classmethod from_sexpr(exp: list) Net
Convert the given S-Expresstion into a Net object
- Args:
exp (list): Part of parsed S-Expression
(net ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not net
- Returns:
Net: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 0, newline: bool = False) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 0.
newline (bool): Adds a newline to the end of the output. Defaults to False.
- Returns:
str: S-Expression of this object
- class kiutils.items.common.Group(name: str = '', locked: bool = False, id: str = '', members: ~typing.List[str] = <factory>)
Bases:
objectThe
grouptoken defines a group of items.- name: str = ''
The
nameattribute defines the name of the group
- locked: bool = False
The
lockedtoken defines if the group may be moved or not
- id: str = ''
The
idtoken attribute defines the unique identifier of the group
- members: List[str]
The
memberstoken attributes define a list of unique identifiers of the objects belonging to the group
- classmethod from_sexpr(exp: list) Group
Convert the given S-Expresstion into a Group object
- Args:
exp (list): Part of parsed S-Expression
(group ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not group
- Returns:
Group: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.common.PageSettings(paperSize: str = 'A4', width: float | None = None, height: float | None = None, portrait: bool = False)
Bases:
objectThe
papertoken defines the drawing page size and orientation.- paperSize: str = 'A4'
The
paperSizetoken defines the size of the paper. Valid sizes are A0, A1, A2, A3, A4, A5,A,B,C,DandE. When using user-defines page sizes, set this toUser
- width: float | None = None
The
widthtoken sets the width of a user-defines page size
- height: float | None = None
The
heighttoken sets the height of a user-defines page size
- portrait: bool = False
The
portraittoken defines if the page is in portrait or landscape mode
- classmethod from_sexpr(exp: list) PageSettings
Convert the given S-Expresstion into a PageSettings object
- Args:
exp (list): Part of parsed S-Expression
(paper ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not paper
Exception: When the paper type is set to
Userand the list’s length is not 4
- Returns:
PageSettings: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Raises:
Exception: When paper size is set to
Userand width or height is not specified
- Returns:
str: S-Expression of this object
- class kiutils.items.common.TitleBlock(title: str | None = None, date: str | None = None, revision: str | None = None, company: str | None = None, comments: ~typing.Dict[int, str] = <factory>)
Bases:
objectThe
title_blocktoken defines the contents of the title block.- title: str | None = None
The optional
titletoken attribute is a quoted string that defines the document title
- date: str | None = None
The optional
datetoken attribute is a quoted string that defines the document date using the YYYY-MM-DD format
- revision: str | None = None
The optional
revisiontoken attribute is a quoted string that defines the document revision
- company: str | None = None
The optional
companytoken attribute is a quoted string that defines the document company name
- comments: Dict[int, str]
The
commentstoken attributes define a dictionary of document comments where the key is a number from 1 to 9 and the value is a comment string
- classmethod from_sexpr(exp: list) TitleBlock
Convert the given S-Expresstion into a TitleBlock object
- Args:
exp (list): Part of parsed S-Expression
(title_block ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not title_block
- Returns:
TitleBlock: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.common.Property(key: str = '', value: str = '', id: int | None = None, position: ~kiutils.items.common.Position = <factory>, effects: ~kiutils.items.common.Effects | None = None, showName: bool = False)
Bases:
objectThe
propertytoken defines a symbol property when used inside asymboldefinition.- key: str = ''
The
keystring defines the name of the property and must be unique
- value: str = ''
The
valuestring defines the value of the property
- id: int | None = None
The
idtoken defines an integer ID for the property and must be unique.Optional since KiCad v7, but required in older versions
- position: Position
The
positiondefines the X and Y coordinates as well as the rotation angle of the property. All three items will initially be set to zero.
- showName: bool = False
The
show_nametoken defines if the property name is visibly shown. Used for netclass labels.Available since KiCad v7
- classmethod from_sexpr(exp: list) Property
Convert the given S-Expresstion into a Property object
- Args:
exp (list): Part of parsed S-Expression
(property ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not property
- Returns:
Property: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 4, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 4.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.common.RenderCachePolygon(pts: ~typing.List[~kiutils.items.common.Position] = <factory>)
Bases:
objectA polygon used by the
render_cachetokenUsed since KiCad v7
- classmethod from_sexpr(exp: list) RenderCachePolygon
Convert the given S-Expresstion into a RenderCachePolygon object
- Args:
exp (list): Part of parsed S-Expression
(polygon ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not polygon
- Returns:
RenderCachePolygon: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 6, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 6.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.common.RenderCache(text: str = '', id: int = 0, polygons: ~typing.List[~kiutils.items.common.Position] = <factory>)
Bases:
objectThe
render_cachetoken defines a cache for none-standard fonts.Used since KiCad v7
- Documentation:
None found (05.03.2023), seems to be used in ‘’text_box’’ tokens for custom fonts
- text: str = ''
The
texttoken defines which text the cache represents. Defaults to an empty string.
- id: int = 0
The
idtoken is some number after the text. Defaults to 0.
- polygons: List[Position]
The
polygonstoken is a list of polygons that define the outline of the cached text
- classmethod from_sexpr(exp: list) RenderCache
Convert the given S-Expresstion into a RenderCache object
- Args:
exp (list): Part of parsed S-Expression
(render_cache ...)
- Raises:
Exception: When given parameter’s type is not a list or the list is smaller than 3
Exception: When the first item of the list is not render_cache
- Returns:
RenderCache: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 4, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 4.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.common.Fill(type: str = 'none', color: ColorRGBA | None = None)
Bases:
objectThe
filltoken defines how schematic and symbol graphical items are filled- type: str = 'none'
The
typeattribute defines how the graphical item is filled. Defaults toNone. Possible values are: -none: Graphic is not filled -outline: Graphic item filled with the line color -background: Graphic item filled with the theme background color
- color: ColorRGBA | None = None
The optional
colortoken defines the color of the filled item.Available since KiCad v7
- classmethod from_sexpr(exp: list) Fill
Convert the given S-Expresstion into a Fill object
- Args:
exp (list): Part of parsed S-Expression
(fill ...)
- Raises:
Exception: When given parameter’s type is not a list or the list is smaller than 3
Exception: When the first item of the list is not fill
- Returns:
Fill: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 4, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 4.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.common.Image(position: ~kiutils.items.common.Position = <factory>, scale: float | None = None, data: ~typing.List[str] = <factory>, uuid: str | None = None, layer: str | None = None)
Bases:
objectThe
imagetoken defines an image embedded into the file- scale: float | None = None
The optional
scaletoken attribute defines the scale factor (size) of the image
- data: List[str]
The
datatoken attribute defines the image data in the portable network graphics format (PNG) encoded with MIME type base64 as a list of strings
- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- layer: str | None = None
The optional
layertoken defines the canonical layer name when the image is used inside a footprint or PCB. When used inside a schematic, this token is required to beNone.
- classmethod from_sexpr(exp: list) Image
Convert the given S-Expresstion into a Image object
- Args:
exp (list): Part of parsed S-Expression
(image ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not image
- Returns:
Image: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.common.ProjectInstance(name: str = '')
Bases:
ABCThe
instancestoken defines a project instance and serves as an abstract base class for symbol and hierarchical sheet project instances.Available since KiCad v7.
- name: str = ''
The
nametoken defines the name of the project instance
- abstract from_sexpr(exp: list) ProjectInstance
- abstract to_sexpr(indent=2, newline=True) str
Dimensions (kiutils.items.dimension)
The dimensions are used to mark spots in the board file for their dimensions (units, metric, imperial, etc)
- Author:
Marvin Mager - @mvnmgrx - 2022
- License identifier:
GPL-3.0
- Major changes:
14.06.2022 - created
- Documentation taken from:
https://dev-docs.kicad.org/en/file-formats/sexpr-intro/index.html#_dimension
- class kiutils.items.dimensions.DimensionFormat(prefix: str | None = None, suffix: str | None = None, units: int = 3, unitsFormat: int = 1, precision: int = 4, overrideValue: str | None = None, suppressZeroes: bool = False)
Bases:
objectThe
formattoken defines the text formatting of a dimension- prefix: str | None = None
The optional
prefixtoken defines the string to add to the beginning of the dimension text
- suffix: str | None = None
The optional
suffixtoken defines the string to add to the end of the dimension text
- units: int = 3
The
unitstoken defines the dimension units used to display the dimension text. Valid units are as follows: - 0: Inches - 1: Mils - 2: Millimeters - 3: Automatic
- unitsFormat: int = 1
The
unitsFormattoken defines how the unit’s suffix is formatted. Valid units formats are as follows: - 0: No suffix - 1: Bare suffix - 2: Wrap suffix in parenthesis
- precision: int = 4
The
precisiontoken defines the number of significant digits to display
- overrideValue: str | None = None
The optional
overrideValuetoken defines the text to substitute for the actual physical dimension
- suppressZeroes: bool = False
The
suppressZeroestoken removes all trailing zeros from the dimension text
- classmethod from_sexpr(exp: list) DimensionFormat
Convert the given S-Expresstion into a DimensionFormat object
- Args:
exp (list): Part of parsed S-Expression
(format ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not format
- Returns:
DimensionFormat: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 4, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 4.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.dimensions.DimensionStyle(thickness: float = 0.0, arrowLength: float = 0.0, textPositionMode: int = 0, extensionHeight: float | None = None, textFrame: int | None = None, extensionOffset: float | None = None, keepTextAligned: bool = False)
Bases:
objectThe
styletoken defines the style of a dimension- thickness: float = 0.0
The
thicknesstoken defines the line thickness of the dimension
- arrowLength: float = 0.0
The
arrowLengthtoken defines the length of the dimension arrows
- textPositionMode: int = 0
The
textPositionModetoken defines the position mode of the dimension text. Valid position modes are as follows: - 0: Text is outside the dimension line - 1: Text is in line with the dimension line - 2: Text has been manually placed by the user
- extensionHeight: float | None = None
The optional
extensionHeighttoken defines the length of the extension lines past the dimension crossbar
- textFrame: int | None = None
The optional
textFrametoken defines the style of the frame around the dimension text. This only applies to leader dimensions. Valid text frames are as follows: - 0: No text frame - 1: Rectangle - 2: Circle - 3:Rounded rectangle
- extensionOffset: float | None = None
The optional
extensionOffsettoken defines the distance from feature points to extension line start
- keepTextAligned: bool = False
The
keepTextAlignedtoken indicates that the dimension text should be kept in line with the dimension crossbar. When false, the dimension text is shown horizontally regardless of the orientation of the dimension.
- classmethod from_sexpr(exp: list) DimensionStyle
Convert the given S-Expresstion into a DimensionStyle object
- Args:
exp (list): Part of parsed S-Expression
(style ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not style
- Returns:
DimensionStyle: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 4, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 4.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.dimensions.Dimension(locked: bool = False, type: str = 'aligned', layer: str = 'F.Cu', tstamp: str | None = None, pts: ~typing.List[~kiutils.items.common.Position] = <factory>, height: float | None = None, orientation: float | None = None, leaderLength: float | None = None, grText: ~kiutils.items.gritems.GrText | None = None, format: ~kiutils.items.dimensions.DimensionFormat | None = None, style: ~kiutils.items.dimensions.DimensionStyle = <factory>)
Bases:
objectThe
dimensiontoken defines a dimension in the PCB- locked: bool = False
The optional
lockedtoken specifies if the dimension can be moved
- type: str = 'aligned'
The
typetoken defines the type of dimension. Valid dimension types arealigned,leader,center,orthogonal(andradialin KiCad version 7)
- layer: str = 'F.Cu'
The
layertoken defines the canonical layer the polygon resides on
- tstamp: str | None = None
The
tstamptoken defines the unique identifier for the footprint. This only applies to footprints defined in the board file format.
- height: float | None = None
The optional
heighttoken defines the height of aligned dimensions
- orientation: float | None = None
The optional
orientationtoken defines the rotation angle for orthogonal dimensions
- leaderLength: float | None = None
The optional
leaderLengthtoken attribute defines the distance from the marked radius to the knee for radial dimensions.
- grText: GrText | None = None
The optional
grTexttoken define the dimension text formatting for all dimension types except center dimensions
- format: DimensionFormat | None = None
The optional
formattoken define the dimension formatting for all dimension types except center dimensions
- style: DimensionStyle
The
styletoken defines the dimension style information
- classmethod from_sexpr(exp: list) Dimension
Convert the given S-Expresstion into a Dimension object
- Args:
exp (list): Part of parsed S-Expression
(dimension ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not dimension
- Returns:
Dimension: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Raises:
Exception: When number of coordinate points of the dimension equals 0
- Returns:
str: S-Expression of this object
Footprint items (kiutils.items.fpitems)
Footprint graphical items define all of the drawing items that are used in the footprint definition. This includes text, text boxes, lines, rectangles, circles, arcs, polygons, curves and dimensions.
- Author:
Marvin Mager - @mvnmgrx - 2022
- License identifier:
GPL-3.0
- Major changes:
08.02.2022 - created
- Documentation taken from:
https://dev-docs.kicad.org/en/file-formats/sexpr-intro/index.html#_footprint_graphics_items
- class kiutils.items.fpitems.FpText(type: str = 'reference', text: str = '%REF', position: ~kiutils.items.common.Position = <factory>, layer: str = 'F.Cu', hide: bool = False, effects: ~kiutils.items.common.Effects = <factory>, tstamp: str | None = None, renderCache: ~kiutils.items.common.RenderCache | None = None)
Bases:
objectThe
fp_texttoken defines a graphic line in a footprint definition.- type: str = 'reference'
The
typeattribute defines the type of text. Valid types arereference,value, anduser
- text: str = '%REF'
The
textattribute is a string that defines the text
- position: Position
The
positiondefines the X and Y position coordinates and optional orientation angle of the text
- layer: str = 'F.Cu'
The
layertoken defines the canonical layer the text resides on
- hide: bool = False
The optional
hidetoken, defines if the text is hidden
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the text object
- renderCache: RenderCache | None = None
If the
effectstoken prescribe a TrueType font then the optionalrender_cachetoken should be given in case the font can not be found on the current system.Available since KiCad v7
- classmethod from_sexpr(exp: list) FpText
Convert the given S-Expresstion into a FpText object
- Args:
exp (list): Part of parsed S-Expression
(fp_text ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not fp_text
- Returns:
FpText: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.fpitems.FpLine(start: ~kiutils.items.common.Position = <factory>, end: ~kiutils.items.common.Position = <factory>, layer: str = 'F.Cu', width: float | None = 0.12, stroke: ~kiutils.items.common.Stroke | None = None, locked: bool = False, tstamp: str | None = None)
Bases:
objectThe
fp_linetoken defines a graphic line in a footprint definition.- layer: str = 'F.Cu'
The
layertoken defines the canonical layer the line resides on
- width: float | None = 0.12
The
widthtoken defines the line width of the line. (prior to version 7)
- stroke: Stroke | None = None
The
strokedescribes the line width and style of the line. (version 7)
- locked: bool = False
The optional
lockedtoken defines if the line cannot be edited
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the line object
- classmethod from_sexpr(exp: list) FpLine
Convert the given S-Expresstion into a FpLine object
- Args:
exp (list): Part of parsed S-Expression
(fp_line ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not fp_line
- Returns:
FpLine: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.fpitems.FpRect(start: ~kiutils.items.common.Position = <factory>, end: ~kiutils.items.common.Position = <factory>, layer: str = 'F.Cu', width: float | None = 0.12, stroke: ~kiutils.items.common.Stroke | None = None, fill: str | None = None, locked: bool = False, tstamp: str | None = None)
Bases:
objectThe
fp_recttoken defines a graphic rectangle in a footprint definition.- Documentation:
https://dev-docs.kicad.org/en/file-formats/sexpr-intro/index.html#_footprint_rectangle
- layer: str = 'F.Cu'
The
layertoken defines the canonical layer the rectangle resides on
- width: float | None = 0.12
The
widthtoken defines the line width of the rectangle. (prior to version 7)
- stroke: Stroke | None = None
The
strokedescribes the line width and style of the rectangle. (version 7)
- fill: str | None = None
The optional
filltoke defines how the rectangle is filled. Valid fill types are solid and none. If not defined, the rectangle is not filled.
- locked: bool = False
The optional
lockedtoken defines if the rectangle cannot be edited
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the rectangle object
- classmethod from_sexpr(exp: list) FpRect
Convert the given S-Expresstion into a FpRect object
- Args:
exp (list): Part of parsed S-Expression
(fp_rect ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not fp_rect
- Returns:
FpRect: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.fpitems.FpTextBox(locked: bool = False, text: str = '', start: ~kiutils.items.common.Position | None = None, end: ~kiutils.items.common.Position | None = None, pts: ~typing.List[~kiutils.items.common.Position] = <factory>, angle: float | None = None, layer: str = 'F.Cu', tstamp: str | None = None, effects: ~kiutils.items.common.Effects | None = None, stroke: ~kiutils.items.common.Stroke | None = None, renderCache: ~kiutils.items.common.RenderCache | None = None)
Bases:
objectThe
fp_text_boxtoken defines a rectangle containing line-wrapped text.Available since KiCad v7
- locked: bool = False
The
lockedtoken specifies if the text box can be moved. Defaults toFalse.
- text: str = ''
The
texttoken defines the content of the text box. Defaults to an empty string.
- start: Position | None = None
The optional
starttoken defines the top-left of a cardinally oriented text box
- end: Position | None = None
The optional
endtoken defines the bottom-right of a cardinally oriented text box
- pts: List[Position]
The
ptstoken defines the four corners of a non-cardianlly oriented text box. The corners must be in order, but the winding can be either direction.
- angle: float | None = None
The optional
angletoken defines the rotation of the text box in degrees.- Note:
If
angleis not given, or is a cardinal angle (0, 90, 180 or 270), then the text box
MUST have
startandendtokens. - Ifangleis given and is not a cardinal angle, then the text box MUST have aptstoken (with 4 pts).
- layer: str = 'F.Cu'
The
layertoken defines the canonical layer the text box resides on. Defaults toF.Cu.
- tstamp: str | None = None
The optional
tstamptoken defines the unique identifier of the text box
- effects: Effects | None = None
The optional
effectstoken describes the style of the text in the text box
- stroke: Stroke | None = None
The optional
stroketoken describes the style of an optional border to be drawn around the text box
- renderCache: RenderCache | None = None
If the
effectstoken prescribe a TrueType font then the optionalrender_cachetoken should be given in case the font can not be found on the current system.
- classmethod from_sexpr(exp: list) FpTextBox
Convert the given S-Expression into a FpTextBox object
- Args:
exp (list): Part of parsed S-Expression
(fp_text_box ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not fp_text_box
- Returns:
FpTextBox: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Raises:
Exception: When a non-cardinal angle is given and no corner points were defined using the
self.ptstokenException: When a cardinal angle or no angle is given and either start or end token is undefined
- Returns:
str: S-Expression of this object
- class kiutils.items.fpitems.FpCircle(center: ~kiutils.items.common.Position = <factory>, end: ~kiutils.items.common.Position = <factory>, layer: str = 'F.Cu', width: float | None = 0.12, stroke: ~kiutils.items.common.Stroke | None = None, fill: str | None = None, locked: bool = False, tstamp: str | None = None)
Bases:
objectThe ``fp_circle `` token defines a graphic circle in a footprint definition.
- layer: str = 'F.Cu'
The
layertoken defines the canonical layer the circle resides on
- width: float | None = 0.12
The
widthtoken defines the line width of the circle. (prior to version 7)
- stroke: Stroke | None = None
The
strokedescribes the line width and style of the circle. (version 7)
- fill: str | None = None
The optional
filltoke defines how the circle is filled. Valid fill types aresolidandnone. If not defined, the circle is not filled.
- locked: bool = False
The optional
lockedtoken defines if the circle cannot be edited
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the circle object
- classmethod from_sexpr(exp: list) FpCircle
Convert the given S-Expresstion into a FpCircle object
- Args:
exp (list): Part of parsed S-Expression
(fp_circle ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not fp_circle
- Returns:
FpCircle: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.fpitems.FpArc(start: ~kiutils.items.common.Position = <factory>, mid: ~kiutils.items.common.Position = <factory>, end: ~kiutils.items.common.Position = <factory>, layer: str = 'F.Cu', width: float | None = 0.12, stroke: ~kiutils.items.common.Stroke | None = None, locked: bool = False, tstamp: str | None = None)
Bases:
objectThe
fp_arctoken defines a graphic arc in a footprint definition.- layer: str = 'F.Cu'
The
layertoken defines the canonical layer the arc resides on
- width: float | None = 0.12
The
widthtoken defines the line width of the arc. (prior to version 7)
- locked: bool = False
The optional
lockedtoken defines if the arc cannot be edited
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the arc object
- classmethod from_sexpr(exp: list) FpArc
Convert the given S-Expresstion into a FpArc object
- Args:
exp (list): Part of parsed S-Expression
(fp_arc ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not fp_arc
- Returns:
FpArc: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.fpitems.FpPoly(layer: str = 'F.Cu', coordinates: ~typing.List[~kiutils.items.common.Position] = <factory>, width: float | None = 0.12, stroke: ~kiutils.items.common.Stroke | None = None, fill: str | None = None, locked: bool = False, tstamp: str | None = None)
Bases:
objectThe
fp_polytoken defines a graphic polygon in a footprint definition.- layer: str = 'F.Cu'
The
layertoken defines the canonical layer the polygon resides on
- coordinates: List[Position]
The
coordinatesdefine the list of X/Y coordinates of the polygon outline
- width: float | None = 0.12
The
widthtoken defines the line width of the polygon. (prior to version 7)
- stroke: Stroke | None = None
The
strokedescribes the line width and style of the polygon. (version 7)
- fill: str | None = None
The optional
filltoke defines how the polygon is filled. Valid fill types are solid and none. If not defined, the rectangle is not filled.
- locked: bool = False
The optional
lockedtoken defines if the polygon cannot be edited
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the polygon object
- classmethod from_sexpr(exp: list) FpPoly
Convert the given S-Expresstion into a FpPoly object
- Args:
exp (list): Part of parsed S-Expression
(fp_poly ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not fp_poly
- Returns:
FpPoly: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object. When no coordinates are set in the polygon, the resulting S-Expression will be left empty.
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.fpitems.FpCurve(coordinates: ~typing.List[~kiutils.items.common.Position] = <factory>, layer: str = 'F.Cu', width: float | None = 0.12, stroke: ~kiutils.items.common.Stroke | None = None, locked: bool = False, tstamp: str | None = None)
Bases:
objectThe
fp_curvetoken defines a graphic Cubic Bezier curve in a footprint definition.- coordinates: List[Position]
The
coordinatesdefine the list of X/Y coordinates of the curve outline
- layer: str = 'F.Cu'
The
layertoken defines the canonical layer the curve resides on
- width: float | None = 0.12
The
widthtoken defines the line width of the curve. (prior to version 7)
- stroke: Stroke | None = None
The
strokedescribes the line width and style of the curve. (version 7)
- locked: bool = False
The optional
lockedtoken defines if the curve cannot be edited
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the curve object
- classmethod from_sexpr(exp: list) FpCurve
Convert the given S-Expresstion into a FpCurve object
- Args:
exp (list): Part of parsed S-Expression
(fp_curve ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not fp_curve
- Returns:
FpCurve: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object. When no coordinates are set in the curve, the resulting S-Expression will be left empty.
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
Graphical items (kiutils.items.gritems)
- The graphical items are footprint and board items that are outside of the connectivity items.
This includes graphical items on technical, user, and copper layers. Graphical items are also used to define complex pad geometries.
- Author:
Marvin Mager - @mvnmgrx - 2022
- License identifier:
GPL-3.0
- Major changes:
10.02.2022 - created
- Documentation taken from:
https://dev-docs.kicad.org/en/file-formats/sexpr-intro/index.html#_graphic_items
- class kiutils.items.gritems.GrText(text: str = '', position: ~kiutils.items.common.Position = <factory>, layer: str | None = None, effects: ~kiutils.items.common.Effects = <factory>, tstamp: str | None = None, locked: bool = False, renderCache: ~kiutils.items.common.RenderCache | None = None)
Bases:
objectThe
gr_texttoken defines a graphical text.- text: str = ''
The
textattribute is a string that defines the text
- position: Position
The
positiondefines the X and Y position coordinates and optional orientation angle of the text
- layer: str | None = None
The
layertoken defines the canonical layer the text resides on
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the text object
- locked: bool = False
The
lockedtoken defines if the object may be moved or not
- renderCache: RenderCache | None = None
If the
effectstoken prescribe a TrueType font then the optionalrender_cachetoken should be given in case the font can not be found on the current system.Available since KiCad v7
- classmethod from_sexpr(exp: list) GrText
Convert the given S-Expresstion into a GrText object
- Args:
exp (list): Part of parsed S-Expression
(gr_text ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not gr_text
- Returns:
GrText: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.gritems.GrTextBox(locked: bool = False, text: str = '', start: ~kiutils.items.common.Position | None = None, end: ~kiutils.items.common.Position | None = None, pts: ~typing.List[~kiutils.items.common.Position] = <factory>, angle: float | None = None, layer: str = 'F.Cu', tstamp: str | None = None, effects: ~kiutils.items.common.Effects | None = None, stroke: ~kiutils.items.common.Stroke | None = None, renderCache: ~kiutils.items.common.RenderCache | None = None)
Bases:
objectThe
gr_text_boxtoken defines a graphical rectangle containing line-wrapped text.Available since KiCad v7
- locked: bool = False
The
lockedtoken specifies if the text box can be moved. Defaults toFalse.
- text: str = ''
The
texttoken defines the content of the text box. Defaults to an empty string.
- start: Position | None = None
The optional
starttoken defines the top-left of a cardinally oriented text box
- end: Position | None = None
The optional
endtoken defines the bottom-right of a cardinally oriented text box
- pts: List[Position]
The
ptstoken defines the four corners of a non-cardianlly oriented text box. The corners must be in order, but the winding can be either direction.
- angle: float | None = None
The optional
angletoken defines the rotation of the text box in degrees.- Note:
If
angleis not given, or is a cardinal angle (0, 90, 180 or 270), then the text box MUST havestartandendtokens.If
angleis given and is not a cardinal angle, then the text box MUST have aptstoken (with 4 pts).
- layer: str = 'F.Cu'
The
layertoken defines the canonical layer the text box resides on. Defaults toF.Cu.
- tstamp: str | None = None
The optional
tstamptoken defines the unique identifier of the text box
- effects: Effects | None = None
The optional
effectstoken describes the style of the text in the text box
- stroke: Stroke | None = None
The optional
stroketoken describes the style of an optional border to be drawn around the text box
- renderCache: RenderCache | None = None
If the
effectstoken prescribe a TrueType font then the optionalrender_cachetoken should be given in case the font can not be found on the current system.Available since KiCad v7
- classmethod from_sexpr(exp: list) GrTextBox
Convert the given S-Expression into a GrTextBox object
- Args:
exp (list): Part of parsed S-Expression
(gr_text_box ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not fp_text_box
- Returns:
GrTextBox: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Raises:
Exception: When a non-cardinal angle is given and no corner points were defined using the
self.ptstokenException: When a cardinal angle or no angle is given and either start or end token is undefined
- Returns:
str: S-Expression of this object
- class kiutils.items.gritems.GrLine(start: ~kiutils.items.common.Position = <factory>, end: ~kiutils.items.common.Position = <factory>, angle: float | None = None, layer: str | None = None, width: float | None = 0.12, tstamp: str | None = None, locked: bool = False)
Bases:
objectThe
gr_linetoken defines a graphical line.- angle: float | None = None
The optional
angletoken defines the rotational angle of the line
- layer: str | None = None
The
layertoken defines the canonical layer the rectangle resides on
- width: float | None = 0.12
The
widthtoken defines the line width of the rectangle. (prior to version 7)
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the rectangle object
- locked: bool = False
The
lockedtoken defines if the object may be moved or not
- classmethod from_sexpr(exp: list) GrLine
Convert the given S-Expresstion into a GrLine object
- Args:
exp (list): Part of parsed S-Expression
(gr_line ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not gr_line
- Returns:
GrLine: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.gritems.GrRect(start: ~kiutils.items.common.Position = <factory>, end: ~kiutils.items.common.Position = <factory>, layer: str | None = None, width: float | None = 0.12, fill: str | None = None, tstamp: str | None = None, locked: bool = False)
Bases:
objectThe
gr_recttoken defines a graphical rectangle.- Documentation:
https://dev-docs.kicad.org/en/file-formats/sexpr-intro/index.html#_graphical_rectangle
- layer: str | None = None
The
layertoken defines the canonical layer the rectangle resides on
- width: float | None = 0.12
The
widthtoken defines the line width of the rectangle. (prior to version 7)
- fill: str | None = None
The optional
filltoke defines how the rectangle is filled. Valid fill types are solid and none. If not defined, the rectangle is not filled
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the rectangle object
- locked: bool = False
The
lockedtoken defines if the object may be moved or not
- classmethod from_sexpr(exp: list) GrRect
Convert the given S-Expresstion into a GrRect object
- Args:
exp (list): Part of parsed S-Expression
(gr_rect ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not gr_rect
- Returns:
GrRect: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.gritems.GrCircle(center: ~kiutils.items.common.Position = <factory>, end: ~kiutils.items.common.Position = <factory>, layer: str | None = None, width: float | None = 0.12, fill: str | None = None, tstamp: str | None = None, locked: bool = False)
Bases:
objectThe ``gr_circle `` token defines a graphical circle.
- layer: str | None = None
The
layertoken defines the canonical layer the circle resides on
- width: float | None = 0.12
The
widthtoken defines the line width of the circle. (prior to version 7)
- fill: str | None = None
The optional
filltoke defines how the circle is filled. Valid fill types are solid and none. If not defined, the rectangle is not filled
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the circle object
- locked: bool = False
The
lockedtoken defines if the object may be moved or not
- classmethod from_sexpr(exp: list) GrCircle
Convert the given S-Expresstion into a GrCircle object
- Args:
exp (list): Part of parsed S-Expression
(gr_circle ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not gr_circle
- Returns:
GrCircle: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.gritems.GrArc(start: ~kiutils.items.common.Position = <factory>, mid: ~kiutils.items.common.Position = <factory>, end: ~kiutils.items.common.Position = <factory>, layer: str | None = None, width: float | None = 0.12, tstamp: str | None = None, locked: bool = False)
Bases:
objectThe
gr_arctoken defines a graphic arc.- layer: str | None = None
The
layertoken defines the canonical layer the arc resides on
- width: float | None = 0.12
The
widthtoken defines the line width of the arc. (prior to version 7)
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the arc object.
- locked: bool = False
The
lockedtoken defines if the object may be moved or not
- classmethod from_sexpr(exp: list) GrArc
Convert the given S-Expresstion into a GrArc object
- Args:
exp (list): Part of parsed S-Expression
(gr_arc ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not gr_arc
- Returns:
GrArc: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.gritems.GrPoly(layer: str | None = None, coordinates: ~typing.List[~kiutils.items.common.Position] = <factory>, width: float | None = 0.12, fill: str | None = None, tstamp: str | None = None, locked: bool = False)
Bases:
objectThe
gr_polytoken defines a graphic polygon in a footprint definition.- layer: str | None = None
The
coordinatesdefine the list of X/Y coordinates of the polygon outline
- width: float | None = 0.12
The
widthtoken defines the line width of the polygon. (prior to version 7)
- fill: str | None = None
The optional
filltoke defines how the polygon is filled. Valid fill types are solid and none. If not defined, the rectangle is not filled
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the polygon object
- locked: bool = False
The
lockedtoken defines if the object may be moved or not
- classmethod from_sexpr(exp: list) GrPoly
Convert the given S-Expresstion into a GrPoly object
- Args:
exp (list): Part of parsed S-Expression
(gr_poly ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not gr_poly
- Returns:
GrPoly: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True, pts_newline: bool = False) str
Generate the S-Expression representing this object. When no coordinates are set in the polygon, the resulting S-Expression will be left empty.
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- pts_newline (bool): Adds a newline for the
(pts ..)token as KiCad treats this different in Board files than Footprint files. Defaults to False.
- pts_newline (bool): Adds a newline for the
- Returns:
str: S-Expression of this object
- class kiutils.items.gritems.GrCurve(coordinates: ~typing.List[~kiutils.items.common.Position] = <factory>, layer: str | None = None, width: float | None = 0.12, tstamp: str | None = None, locked: bool = False)
Bases:
objectThe
gr_curvetoken defines a graphic Cubic Bezier curve in a footprint definition.- coordinates: List[Position]
The
coordinatesdefine the list of X/Y coordinates of the curve outline
- layer: str | None = None
The
layertoken defines the canonical layer the curve resides on
- width: float | None = 0.12
The
widthtoken defines the line width of the curve. (prior to version 7)
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the curve object
- locked: bool = False
The
lockedtoken defines if the object may be moved or not
- classmethod from_sexpr(exp: list) GrCurve
Convert the given S-Expresstion into a GrCurve object
- Args:
exp (list): Part of parsed S-Expression
(gr_curve ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not gr_curve
- Returns:
GrCurve: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object. When no coordinates are set in the curve, the resulting S-Expression will be left empty.
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
Schematic items (kiutils.items.schitems)
Defines items used in KiCad schematic files
- Author:
Marvin Mager - @mvnmgrx - 2022
- License identifier:
GPL-3.0
- Major changes:
19.02.2022 - created
- Documentation taken from:
- class kiutils.items.schitems.Junction(position: ~kiutils.items.common.Position = <factory>, diameter: float = 0, color: ~kiutils.items.common.ColorRGBA = <factory>, uuid: str | None = None)
Bases:
objectThe
junctiontoken defines a junction in the schematic- diameter: float = 0
The
diametertoken attribute defines the DIAMETER of the junction. A diameter of 0 is the default diameter in the system settings.
- color: ColorRGBA
The
colortoken attributes define the Red, Green, Blue, and Alpha transparency of the junction. If all four attributes are 0, the default junction color is used.
- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- classmethod from_sexpr(exp: list) Junction
Convert the given S-Expresstion into a Junction object
- Args:
exp (list): Part of parsed S-Expression
(junction ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not junction
- Returns:
Junction: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.NoConnect(position: ~kiutils.items.common.Position = <factory>, uuid: str | None = None)
Bases:
objectThe
no_connecttoken defines a unused pin connection in the schematic- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- classmethod from_sexpr(exp: list) NoConnect
Convert the given S-Expresstion into a NoConnect object
- Args:
exp (list): Part of parsed S-Expression
(no_connect ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not no_connect
- Returns:
NoConnect: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.BusEntry(position: ~kiutils.items.common.Position = <factory>, uuid: str | None = None, size: ~kiutils.items.common.Position = <factory>, stroke: ~kiutils.items.common.Stroke = <factory>)
Bases:
objectThe
bus_entrytoken defines a bus entry in the schematic- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- size: Position
The
sizetoken attributes define the X and Y distance of the end point from the position of the bus entry
- classmethod from_sexpr(exp: list) BusEntry
Convert the given S-Expresstion into a BusEntry object
- Args:
exp (list): Part of parsed S-Expression
(bus_entry ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not bus_entry
- Returns:
BusEntry: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.BusAlias(name: str = '', members: ~typing.List[str] = <factory>)
Bases:
objectThe
bus_aliastoken defines a bus entry in the schematic- name: str = ''
The
nameof the bus.
- members: List[str]
The list of
membersdefined in the bus. Note that when you tap out a bus entry from a bus using one these members a label will be created with the selected member name
- classmethod from_sexpr(exp: list) BusAlias
Convert the given S-Expresstion into a BusAlias object
- Args:
exp (list): Part of parsed S-Expression
(bus_alias ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not bus_alias
Exception: When the S-Expression is not exactly three items long
Exception: When the
memberstoken is missing
- Returns:
BusAlias: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.Connection(type: str = 'wire', points: ~typing.List[~kiutils.items.common.Position] = <factory>, stroke: ~kiutils.items.common.Stroke = <factory>, uuid: str | None = None)
Bases:
objectThe
wireandbustokens define wires and buses in the schematic- type: str = 'wire'
The
typetoken defines wether the connection is abusor awire
- points: List[Position]
The
pointstoken defines the list of X and Y coordinates of start and end points of the wire or bus
- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- classmethod from_sexpr(exp: list) Connection
Convert the given S-Expresstion into a Connection object
- Args:
exp (list): Part of parsed S-Expression
(wire ...)or(bus ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not wire or bus
- Returns:
Connection: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.PolyLine(points: ~typing.List[~kiutils.items.common.Position] = <factory>, stroke: ~kiutils.items.common.Stroke = <factory>, uuid: str | None = None)
Bases:
objectThe
polylinetoken defines one or more lines that may or may not represent a polygon- points: List[Position]
The
pointstoken defines the list of X/Y coordinates of to draw line(s) between. A minimum of two points is required.
- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- classmethod from_sexpr(exp: list) PolyLine
Convert the given S-Expresstion into a PolyLine object
- Args:
exp (list): Part of parsed S-Expression
(polyline ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not polyline
- Returns:
PolyLine: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.Text(text: str = '', position: ~kiutils.items.common.Position = <factory>, effects: ~kiutils.items.common.Effects = <factory>, uuid: str | None = None)
Bases:
objectThe
texttoken defines graphical text in a schematic- text: str = ''
The
texttoken defines the text string
- position: Position
The
positiontoken defines the X and Y coordinates and rotation angle of the text
- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- classmethod from_sexpr(exp: list) Text
Convert the given S-Expresstion into a Text object
- Args:
exp (list): Part of parsed S-Expression
(text ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not text
- Returns:
Text: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.TextBox(text: str = '', position: ~kiutils.items.common.Position = <factory>, size: ~kiutils.items.common.Position = <factory>, stroke: ~kiutils.items.common.Stroke = <factory>, fill: ~kiutils.items.common.Fill = <factory>, effects: ~kiutils.items.common.Effects = <factory>, uuid: str | None = None)
Bases:
objectThe
text_boxtoken defines a text box inside a schematicAvailable since KiCad v7
- Documentation:
- text: str = ''
The
texttoken defines the text string
- position: Position
The
positiontoken defines the X and Y coordinates and rotation angle of the text
- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- classmethod from_sexpr(exp: list) TextBox
Convert the given S-Expresstion into a TextBox object
- Args:
exp (list): Part of parsed S-Expression
(text_box ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not text_box
- Returns:
TextBox: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.LocalLabel(text: str = '', position: ~kiutils.items.common.Position = <factory>, effects: ~kiutils.items.common.Effects = <factory>, uuid: str | None = None, fieldsAutoplaced: bool = False)
Bases:
objectThe
labeltoken defines an wire or bus label name in a schematic- text: str = ''
The
texttoken defines the text in the label
- position: Position
The
positiontoken defines the X and Y coordinates and rotation angle of the label
- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- fieldsAutoplaced: bool = False
The
fields_autoplacedis a flag that indicates that any PROPERTIES associated with the global label have been place automatically
- classmethod from_sexpr(exp: list) LocalLabel
Convert the given S-Expresstion into a LocalLabel object
- Args:
exp (list): Part of parsed S-Expression
(label ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not label
- Returns:
LocalLabel: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.GlobalLabel(text: str = '', shape: str = 'input', fieldsAutoplaced: bool = False, position: ~kiutils.items.common.Position = <factory>, effects: ~kiutils.items.common.Effects = <factory>, uuid: str | None = None, properties: ~typing.List[~kiutils.items.common.Property] = <factory>)
Bases:
objectThe
global_labeltoken defines a label name that is visible across all schematics in a design- text: str = ''
The
texttoken defines the text in the label
- shape: str = 'input'
The
shapetoken defines the way the global label is drawn. Possible values are:input,output,bidirectional,tri_state,passive.
- fieldsAutoplaced: bool = False
The
fields_autoplacedis a flag that indicates that any PROPERTIES associated with the global label have been place automatically
- position: Position
The
positiontoken defines the X and Y coordinates and rotation angle of the label
- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- properties: List[Property]
The
propertiestoken defines a list of properties of the global label. Currently, the only supported property is the inter-sheet reference
- classmethod from_sexpr(exp: list) GlobalLabel
Convert the given S-Expresstion into a GlobalLabel object
- Args:
exp (list): Part of parsed S-Expression
(global_label ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not global_label
- Returns:
GlobalLabel: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.HierarchicalLabel(text: str = '', shape: str = 'input', position: ~kiutils.items.common.Position = <factory>, effects: ~kiutils.items.common.Effects = <factory>, uuid: str | None = None, fieldsAutoplaced: bool = False)
Bases:
objectThe
hierarchical_labeltoken defines a label that are used by hierarchical sheets to define connections between sheet in hierarchical designs- Documentation:
https://dev-docs.kicad.org/en/file-formats/sexpr-schematic/#_hierarchical_label_section
- text: str = ''
The
texttoken defines the text in the label
- shape: str = 'input'
The
shapetoken defines the way the global label is drawn. Possible values are:input,output,bidirectional,tri_state,passive.
- position: Position
The
positiontoken defines the X and Y coordinates and rotation angle of the label
- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- fieldsAutoplaced: bool = False
The
fields_autoplacedis a flag that indicates that any PROPERTIES associated with the global label have been place automatically
- classmethod from_sexpr(exp: list) HierarchicalLabel
Convert the given S-Expresstion into a HierarchicalLabel object
- Args:
exp (list): Part of parsed S-Expression
(hierarchical_label ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not hierarchical_label
- Returns:
HierarchicalLabel: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.SymbolProjectPath(sheetInstancePath: str = '', reference: str = '', unit: int = 1)
Bases:
objectThe symbol project path defines the
pathtoken to the sheet instance of the instance data of a symbol.Available since KiCad v7.
- sheetInstancePath: str = ''
The
PATH_INSTANCEtoken defines the path to the symbol instance
- reference: str = ''
The
referencetoken is a string that defines the reference designator for the symbol instance
- unit: int = 1
The
unittoken is a integer that defines the symbol unit for the symbol instance. For symbols that do not define multiple units, this will always be 1.
- classmethod from_sexpr(exp: list) SymbolProjectPath
Convert the given S-Expression into a SymbolProjectPath object
- Args:
exp (list): Part of parsed S-Expression
(path ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not path
- Returns:
SymbolProjectPath: Object of the class initialized with the given S-Expression
- to_sexpr(indent=4, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 4.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.SymbolProjectInstance(name: str = '', paths: ~typing.List[~kiutils.items.schitems.SymbolProjectPath] = <factory>)
Bases:
ProjectInstanceThe
projecttoken attribute defines the name of the project as well as a list of symbol project paths (instance data). There can be instance data from other project when schematics are shared across multiple projects. The projects will have to be sorted by thenametoken in alphabetical order.Available since KiCad v7.
- paths: List[SymbolProjectPath]
The
pathstoken defines a list of symbol project paths for this project instance
- classmethod from_sexpr(exp: list) SymbolProjectInstance
Convert the given S-Expression into a SymbolProjectInstance object
- Args:
exp (list): Part of parsed S-Expression
(project ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not project
- Returns:
SymbolProjectInstance: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.SchematicSymbol(libraryNickname: str | None = None, entryName: str | None = None, libName: str | None = None, position: ~kiutils.items.common.Position = <factory>, unit: int | None = None, inBom: bool = False, onBoard: bool = False, dnp: bool | None = None, fieldsAutoplaced: bool = False, uuid: str | None = '', properties: ~typing.List[~kiutils.items.common.Property] = <factory>, pins: ~typing.Dict[str, str] = <factory>, mirror: str | None = None, instances: ~typing.List[~kiutils.items.schitems.SymbolProjectInstance] = <factory>)
Bases:
objectThe
symboltoken in the symbol section of the schematic defines an instance of a symbol from the library symbol section of the schematic- property libId: str
The
lib_idtoken defines which symbol in the library symbol section of the schematic this schematic symbol references. Inkiutils, thelib_idtoken is a combination of both thelibraryNicknameandentryNametoken. Setting thelib_idtoken will update those tokens accordingly.- Returns:
Symbol id in the following format:
<libraryNickname>:<entryName>or<entryName>, iflibraryNicknametoken is not set.
- libraryNickname: str | None = None
The optional
libraryNicknametoken defines which symbol library this symbol belongs to and is a part of theidtoken
- entryName: str = None
The
entryNametoken defines the actual name of the symbol and is a part of theidtoken
- libName: str | None = None
The optional
lib_nametoken is only set when the symbol was edited in the schematic. It may be set to<entryName>_Xwhere X is a unique number that specifies which variation this symbol is of its original.
- position: Position
The
positiondefines the X and Y coordinates and angle of rotation of the symbol
- unit: int | None = None
The optional
unittoken attribute defines which unit in the symbol library definition that the schematic symbol represents
- inBom: bool = False
The
in_bomtoken attribute determines whether the schematic symbol appears in any bill of materials output
- onBoard: bool = False
The
on_boardtoken attribute determines if the footprint associated with the symbol is exported to the board via the netlist
- dnp: bool | None = None
The optional
dnptoken defines if a symbol is marked as do-not-populate in the schematic.Available since KiCad v7
- fieldsAutoplaced: bool = False
The
fields_autoplacedis a flag that indicates that any PROPERTIES associated with the global label have been place automatically
- uuid: str | None = ''
The optional uuid defines the universally unique identifier
- properties: List[Property]
The
propertiessection defines a list of symbol properties of the schematic symbol
- pins: Dict[str, str]
The
pinstoken defines a dictionary with pin numbers in form of strings as keys and uuid’s as values
- mirror: str | None = None
The
mirrortoken defines if the symbol is mirrored in the schematic. Accepted values:xory. When mirroring around the x and y axis at the same time use some additional rotation to get the correct orientation of the symbol.
- instances: List[SymbolProjectInstance]
The
instancestoken defines a list of symbol instances grouped by project. Every symbol will have a least one instance.Available since KiCad v7.
- classmethod from_sexpr(exp: list) SchematicSymbol
Convert the given S-Expresstion into a SchematicSymbol object
- Args:
exp (list): Part of parsed S-Expression
(symbol ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not symbol
- Returns:
SchematicSymbol: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.HierarchicalPin(name: str = '', connectionType: str = 'input', position: ~kiutils.items.common.Position = <factory>, effects: ~kiutils.items.common.Effects = <factory>, uuid: str | None = None)
Bases:
object- The
pintoken in a sheet object defines an electrical connection between the sheet in a schematic with the hierarchical label defined in the associated schematic file
- Documentation:
https://dev-docs.kicad.org/en/file-formats/sexpr-schematic/#_hierarchical_sheet_pin_definition
- name: str = ''
The
nameattribute defines the name of the sheet pin. It must have an identically named hierarchical label in the associated schematic file.
- connectionType: str = 'input'
The electrical connect type token defines the type of electrical connect made by the sheet pin
- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- classmethod from_sexpr(exp: list) HierarchicalPin
Convert the given S-Expresstion into a HierarchicalPin object
- Args:
exp (list): Part of parsed S-Expression
(pin ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not pin
- Returns:
HierarchicalPin: Object of the class initialized with the given S-Expression
- to_sexpr(indent=4, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 4.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- The
- class kiutils.items.schitems.HierarchicalSheetProjectPath(sheetInstancePath: str = '', page: str = '')
Bases:
objectThe symbol project path defines the
pathtoken to the sheet instance of the instance data of a symbol.Available since KiCad v7.
- Documentation:
https://dev-docs.kicad.org/en/file-formats/sexpr-schematic/#_hierarchical_sheet_section
- sheetInstancePath: str = ''
The
PATH_INSTANCEtoken defines the path to the symbol instance
- page: str = ''
The
pagetoken is a string that defines the page number of the sheet instance
- classmethod from_sexpr(exp: list) HierarchicalSheetProjectPath
Convert the given S-Expression into a HierarchicalSheetProjectPath object
- Args:
exp (list): Part of parsed S-Expression
(path ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not path
- Returns:
HierarchicalSheetProjectPath: Object of the class initialized with the given S-Expression
- to_sexpr(indent=4, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 4.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.HierarchicalSheetProjectInstance(name: str = '', paths: ~typing.List[~kiutils.items.schitems.HierarchicalSheetProjectPath] = <factory>)
Bases:
ProjectInstanceThe
projecttoken attribute defines the name of the project as well as a list of hierarchical sheet project paths (instance data). There can be instance data from other project when schematics are shared across multiple projects. The projects will have to be sorted by thenametoken in alphabetical order.Available since KiCad v7.
- Documentation:
https://dev-docs.kicad.org/en/file-formats/sexpr-schematic/#_hierarchical_sheet_section
- paths: List[HierarchicalSheetProjectPath]
The
pathstoken defines a list of hierarchical sheet project paths for this project instance
- classmethod from_sexpr(exp: list) HierarchicalSheetProjectInstance
Convert the given S-Expression into a HierarchicalSheetProjectInstance object
- Args:
exp (list): Part of parsed S-Expression
(project ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not project
- Returns:
HierarchicalSheetProjectInstance: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.HierarchicalSheet(position: ~kiutils.items.common.Position = <factory>, width: float = 0, height: float = 0, fieldsAutoplaced: bool = False, stroke: ~kiutils.items.common.Stroke = <factory>, fill: ~kiutils.items.common.ColorRGBA = <factory>, uuid: str | None = None, sheetName: ~kiutils.items.common.Property = <factory>, fileName: ~kiutils.items.common.Property = <factory>, pins: ~typing.List[~kiutils.items.schitems.HierarchicalPin] = <factory>, instances: ~typing.List[~kiutils.items.schitems.HierarchicalSheetProjectInstance] = <factory>)
Bases:
objectThe
sheettoken defines a hierarchical sheet of the schematic- Documentation:
https://dev-docs.kicad.org/en/file-formats/sexpr-schematic/#_hierarchical_sheet_section
- position: Position
The
positiondefines the X and Y coordinates and angle of rotation of the sheet in the schematic
- width: float = 0
The
widthtoken defines the width of the sheet
- height: float = 0
The
heighttoken defines the height of the sheet
- fieldsAutoplaced: bool = False
The
fields_autoplacedis a flag that indicates that any PROPERTIES associated with the global label have been place automatically
- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- sheetName: Property
The
sheetNameis a property that defines the name of the sheet. The property’s key should therefore be set to Sheet name
- fileName: Property
The
fileNameis a property that defines the file name of the sheet. The property’s key should therefore be set to Sheet file
- pins: List[HierarchicalPin]
The
pinssection is a list of hierarchical pins that map a hierarchical label defined in the associated schematic file
- instances: List[HierarchicalSheetProjectInstance]
The
instancestoken defines a list of hierachical sheet instances grouped by project. Every hierarchical sheet will have a least one instance.Available since KiCad v7.
- classmethod from_sexpr(exp: list) HierarchicalSheet
Convert the given S-Expresstion into a HierarchicalSheet object
- Args:
exp (list): Part of parsed S-Expression
(sheet ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not sheet
- Returns:
HierarchicalSheet: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.HierarchicalSheetInstance(instancePath: str = '/', page: str = '1')
Bases:
object- The sheet_instance token defines the per sheet information for the entire schematic. This
section will only exist in schematic files that are the root sheet of a project
- Documentation:
https://dev-docs.kicad.org/en/file-formats/sexpr-schematic/#_hierarchical_sheet_instance_section
- instancePath: str = '/'
The
instancePathattribute is the path to the sheet instance
- page: str = '1'
The
pagetoken defines the page number of the schematic represented by the sheet instance information. Page numbers can be any valid string.
- classmethod from_sexpr(exp: list) HierarchicalSheetInstance
Convert the given S-Expresstion into a HierarchicalSheetInstance object
- Args:
exp (list): Part of parsed S-Expression
(path ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not path
- Returns:
HierarchicalSheetInstance: Object of the class initialized with the given S-Expression
- to_sexpr(indent=4, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 4.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.SymbolInstance(path: str = '/', reference: str = '', unit: int = 0, value: str = '', footprint: str = '')
Bases:
objectThe
symbol_instancetoken defines the per symbol information for the entire schematic- path: str = '/'
The
pathattribute is the path to the sheet instance
- reference: str = ''
The
referencetoken attribute is a string that defines the reference designator for the symbol instance
- unit: int = 0
The unit token attribute is a integer ordinal that defines the symbol unit for the symbol instance. For symbols that do not define multiple units, this will always be 1.
- value: str = ''
The value token attribute is a string that defines the value field for the symbol instance
- footprint: str = ''
The
footprinttoken attribute is a string that defines the LIBRARY_IDENTIFIER for footprint associated with the symbol instance
- classmethod from_sexpr(exp: list) SymbolInstance
Convert the given S-Expresstion into a SymbolInstance object
- Args:
exp (list): Part of parsed S-Expression
(path ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not path
- Returns:
SymbolInstance: Object of the class initialized with the given S-Expression
- to_sexpr(indent=4, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 4.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.Rectangle(start: ~kiutils.items.common.Position = <factory>, end: ~kiutils.items.common.Position = <factory>, stroke: ~kiutils.items.common.Stroke = <factory>, fill: ~kiutils.items.common.Fill = <factory>, uuid: str | None = None)
Bases:
objectThe
rectangletoken defines a graphical rectangle in a schematic.Available since KiCad v7
- start: Position
The
starttoken attributes define the coordinates of the start point of the rectangle
- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- classmethod from_sexpr(exp: list) Rectangle
Convert the given S-Expresstion into a Rectangle object
- Args:
exp (list): Part of parsed S-Expression
(rectangle ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not rectangle
- Returns:
Rectangle: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.Arc(start: ~kiutils.items.common.Position = <factory>, mid: ~kiutils.items.common.Position = <factory>, end: ~kiutils.items.common.Position = <factory>, stroke: ~kiutils.items.common.Stroke = <factory>, fill: ~kiutils.items.common.Fill = <factory>, uuid: str | None = None)
Bases:
objectThe
Arctoken defines a graphical arc in a schematic.Available since KiCad v7
- Documentation:
???
- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- classmethod from_sexpr(exp: list) Arc
Convert the given S-Expresstion into a Arc object
- Args:
exp (list): Part of parsed S-Expression
(arc ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not arc
- Returns:
Arc: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.Circle(center: ~kiutils.items.common.Position = <factory>, radius: float = 0.0, stroke: ~kiutils.items.common.Stroke = <factory>, fill: ~kiutils.items.common.Fill = <factory>, uuid: str | None = None)
Bases:
objectThe
Circletoken defines a graphical circle in a schematic.Available since KiCad v7
- Documentation:
???
- center: Position
The
centertoken attributes define the coordinates of the center point of the circle
- radius: float = 0.0
The
radiustoken attributes define the radius of the circle
- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- classmethod from_sexpr(exp: list) Circle
Convert the given S-Expresstion into a Circle object
- Args:
exp (list): Part of parsed S-Expression
(circle ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not circle
- Returns:
Circle: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.schitems.NetclassFlag(text: str = '', length: float = 2.54, shape: str = 'round', position: ~kiutils.items.common.Position = <factory>, effects: ~kiutils.items.common.Effects = <factory>, properties: ~typing.List[~kiutils.items.common.Property] = <factory>, uuid: str | None = None, fieldsAutoplaced: bool = False)
Bases:
objectThe
netclass_flagtoken defines a netclass flag in a schematic.Available since KiCad v7
- Documentation:
???
- text: str = ''
The
texttoken defines the text the netclass flag
- length: float = 2.54
The
lengthtoken defines the length of the netclass flag
- shape: str = 'round'
The
shapetoken defines the shape of the netclass flag. Valid values areround,rectangle,dotor``diamond``.
- properties: List[Property]
The
propertiestoken defines a list of properties the netclass is assigned to
- uuid: str | None = None
The optional
uuiddefines the universally unique identifier
- fieldsAutoplaced: bool = False
The
fields_autoplacedis a flag that indicates that any PROPERTIES associated with the netclas flag have been place automatically
- classmethod from_sexpr(exp: list) NetclassFlag
Convert the given S-Expresstion into a Circle object
- Args:
exp (list): Part of parsed S-Expression
(netclass_flag ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not netclass_flag
- Returns:
NetclassFlag: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
Symbol items (kiutils.items.syitems)
Symbol graphical items define all of the drawing items that are used in the symbol definition. This includes text, text boxes, lines, rectangles, circles, arcs, polygons and curves.
- Author:
Marvin Mager - @mvnmgrx - 2022
- License identifier:
GPL-3.0
- Major changes:
16.02.2022 - created
- Documentation taken from:
https://dev-docs.kicad.org/en/file-formats/sexpr-intro/index.html#_symbol_graphic_items
- class kiutils.items.syitems.SyArc(private: bool = False, start: ~kiutils.items.common.Position = <factory>, mid: ~kiutils.items.common.Position = <factory>, end: ~kiutils.items.common.Position = <factory>, stroke: ~kiutils.items.common.Stroke = <factory>, fill: ~kiutils.items.common.Fill = <factory>)
Bases:
objectThe
arctoken defines a graphical arc in a symbol definition.- private: bool = False
The
privatetoken defines if the arc is only visible in the symbol editor. Defaults toFalse.Available since KiCad v7
- classmethod from_sexpr(exp: list) SyArc
Convert the given S-Expresstion into a SyArc object
- Args:
exp (list): Part of parsed S-Expression
(arc ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not arc
- Returns:
SyArc: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 6, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 6.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.syitems.SyCircle(private: bool = False, center: ~kiutils.items.common.Position = <factory>, radius: float = 0.0, stroke: ~kiutils.items.common.Stroke = <factory>, fill: ~kiutils.items.common.Fill = <factory>)
Bases:
objectThe
circletoken defines a graphical circle in a symbol definition.- private: bool = False
The
privatetoken defines if the circle is only visible in the symbol editor. Defaults toFalse.Available since KiCad v7
- radius: float = 0.0
The
radiustoken defines the length of the radius of the circle
- classmethod from_sexpr(exp: list) SyCircle
Convert the given S-Expresstion into a SyCircle object
- Args:
exp (list): Part of parsed S-Expression
(circle ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not circle
- Returns:
SyCircle: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 6, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 6.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.syitems.SyCurve(points: ~typing.List[~kiutils.items.common.Position] = <factory>, stroke: ~kiutils.items.common.Stroke = <factory>, fill: ~kiutils.items.common.Fill = <factory>)
Bases:
objectThe
curvetoken defines a graphical Qubic Bezier curve.- points: List[Position]
The
pointstoken defines the four X/Y coordinates of each point of the curve
- classmethod from_sexpr(exp: list) SyCurve
Convert the given S-Expresstion into a SyCurve object
- Args:
exp (list): Part of parsed S-Expression
(curve ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not curve
- Returns:
SyCurve: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 6, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 6.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.syitems.SyPolyLine(points: ~typing.List[~kiutils.items.common.Position] = <factory>, stroke: ~kiutils.items.common.Stroke = <factory>, fill: ~kiutils.items.common.Fill = <factory>)
Bases:
objectThe
polylinetoken defines one or more graphical lines that may or may not define a polygon.- points: List[Position]
The
pointstoken defines the four X/Y coordinates of each point of the polyline
- classmethod from_sexpr(exp: list) SyPolyLine
Convert the given S-Expresstion into a SyPolyLine object
- Args:
exp (list): Part of parsed S-Expression
(polyline ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not polyline
- Returns:
SyPolyLine: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 6, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 6.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.syitems.SyRect(private: bool = False, start: ~kiutils.items.common.Position = <factory>, end: ~kiutils.items.common.Position = <factory>, stroke: ~kiutils.items.common.Stroke = <factory>, fill: ~kiutils.items.common.Fill = <factory>)
Bases:
objectThe
rectangletoken defines a graphical rectangle in a symbol definition.- private: bool = False
The
privatetoken defines if the rectangle is only visible in the symbol editor. Defaults toFalse.Available since KiCad v7
- start: Position
The
starttoken attributes define the coordinates of the start point of the rectangle
- classmethod from_sexpr(exp: list) SyRect
Convert the given S-Expresstion into a SyRect object
- Args:
exp (list): Part of parsed S-Expression
(rectangle ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not rectangle
- Returns:
SyRect: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 6, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 6.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.syitems.SyText(text: str = '', position: ~kiutils.items.common.Position = <factory>, effects: ~kiutils.items.common.Effects = <factory>)
Bases:
objectThe
texttoken defines a graphical text in a symbol definition.- text: str = ''
The
textattribute is a quoted string that defines the text
- classmethod from_sexpr(exp: list) SyText
Convert the given S-Expresstion into a SyText object
- Args:
exp (list): Part of parsed S-Expression
(text ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not text
- Returns:
SyText: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 6, newline: bool = True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 6.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
- class kiutils.items.syitems.SyTextBox(text: str = '', private: bool = False, position: ~kiutils.items.common.Position = <factory>, size: ~kiutils.items.common.Position = <factory>, stroke: ~kiutils.items.common.Stroke = <factory>, fill: ~kiutils.items.common.Fill = <factory>, effects: ~kiutils.items.common.Effects = <factory>, uuid: str | None = None)
Bases:
objectThe
text_boxtoken defines a text box inside a symbolAvailable since KiCad v7
- Documentation:
- text: str = ''
The
texttoken defines the text string
- private: bool = False
The
privatetoken defines if the text box is only visible in the symbol editor. Defaults toFalse.
- position: Position
The
positiontoken defines the X and Y coordinates and rotation angle of the text
- uuid: str | None = None
The optional
uuiddefines the universally unique identifier. Defaults toNone.
- classmethod from_sexpr(exp: list) SyTextBox
Convert the given S-Expresstion into a SyTextBox object
- Args:
exp (list): Part of parsed S-Expression
(text_box ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not text_box
- Returns:
SyTextBox: Object of the class initialized with the given S-Expression
- to_sexpr(indent=2, newline=True) str
Generate the S-Expression representing this object
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object
Zone items (kiutils.items.zones)
- The zone token defines a zone on the board or footprint. Zones serve two purposes in
KiCad: filled copper zones and keep out areas.
- Author:
Marvin Mager - @mvnmgrx - 2022
- License identifier:
GPL-3.0
- Major changes:
11.02.2022 - created
- Documentation taken from:
https://dev-docs.kicad.org/en/file-formats/sexpr-intro/index.html#_footprint_graphics_items
- class kiutils.items.zones.KeepoutSettings(tracks: str = 'allowed', vias: str = 'allowed', pads: str = 'allowed', copperpour: str = 'not-allowed', footprints: str = 'not-allowed')
Bases:
objectThe ``keepout `` token attributes define which objects should be kept out of the zone. This section only applies to keep out zones.
- Documentation:
https://dev-docs.kicad.org/en/file-formats/sexpr-intro/index.html#_zone_keep_out_settings
- tracks: str = 'allowed'
The
trackstoken attribute defines whether or not tracks should be excluded from the keep out area. Valid attributes areallowedandnot_allowed.
- vias: str = 'allowed'
The
viastoken attribute defines whether or not vias should be excluded from the keep out area. Valid attributes areallowedandnot_allowed.
- pads: str = 'allowed'
The
padstoken attribute defines whether or not pads should be excluded from the keep out area. Valid attributes areallowedandnot_allowed.
- copperpour: str = 'not-allowed'
The
copperpourtoken attribute defines whether or not copper pours should be excluded from the keep out area. Valid attributes areallowedandnot_allowed.
- footprints: str = 'not-allowed'
The
footprintstoken attribute defines whether or not footprints should be excluded from the keep out area. Valid attributes areallowedandnot_allowed.
- classmethod from_sexpr(exp: list) KeepoutSettings
Convert the given S-Expresstion into a KeepoutSettings object
- Args:
exp (list): Part of parsed S-Expression
(keepout ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not keepout
- Returns:
KeepoutSettings: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 0, newline: bool = False) str
Generate the S-Expression representing this object. When no coordinates are set in the curve, the resulting S-Expression will be left empty.
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 0.
newline (bool): Adds a newline to the end of the output. Defaults to False.
- Returns:
str: S-Expression of this object
- class kiutils.items.zones.FillSettings(yes: bool = False, mode: str | None = None, thermalGap: float | None = None, thermalBridgeWidth: float | None = None, smoothingStyle: str | None = None, smoothingRadius: float | None = None, islandRemovalMode: int | None = None, islandAreaMin: float | None = None, hatchThickness: float | None = None, hatchGap: float | None = None, hatchOrientation: float | None = None, hatchSmoothingLevel: int | None = None, hatchSmoothingValue: float | None = None, hatchBorderAlgorithm: int | None = None, hatchMinHoleArea: float | None = None)
Bases:
objectThe
filltoken attributes define how the zone is to be filled.- yes: bool = False
The
yestoken specifies if the zone should be filled. If not specified, the zone is not filled and no additional attributes are required.
- mode: str | None = None
The optional
modetoken attribute defines how the zone is filled. The only valid fill mode ishatched. When not defined, the fill mode is solid.
- thermalGap: float | None = None
The optional
thermalGaptoken attribute defines the distance from the zone to all pad thermal relief connections to the zone.
- thermalBridgeWidth: float | None = None
The optional
thermalBridgeWidthtoken attribute defines the spoke width for all pad thermal relief connection to the zone.
- smoothingStyle: str | None = None
The optional
smoothingStyletoken attributes define the style of corner smoothing. Valid smoothing styles arechamferandfillet
- smoothingRadius: float | None = None
The optional
smoothingRadiustoken attributes define the radius of corner smoothing
- islandRemovalMode: int | None = None
The optional
islandRemovalModetoken attribute defines the island removal mode. Valid island removal modes are: - 0: Always remove islands. - 1: Never remove islands. - 2: Minimum area island to allow.
- islandAreaMin: float | None = None
The optional
islandAreaMintoken attribute defines the minimum allowable zone island. This only valid when the remove islands mode is set to 2.
- hatchThickness: float | None = None
The optional
hatchThicknesstoken attribute defines the thickness for hatched fills
- hatchGap: float | None = None
The optional
hatchGaptoken attribute defines the distance between lines for hatched fills
- hatchOrientation: float | None = None
The optional
hatchOrientationtoken attribute defines the line angle for hatched fills
- hatchSmoothingLevel: int | None = None
The optional
hatchSmoothingLeveltoken attribute defines how hatch outlines are smoothed. Valid hatch smoothing levels are: - 0: No smoothing - 1: Fillet - 2: Arc minimum - 3: Arc maximum
- hatchSmoothingValue: float | None = None
The optional
hatchSmoothingValuetoken attribute defines the ratio between the hole and the chamfer/fillet size
- hatchBorderAlgorithm: int | None = None
The optional
hatchBorderAlgorithmtoken attribute defines the if the zone line thickness is used when performing a hatch fill. Valid values for the hatch border algorithm are: - 0: Use zone minimum thickness. - 1: Use hatch thickness.
- hatchMinHoleArea: float | None = None
The optional
hatchMinHoleAreatoken attribute defines the minimum area a hatch file hole can be
- classmethod from_sexpr(exp: list) FillSettings
Convert the given S-Expresstion into a FillSettings object
- Args:
exp (list): Part of parsed S-Expression
(fill ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not fill
- Returns:
FillSettings: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 0, newline: bool = False) str
Generate the S-Expression representing this object. When no coordinates are set in the curve, the resulting S-Expression will be left empty.
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 0.
newline (bool): Adds a newline to the end of the output. Defaults to False.
- Returns:
str: S-Expression of this object
- class kiutils.items.zones.ZonePolygon(coordinates: ~typing.List[~kiutils.items.common.Position] = <factory>)
Bases:
objectThe
polygontoken defines a list of coordinates that define part of a zone- coordinates: List[Position]
The
coordinatesdefines the list of polygon X/Y coordinates used to define the zone polygon
- classmethod from_sexpr(exp: list) ZonePolygon
Convert the given S-Expresstion into a ZonePolygon object
- Args:
exp (list): Part of parsed S-Expression
(polygon ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not polygon
- Returns:
ZonePolygon: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 4, newline: bool = True) str
Generate the S-Expression representing this object. When no coordinates are set in the polygon, the resulting S-Expression will be left empty.
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 4.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
- str: S-Expression of this object. If the polygon has no coordinates, an empty
expression is returned.
- class kiutils.items.zones.FilledPolygon(layer: str = 'F.Cu', island: bool = False, coordinates: ~typing.List[~kiutils.items.common.Position] = <factory>)
Bases:
objectThe
filled_polygontoken defines the polygons used to fill a zone- layer: str = 'F.Cu'
The
layertoken attribute defines the canonical layer the zone fill resides on
- island: bool = False
The
islandtoken’s definition has to be defined ..
- coordinates: List[Position]
The
coordinatesdefines the list of polygon X/Y coordinates used to fill the zone
- classmethod from_sexpr(exp: list) FilledPolygon
Convert the given S-Expresstion into a FilledPolygon object
- Args:
exp (list): Part of parsed S-Expression
(filled_polygon ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not filled_polygon
- Returns:
FilledPolygon: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 4, newline: bool = True) str
Generate the S-Expression representing this object. When no coordinates are set in the filled polygon, the resulting S-Expression will be left empty.
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 4.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
- str: S-Expression of this object. If the filled polygon has no coordinates, an empty
expression is returned.
- class kiutils.items.zones.FillSegments(layer: str = 'F.Cu', coordinates: ~typing.List[~kiutils.items.common.Position] = <factory>)
Bases:
object- The
fill_polygontoken defines the segments used to fill the zone. This is only used when loading boards prior to version 4 which filled zones with segments.
- Documentation:
https://dev-docs.kicad.org/en/file-formats/sexpr-intro/index.html#_zone_fill_segments
- layer: str = 'F.Cu'
The
layertoken attribute defines the canonical layer the zone fill resides on
- coordinates: List[Position]
The
coordinatesdefines the list of polygon X/Y coordinates used to fill the zone.
- classmethod from_sexpr(exp: list) FillSegments
Convert the given S-Expresstion into a FillSegments object
- Args:
exp (list): Part of parsed S-Expression
(fill_segments ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not fill_segments
- Returns:
FillSegments: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 4, newline: bool = True) str
Generate the S-Expression representing this object. When no coordinates are set in the curve, the resulting S-Expression will be left empty.
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 4.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Returns:
str: S-Expression of this object. If the fill segments has no coordinates, an empty expression is returned.
- The
- class kiutils.items.zones.Hatch(style: str = 'none', pitch: float = 0.0)
Bases:
objectData wrapper for Zone class hatching attribute
- style: str = 'none'
The
styletoken defines the style of the hatching. Valid hatch styles arenone,edgeandfull
- pitch: float = 0.0
The
pitchtoken defines the pitch of the hatch
- class kiutils.items.zones.Zone(locked: bool = False, net: int = 0, netName: str = 'unknown', layers: ~typing.List[str] = <factory>, tstamp: str | None = None, name: str | None = None, hatch: ~kiutils.items.zones.Hatch = <factory>, priority: int | None = None, connectPads: str | None = None, clearance: float = 0.254, minThickness: float = 0.254, filledAreasThickness: str | None = None, keepoutSettings: ~kiutils.items.zones.KeepoutSettings | None = None, fillSettings: ~kiutils.items.zones.FillSettings | None = None, polygons: ~typing.List[~kiutils.items.zones.ZonePolygon] = <factory>, filledPolygons: ~typing.List[~kiutils.items.zones.FilledPolygon] = <factory>, fillSegments: ~kiutils.items.zones.FillSegments | None = None)
Bases:
object- The
zonetoken defines a zone on the board or footprint. Zones serve two purposes in KiCad: filled copper zones and keep out areas.
- Documentation:
https://dev-docs.kicad.org/en/file-formats/sexpr-intro/index.html#_zone
- locked: bool = False
The
lockedtoken defines if the zone may be edited or not (Missing in KiCad docu as of 11.02.2022)
- net: int = 0
The
nettoken attribute defines by the net ordinal number which net in the nets section that the zone is part of
- netName: str = 'unknown'
The
net_nametoken attribute defines the name of the net if the zone is not a keep out area. The net name attribute will be an empty string if the zone is a keep out area.
- layers: List[str]
The
layerstoken define the canonical layer set the zone connects as a list of strings. When the zone only resides on one layer, the output ofself.to_sexpr()will change into(layer "xyz")instead of(layers ..)automatically.
- tstamp: str | None = None
The
tstamptoken defines the unique identifier of the zone object
- name: str | None = None
The optional
nametoken attribute defines the name of the zone if one has been assigned
- priority: int | None = None
The optional
priorityattribute defines the zone priority if it is not zero
- connectPads: str | None = None
The
connectPadstoken attributes define the pad connection type and clearance. Valid pad connection types arethru_hole_only,fullandno. If the pad connection type is not defined, thermal relief pad connections are used
- clearance: float = 0.254
The
clearancetoken defines the thermal relief for pad connections. The usage of this token is depending on the value ofconnectPads.
- minThickness: float = 0.254
The
minThicknesstoken attributed defines the minimum fill width allowed in the zone
- filledAreasThickness: str | None = None
The optional
filledAreasThicknessattribute no specifies if the zone like width is not used when determining the zone fill area. This is to maintain compatibility with older board files that included the line thickness when performing zone fills when it is not defined.
- keepoutSettings: KeepoutSettings | None = None
The optional
keepoutSettingssection defines the keep out items if the zone defines as a keep out area
- fillSettings: FillSettings | None = None
The optional
fillSettingssection defines how the zone is to be filled
- polygons: List[ZonePolygon]
The
polygontoken defines a list of zone polygons that define the shape of the zone
- filledPolygons: List[FilledPolygon]
The
filledPolygonstoken defines a list of filled polygons in the zone
- fillSegments: FillSegments | None = None
The optional
fillSegmentssection defines a list of track segments used to fill the zone
- classmethod from_sexpr(exp: list) Zone
Convert the given S-Expresstion into a Zone object
- Args:
exp (list): Part of parsed S-Expression
(zone ...)
- Raises:
Exception: When given parameter’s type is not a list
Exception: When the first item of the list is not zone
- Returns:
Zone: Object of the class initialized with the given S-Expression
- to_sexpr(indent: int = 2, newline: bool = True) str
Generate the S-Expression representing this object.
- Args:
indent (int): Number of whitespaces used to indent the output. Defaults to 2.
newline (bool): Adds a newline to the end of the output. Defaults to True.
- Raises:
Exception: When the zone has no elements in its layer list
- Returns:
str: S-Expression of this object.
- The