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

Minimum Wizard Requirements

Oliver edited this page Sep 26, 2016 · 6 revisions

Each footprint wizard must subclass the FootprintWizard class which is found in the FootprintWizardBase module.

e.g.

import FootprintWizardBase

class ExampleWizard(FootprintWizardBase.FootprintWizard):
    # functions, etc

Additionally, there are six required functions that need to be implemented for the wizard:

GetName()

The GetName function simply returns the name of this footprint wizard (string type)

def GetName(self):
    return "ExampleWizard"

GetDescription()

The GetDescription function returns a long-form description of the wizard which will be displayed in the wizard selection window within KiCad

def GetDescription(self):
    return "Example wizard used to demonstrate how to make a wizard."

GetValue()

The GetValue function returns the value of the generated footprint. This must be a string value and typically the value will be dependent on one (or more) of the specified parameters. As an example, consider a very simple footprint which is a box of a given width and height (specified in millimeters):

def GetValue(self):
    return "SimpleBox_{w}x{h}mm".format(
        w = self.parameters["Shape"]["width"],
        h = self.parameters["Shape"]["height"])

GenerateParameterList()

This function is where the various footprint parameters are defined (see Footprint Parameters).

def GenerateParameterList(self):
    self.AddParam("Shape", "width", self.uMM, 3.75)
    self.AddParam("Shape", "height", self.uMM, 4.95)

    self.AddParam("PageB", "param3", self.uPercent, 33.05, min_value=20)

CheckParameters()

This function is used to perform any custom parameter checking required by the wizard. As an example, a simple test where the width should be no less than half the height:

def CheckParameters(self):
    h = self.parameters["Shape"]["height"]

    self.CheckParam("Shape", "width", min_value=h/2)

BuildThisFootprint()

This function is responsible for actually building the footprint based on the supplied parameter values. The available drawing tools should be used to simplify footprint specification.

Wizard Registration

Finally, after the Wizard class has been fully defined, the Wizard must be registered:

class ExampleWizard(FootprintWizardBase.FootprintWizard):
    # functions, etc

ExampleWizard().register()