KicadModTree package¶
- KicadModTree.nodes package
- KicadModTree.nodes.base package
- KicadModTree.nodes.specialized package
- KicadModTree.nodes.specialized.PolygoneLine module
- KicadModTree.nodes.specialized.RectLine module
- KicadModTree.nodes.specialized.RectFill module
- KicadModTree.nodes.specialized.FilledRect module
- KicadModTree.nodes.specialized.PadArray module
- KicadModTree.nodes.specialized.Rotation module
- KicadModTree.nodes.specialized.Translation module
- KicadModTree.nodes.Footprint module
- KicadModTree.nodes.Node module
- KicadModTree.util package
KicadModTree.FileHandler module¶
-
class
KicadModTree.FileHandler.
FileHandler
(kicad_mod)[source]¶ Bases:
object
some basic methods to write footprints, and which is the base class of footprint writer implementations
Parameters: kicad_mod ( KicadModTree.Footprint
) – Main object representing the footprintExample: >>> from KicadModTree import * >>> kicad_mod = Footprint("example_footprint") >>> file_handler = KicadFileHandler(kicad_mod) # KicadFileHandler is a implementation of FileHandler >>> file_handler.writeFile('example_footprint.kicad_mod')
-
serialize
(**kwargs)[source]¶ Get a valid string representation of the footprint in the specified format
Example: >>> from KicadModTree import * >>> kicad_mod = Footprint("example_footprint") >>> file_handler = KicadFileHandler(kicad_mod) # KicadFileHandler is a implementation of FileHandler >>> print(file_handler.serialize())
-
writeFile
(filename, **kwargs)[source]¶ Write the output of FileHandler.serialize to a file
Parameters: filename ( str
) – path of the output fileExample: >>> from KicadModTree import * >>> kicad_mod = Footprint("example_footprint") >>> file_handler = KicadFileHandler(kicad_mod) # KicadFileHandler is a implementation of FileHandler >>> file_handler.writeFile('example_footprint.kicad_mod')
-
KicadModTree.KicadFileHandler module¶
-
class
KicadModTree.KicadFileHandler.
KicadFileHandler
(kicad_mod)[source]¶ Bases:
KicadModTree.FileHandler.FileHandler
Implementation of the FileHandler for .kicad_mod files
Parameters: kicad_mod ( KicadModTree.Footprint
) – Main object representing the footprintExample: >>> from KicadModTree import * >>> kicad_mod = Footprint("example_footprint") >>> file_handler = KicadFileHandler(kicad_mod) >>> file_handler.writeFile('example_footprint.kicad_mod')
-
serialize
(**kwargs)[source]¶ Get a valid string representation of the footprint in the .kicad_mod format
Example: >>> from KicadModTree import * >>> kicad_mod = Footprint("example_footprint") >>> file_handler = KicadFileHandler(kicad_mod) >>> print(file_handler.serialize())
-
writeFile
(filename, **kwargs)¶ Write the output of FileHandler.serialize to a file
Parameters: filename ( str
) – path of the output fileExample: >>> from KicadModTree import * >>> kicad_mod = Footprint("example_footprint") >>> file_handler = KicadFileHandler(kicad_mod) # KicadFileHandler is a implementation of FileHandler >>> file_handler.writeFile('example_footprint.kicad_mod')
-
KicadModTree.ModArgparser module¶
-
class
KicadModTree.ModArgparser.
ModArgparser
(footprint_function)[source]¶ Bases:
object
A general data loading class, which allows us to specify parts using .yml or .csv files.
Using this class allows us to seperate between the implementation of a footprint generator, and the data which represents a single footprint. To do so, we need to define which parameters are expected in those data-files.
To improve the usablity of this class, it is able to do type checks of provided parameters, as well as defining default values and do a simple check if a parameter can be considered as required or optional.
Parameters: footprint_function ( function reference
) – A function which is called for every footprint we want to generateExample: >>> from KicadModTree import * >>> def footprint_gen(args): ... print("create footprint: {}".format(args['name'])) ... >>> parser = ModArgparser(footprint_gen) >>> parser.add_parameter("name", type=str, required=True) # the root node of .yml files is parsed as name >>> parser.add_parameter("datasheet", type=str, required=False) >>> parser.add_parameter("courtyard", type=float, required=False, default=0.25) >>> parser.add_parameter("pincount", type=int, required=True) >>> parser.run() # now run our script which handles the whole part of parsing the files
-
add_parameter
(name, **kwargs)[source]¶ Add a parameter to the ModArgparser
Parameters: - name (
str
) – name of the argument - **kwargs – See below
Keyword Arguments: - type (
type
) – type of the argument - required (
bool
) – is the argument required or optional - default – a default value which is used when there is no value defined
Example: >>> from KicadModTree import * >>> def footprint_gen(args): ... print("create footprint: {}".format(args['name'])) ... >>> parser = ModArgparser(footprint_gen) >>> parser.add_parameter("name", type=str, required=True) # the root node of .yml files is parsed as name >>> parser.add_parameter("datasheet", type=str, required=False) >>> parser.add_parameter("courtyard", type=float, required=False, default=0.25)
- name (
-
run
()[source]¶ Execute the ModArgparser and run all tasks defined via the commandline arguments of this script
This method parses the commandline arguments to determine which actions to take. Beside of parsing .yml and .csv files, it also allows us to output example files.
>>> from KicadModTree import * >>> def footprint_gen(args): ... print("create footprint: {}".format(args['name'])) ... >>> parser = ModArgparser(footprint_gen) >>> parser.add_parameter("name", type=str, required=True) # the root node of .yml files is parsed as name >>> parser.run() # now run our script which handles the whole part of parsing the files
-
KicadModTree.Vector module¶
-
class
KicadModTree.Vector.
Vector2D
(coordinates=None, y=None)[source]¶ Bases:
object
Representation of a 2D Vector in space
Example: >>> from KicadModTree import * >>> Vector2D(0, 0) >>> Vector2D([0, 0]) >>> Vector2D((0, 0)) >>> Vector2D({'x': 0, 'y':0}) >>> Vector2D(Vector2D(0, 0))
-
__dict__
= dict_proxy({'_Vector2D__arithmetic_parse': <staticmethod object>, '__module__': 'KicadModTree.Vector', '__repr__': <function __repr__>, 'render': <function render>, '__isub__': <function __isub__>, '__str__': <function __str__>, 'from_polar': <staticmethod object>, '__div__': <function __div__>, '__truediv__': <function __truediv__>, 'round_to': <function round_to>, '__add__': <function __add__>, '__dict__': <attribute '__dict__' of 'Vector2D' objects>, '__ne__': <function __ne__>, '__eq__': <function __eq__>, '__init__': <function __init__>, '__weakref__': <attribute '__weakref__' of 'Vector2D' objects>, 'rotate': <function rotate>, '__getitem__': <function __getitem__>, '__mul__': <function __mul__>, 'distance_to': <function distance_to>, '__setitem__': <function __setitem__>, '__iadd__': <function __iadd__>, 'from_homogeneous': <staticmethod object>, 'to_homogeneous': <function to_homogeneous>, 'to_dict': <function to_dict>, 'to_polar': <function to_polar>, '__iter__': <function __iter__>, '__sub__': <function __sub__>, '__copy__': <function __copy__>, '__doc__': "Representation of a 2D Vector in space\n\n :Example:\n\n >>> from KicadModTree import *\n >>> Vector2D(0, 0)\n >>> Vector2D([0, 0])\n >>> Vector2D((0, 0))\n >>> Vector2D({'x': 0, 'y':0})\n >>> Vector2D(Vector2D(0, 0))\n ", '__len__': <function __len__>, '__neg__': <function __neg__>})¶
-
__init__
(coordinates=None, y=None)[source]¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
__module__
= 'KicadModTree.Vector'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
distance_to
(value)[source]¶ Distance between this and another point
Parameters: value – the other point Returns: distance between self and other point
-
static
from_homogeneous
(source)[source]¶ Recover 2d vector from its homogeneous representation
Params: - source (
Vector3D
) - 3d homogeneous representation
- source (
-
static
from_polar
(radius, angle, origin=(0, 0), use_degrees=True)[source]¶ Generate a vector from its polar representation
Params: - radius (
float
) - lenght of the vector
- radius (
- angle (
float
) - angle of the vector
- angle (
- origin (
Vector2D
) - origin point for polar conversion. default: (0, 0)
- origin (
- use_degrees (
boolean
) - angle in degrees. default:True
- use_degrees (
-
rotate
(angle, origin=(0, 0), use_degrees=True)[source]¶ Rotate vector around given origin
Params: - angle (
float
) - rotation angle
- angle (
- origin (
Vector2D
) - origin point for the rotation. default: (0, 0)
- origin (
- use_degrees (
boolean
) - rotation angle is given in degrees. default:True
- use_degrees (
-
-
class
KicadModTree.Vector.
Vector3D
(coordinates=None, y=None, z=None)[source]¶ Bases:
KicadModTree.Vector.Vector2D
Representation of a 3D Vector in space
Example: >>> from KicadModTree import * >>> Vector3D(0, 0, 0) >>> Vector3D([0, 0, 0]) >>> Vector3D((0, 0, 0)) >>> Vector3D({'x': 0, 'y':0, 'z':0}) >>> Vector3D(Vector2D(0, 0)) >>> Vector3D(Vector3D(0, 0, 0))
-
__init__
(coordinates=None, y=None, z=None)[source]¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
__module__
= 'KicadModTree.Vector'¶
-