Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

Footprint Parameters

Oliver edited this page Sep 25, 2016 · 3 revisions

Each wizard defines a number of parameters which are used to construct the footpring. The parameters are organised into groups called Pages, and each parameter has the following properties:

Required Parameter Properties

Required properties must be specified for each wizard parameter, and are specified sequentially.

  • Page - The name of the Page that the parameter is associated with
  • Name - The name of the parameter
  • Units - The units of the parameter describe the parameter type
  • Default - The default value should be a sensible starting value

Optional Parameter Properties

Optional properties may be specified for a particular parameter, and can add further information or functionality to a parameter

  • designator - If specified, a designator can be used as short-hand when referencing a particular parameter. If specified, this designator is displayed next to the given parameter in the KiCad wizard screen.
  • min_value - If a minimum value is specified, then an error message will be displayed if the user-provided value is below this value. This functionality is only provided for parameters with numerical types
  • max_value - If a maximum value is specified, then an error message will be displayed if the user-provided value is above this value. This functionality is only provided for parameters with numerical types
  • multiple - If the multiple property is provided, then the given parameter is checked to ensure that it is an integer multiple of this value. This functionality is only provided for parameters with integer type

Parameter Units

Each parameter must have its units specified upon creation. The units of any given parameter determine how the parameter value is treated, and also change the data input allowed from the user. The allowable unit types are as follows:

  • uMM - Parameter value is a measure of linear distance, and is specified in millimeters
  • uMils - Parameter value is a measure of linear distance, and is specified in mils / thou
  • uFloat - Parameter value is a dimensionless floating-point number
  • uInteger - Parameter value is a dimensionless integer number
  • uBool - Parameter value is boolean (True / False)
  • uRadians - Parameter value is an angular measurement, specified in radians
  • uDegrees - Parameter value is an angular measurement, specified in degrees
  • uPercent - Parameter value is a floating point number, expressed as a percentage
  • uString - Parameter value is a raw string

Additionally, a "List" style parameter is available, where the user may select one option from a list of predefined options. These options must all be raw-string values. To specify this parameter type, a parameter can be provided with a list of strings in place of one of the unit types as specified above.

Parameter Creation

Parameter creation is handled within the GenerateParameterList function, and follows the (example) format specified below:

def GenerateParameterList(self):
    self.AddParam("Pads", "count", self.uInteger, 16, multiple=2, designator="n")
    self.AddParam("Pads", "width", self.uMM, 0.35, designator="W", min_value=0.25)
    self.AddParam("Pads", "length", self.uMM, 1.2, designator="H", max_value=2.75)
    self.AddParam("Pads", "shape", ["Rect", "Oval", "RoundRect"], "Rect")

Parameter Retrieval

Once the parameter values have been specified, the footprint is constructed in the BuildThisFootprint() function. It is here that the parameter values are used to build the footprint as specified.

Parameter values are accessed using a Python dictionary lookup. Using the pad width (as specified above) as an example, the actual value of the pad width is accessed as follows:

w = self.parameters["Pads"]["width"]

If multiple operations are to be performed using the various pad parameters, then a shortcut like the following can be used:

pads = self.parameters["Pads"]
w = pads["width"]
l = pads["length"]

The returned value is automatically converted to the correct Python type. For example, a parameter specified as uMM will have a float value returned.

These retrieved values are used to construct the footprint according to the particular rules of the footprint wizard.

Parameter Checking

The footprint wizard parameter values are automatically checked to ensure that the values match the specified units (e.g "three" is not a valid integer value). Additionally, extra options such as min_value are automatically checked after user data entry.

If there are extra checks that need to be performed after the user enters parameter data, this can be performed using the CheckParam() function.

When a new value is specified by the user, the CheckParameters() function in the wizard script is called. It is here that custom parameter checks can be performed. For example, we shall consider the case where the pad width must be less than the pad length.

length = self.parameters["Pads"]["length"]
self.CheckParam("Pads", "width", max_value=length)