KiCad Pcbnew Python Scripting
|
Collection of handy functions to simplify drawing shapes from within footprint wizards. More...
Public Member Functions | |
def | DefaultGraphicLayer (self) |
def | DefaultTextValueLayer (self) |
def | __init__ (self, module) |
def | PushTransform (self, mat) |
Add a transform to the top of the stack and recompute the overall transform. More... | |
def | PopTransform (self, num=1) |
Remove a transform from the top of the stack and recompute the overall transform. More... | |
def | ResetTransform (self) |
Reset the transform stack to the identity matrix. More... | |
def | RecomputeTransforms (self) |
Re-compute the transform stack into a single transform and store in the DC. More... | |
def | TransformTranslate (self, x, y, push=True) |
Set up and return a transform matrix representing a translation optionally pushing onto the stack. More... | |
def | TransformFlipOrigin (self, flip, push=True) |
Set up and return a transform matrix representing a horizontal, vertical or both flip about the origin. More... | |
def | TransformFlip (self, x, y, flip=flipNone, push=True) |
Set up and return a transform matrix representing a horizontal, vertical or both flip about a point (x,y) More... | |
def | TransformRotationOrigin (self, rot, push=True) |
Set up and return a transform matrix representing a rotation about the origin, and optionally push onto the stack. More... | |
def | TransformRotation (self, x, y, rot, push=True) |
Set up and return a transform matrix representing a rotation about the point (x,y), and optionally push onto the stack. More... | |
def | TransformScaleOrigin (self, sx, sy=None, push=True) |
Set up and return a transform matrix representing a scale about the origin, and optionally push onto the stack. More... | |
def | TransformPoint (self, x, y, mat=None) |
Return a point (x, y) transformed by the given matrix, or if that is not given, the drawing context transform. More... | |
def | SetLineThickness (self, lineThickness) |
Set the current pen lineThickness used for subsequent drawing operations. More... | |
def | SetLineTickness (self, lineThickness) |
Old version of SetLineThickness. More... | |
def | GetLineThickness (self) |
Get the current drawing context line thickness. More... | |
def | SetLayer (self, layer) |
Set the current drawing layer, used for subsequent drawing operations. More... | |
def | GetLayer (self) |
Return the current drawing layer, used for drawing operations. More... | |
def | Line (self, x1, y1, x2, y2) |
Draw a line from (x1, y1) to (x2, y2) More... | |
def | Circle (self, x, y, r, filled=False) |
Draw a circle at (x,y) of radius r If filled is true, the thickness and radius of the line will be set such that the circle appears filled. More... | |
def | MyCmp (self, n1, n2) |
def | Arc (self, cx, cy, sx, sy, angle) |
Draw an arc based on centre, start and angle. More... | |
def | HLine (self, x, y, l) |
Draw a horizontal line from (x,y), rightwards. More... | |
def | VLine (self, x, y, l) |
Draw a vertical line from (x1,y1), downwards. More... | |
def | Polyline (self, pts, mirrorX=None, mirrorY=None) |
Draw a polyline, optionally mirroring around the given points. More... | |
def | Reference (self, x, y, size, orientation_degree=0) |
Draw the module's reference as the given point. More... | |
def | Value (self, x, y, size, orientation_degree=0) |
As for references, draw the module's value. More... | |
def | Box (self, x, y, w, h) |
Draw a rectangular box, centred at (x,y), with given width and height. More... | |
def | NotchedCircle (self, x, y, r, notch_w, notch_h, rotate=0) |
Circle radius r centred at (x, y) with a raised or depressed notch at the top Notch height is measured from the top of the circle radius. More... | |
def | NotchedBox (self, x, y, w, h, notchW, notchH, rotate=0) |
Draw a box with a notch in the centre of the top edge. More... | |
def | BoxWithDiagonalAtCorner (self, x, y, w, h, setback=pcbnew.FromMM(1.27), flip=flipNone) |
Draw a box with a diagonal at the top left corner. More... | |
def | BoxWithOpenCorner (self, x, y, w, h, setback=pcbnew.FromMM(1.27), flip=flipNone) |
Draw a box with an opening at the top left corner. More... | |
def | RoundedBox (self, x, y, w, h, rad) |
Draw a box with rounded corners (i.e. More... | |
def | ChamferedBox (self, x, y, w, h, chamfer_x, chamfer_y) |
Draw a box with chamfered corners. More... | |
def | MarkerArrow (self, x, y, direction=dirN, width=pcbnew.FromMM(1)) |
Draw a marker arrow facing in the given direction, with the point at (x,y) More... | |
Public Attributes | |
module | |
dc | |
Static Public Attributes | |
int | dirN = 0 |
int | dirNE = 45 |
int | dirE = 90 |
int | dirSE = 135 |
int | dirS = 180 |
int | dirSW = 225 |
int | dirW = 270 |
int | dirNW = 315 |
int | flipNone = 0 |
int | flipX = 1 |
int | flipY = 2 |
int | flipBoth = 3 |
list | xfrmIDENTITY = [1, 0, 0, 0, 1, 0] |
defaultLineThickness = pcbnew.FromMM(0.15) | |
Collection of handy functions to simplify drawing shapes from within footprint wizards.
A "drawing context" is provided which can be used to set and retain settings such as line thickness and layer. The DC also contains a "transform stack", which allows easy positioning and transforming of drawn elements without lots of geometric book-keeping.
Definition at line 180 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.__init__ | ( | self, | |
module | |||
) |
Definition at line 218 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.Arc | ( | self, | |
cx, | |||
cy, | |||
sx, | |||
sy, | |||
angle | |||
) |
Draw an arc based on centre, start and angle.
The transform matrix is applied
Note that this won't work properly if the result is not a circular arc (e.g. a horizontal scale)
cx | the x coordinate of the arc centre |
cy | the y coordinate of the arc centre |
sx | the x coordinate of the arc start point |
sy | the y coordinate of the arc start point |
angle | the arc's central angle (in deci-degrees) |
Definition at line 536 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.Box | ( | self, | |
x, | |||
y, | |||
w, | |||
h | |||
) |
Draw a rectangular box, centred at (x,y), with given width and height.
x | the x coordinate of the box's centre |
y | the y coordinate of the box's centre |
w | the width of the box |
h | the height of the box |
Definition at line 659 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.BoxWithDiagonalAtCorner | ( | self, | |
x, | |||
y, | |||
w, | |||
h, | |||
setback = pcbnew.FromMM(1.27) , |
|||
flip = flipNone |
|||
) |
Draw a box with a diagonal at the top left corner.
x | the x coordinate of the circle's centre |
y | the y coordinate of the circle's centre |
w | the width of the box |
h | the height of the box |
setback | the set-back of the diagonal, in both x and y |
flip | one of flipNone, flipX, flipY or flipBoth to change the diagonal corner |
Definition at line 748 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.BoxWithOpenCorner | ( | self, | |
x, | |||
y, | |||
w, | |||
h, | |||
setback = pcbnew.FromMM(1.27) , |
|||
flip = flipNone |
|||
) |
Draw a box with an opening at the top left corner.
x | the x coordinate of the circle's centre |
y | the y coordinate of the circle's centre |
w | the width of the box |
h | the height of the box |
setback | the set-back of the opening, in both x and y |
flip | one of flipNone, flipX, flipY or flipBoth to change the open corner position |
Definition at line 775 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.ChamferedBox | ( | self, | |
x, | |||
y, | |||
w, | |||
h, | |||
chamfer_x, | |||
chamfer_y | |||
) |
Draw a box with chamfered corners.
:param x: the x coordinate of the box's centre :param y: the y coordinate of the box's centre :param w: the width of the box :param h: the height of the box :param chamfer_x: the size of the chamfer set-back in the x direction :param chamfer_y: the size of the chamfer set-back in the y direction
Definition at line 837 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.Circle | ( | self, | |
x, | |||
y, | |||
r, | |||
filled = False |
|||
) |
Draw a circle at (x,y) of radius r If filled is true, the thickness and radius of the line will be set such that the circle appears filled.
x | the x coordinate of the arc centre |
y | the y coordinate of the arc centre |
r | the circle's radius |
filled | True to draw a filled circle, False to use the current DC line thickness |
Definition at line 498 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.DefaultGraphicLayer | ( | self | ) |
Definition at line 212 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.DefaultTextValueLayer | ( | self | ) |
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.GetLayer | ( | self | ) |
Return the current drawing layer, used for drawing operations.
Definition at line 479 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.GetLineThickness | ( | self | ) |
Get the current drawing context line thickness.
Definition at line 466 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.HLine | ( | self, | |
x, | |||
y, | |||
l | |||
) |
Draw a horizontal line from (x,y), rightwards.
x | line start x coordinate |
y | line start y coordinate |
l | line length |
Definition at line 570 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.Line | ( | self, | |
x1, | |||
y1, | |||
x2, | |||
y2 | |||
) |
Draw a line from (x1, y1) to (x2, y2)
Definition at line 485 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.MarkerArrow | ( | self, | |
x, | |||
y, | |||
direction = dirN , |
|||
width = pcbnew.FromMM(1) |
|||
) |
Draw a marker arrow facing in the given direction, with the point at (x,y)
x | x position of the arrow tip |
y | y position of the arrow tip |
direction | arrow direction in degrees (0 is "north", can use dir* shorthands) |
width | arrow width |
Definition at line 870 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.MyCmp | ( | self, | |
n1, | |||
n2 | |||
) |
replace the cmp() of python2
Definition at line 526 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.NotchedBox | ( | self, | |
x, | |||
y, | |||
w, | |||
h, | |||
notchW, | |||
notchH, | |||
rotate = 0 |
|||
) |
Draw a box with a notch in the centre of the top edge.
x | the x coordinate of the circle's centre |
y | the y coordinate of the circle's centre |
w | the width of the box |
h | the height of the box |
notchW | the width of the notch |
notchH | the height of the notch |
rotate | the rotation of the whole figure, in degrees |
Definition at line 714 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.NotchedCircle | ( | self, | |
x, | |||
y, | |||
r, | |||
notch_w, | |||
notch_h, | |||
rotate = 0 |
|||
) |
Circle radius r centred at (x, y) with a raised or depressed notch at the top Notch height is measured from the top of the circle radius.
x | the x coordinate of the circle's centre |
y | the y coordinate of the circle's centre |
r | the radius of the circle |
notch_w | the width of the notch |
notch_h | the height of the notch |
rotate | the rotation of the whole figure, in degrees |
Definition at line 678 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.Polyline | ( | self, | |
pts, | |||
mirrorX = None , |
|||
mirrorY = None |
|||
) |
Draw a polyline, optionally mirroring around the given points.
pts | list of polyline vertices (list of (x, y)) |
mirrorX | x coordinate of mirror point (None for no x-flip) |
mirrorY | y coordinate of mirror point (None for no y-flip) |
Definition at line 590 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.PopTransform | ( | self, | |
num = 1 |
|||
) |
Remove a transform from the top of the stack and recompute the overall transform.
num | the number of transforms to pop from the stack. |
Definition at line 238 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.PushTransform | ( | self, | |
mat | |||
) |
Add a transform to the top of the stack and recompute the overall transform.
mat | the transform matrix to add to the stack |
Definition at line 228 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.RecomputeTransforms | ( | self | ) |
Re-compute the transform stack into a single transform and store in the DC.
Definition at line 282 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.Reference | ( | self, | |
x, | |||
y, | |||
size, | |||
orientation_degree = 0 |
|||
) |
Draw the module's reference as the given point.
The actual setting of the reference is not done in this drawing aid - that is up to the wizard
x | the x position of the reference |
y | the y position of the reference |
size | the text size (in both directions) |
orientation_degree | text orientation in degrees |
Definition at line 624 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.ResetTransform | ( | self | ) |
Reset the transform stack to the identity matrix.
Definition at line 252 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.RoundedBox | ( | self, | |
x, | |||
y, | |||
w, | |||
h, | |||
rad | |||
) |
Draw a box with rounded corners (i.e.
a 90-degree circular arc)
:param x: the x coordinate of the box's centre :param y: the y coordinate of the box's centre :param w: the width of the box :param h: the height of the box :param rad: the radius of the corner rounds
Definition at line 802 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.SetLayer | ( | self, | |
layer | |||
) |
Set the current drawing layer, used for subsequent drawing operations.
Definition at line 472 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.SetLineThickness | ( | self, | |
lineThickness | |||
) |
Set the current pen lineThickness used for subsequent drawing operations.
lineThickness | the new line thickness to set |
Definition at line 445 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.SetLineTickness | ( | self, | |
lineThickness | |||
) |
Old version of SetLineThickness.
Does the same thing, but is only here for compatibility with old scripts. Set the current pen lineThickness used for subsequent drawing operations
lineThickness | the new line thickness to set |
Definition at line 454 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.TransformFlip | ( | self, | |
x, | |||
y, | |||
flip = flipNone , |
|||
push = True |
|||
) |
Set up and return a transform matrix representing a horizontal, vertical or both flip about a point (x,y)
This is performed by a translate-to-origin, flip, translate- back sequence.
x | the x coordinate of the flip point |
y | the y coordinate of the flip point |
flip | one of flipNone, flipX, flipY, flipBoth |
push | add this transform to the current stack |
Definition at line 334 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.TransformFlipOrigin | ( | self, | |
flip, | |||
push = True |
|||
) |
Set up and return a transform matrix representing a horizontal, vertical or both flip about the origin.
flip | one of flipNone, flipX, flipY, flipBoth |
push | add this transform to the current stack |
Definition at line 309 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.TransformPoint | ( | self, | |
x, | |||
y, | |||
mat = None |
|||
) |
Return a point (x, y) transformed by the given matrix, or if that is not given, the drawing context transform.
x | the x coordinate of the point to transform |
y | the y coordinate of the point to transform |
mat | the transform matrix to use or None to use the current DC's |
Definition at line 428 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.TransformRotation | ( | self, | |
x, | |||
y, | |||
rot, | |||
push = True |
|||
) |
Set up and return a transform matrix representing a rotation about the point (x,y), and optionally push onto the stack.
This is performed by a translate-to-origin, rotate, translate- back sequence
x | the x coordinate of the rotation centre |
y | the y coordinate of the rotation centre |
rot | the rotation angle in degrees |
push | add this transform to the current stack |
Definition at line 379 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.TransformRotationOrigin | ( | self, | |
rot, | |||
push = True |
|||
) |
Set up and return a transform matrix representing a rotation about the origin, and optionally push onto the stack.
( cos(t) -sin(t) 0 ) ( sin(t) cos(t) 0 )
rot | the rotation angle in degrees |
push | add this transform to the current stack |
Definition at line 359 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.TransformScaleOrigin | ( | self, | |
sx, | |||
sy = None , |
|||
push = True |
|||
) |
Set up and return a transform matrix representing a scale about the origin, and optionally push onto the stack.
( sx 0 0 ) ( 0 sy 0 )
sx | the scale factor in the x direction |
sy | the scale factor in the y direction |
push | add this transform to the current stack |
Definition at line 405 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.TransformTranslate | ( | self, | |
x, | |||
y, | |||
push = True |
|||
) |
Set up and return a transform matrix representing a translation optionally pushing onto the stack.
( 1 0 x ) ( 0 1 y )
x | translation in x-direction |
y | translation in y-direction |
push | add this transform to the current stack |
Definition at line 290 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.Value | ( | self, | |
x, | |||
y, | |||
size, | |||
orientation_degree = 0 |
|||
) |
As for references, draw the module's value.
x | the x position of the value |
y | the y position of the value |
size | the text size (in both directions) |
orientation_degree | text orientation in degrees |
Definition at line 643 of file FootprintWizardBase.py.
def plugins.FootprintWizardBase.FootprintWizardDrawingAids.VLine | ( | self, | |
x, | |||
y, | |||
l | |||
) |
Draw a vertical line from (x1,y1), downwards.
x | line start x coordinate |
y | line start y coordinate |
l | line length |
Definition at line 580 of file FootprintWizardBase.py.
plugins.FootprintWizardBase.FootprintWizardDrawingAids.dc |
Definition at line 221 of file FootprintWizardBase.py.
|
static |
Definition at line 210 of file FootprintWizardBase.py.
|
static |
Definition at line 194 of file FootprintWizardBase.py.
|
static |
Definition at line 192 of file FootprintWizardBase.py.
|
static |
Definition at line 193 of file FootprintWizardBase.py.
|
static |
Definition at line 199 of file FootprintWizardBase.py.
|
static |
Definition at line 196 of file FootprintWizardBase.py.
|
static |
Definition at line 195 of file FootprintWizardBase.py.
|
static |
Definition at line 197 of file FootprintWizardBase.py.
|
static |
Definition at line 198 of file FootprintWizardBase.py.
|
static |
Definition at line 205 of file FootprintWizardBase.py.
|
static |
Definition at line 202 of file FootprintWizardBase.py.
|
static |
Definition at line 203 of file FootprintWizardBase.py.
|
static |
Definition at line 204 of file FootprintWizardBase.py.
plugins.FootprintWizardBase.FootprintWizardDrawingAids.module |
Definition at line 219 of file FootprintWizardBase.py.
|
static |
Definition at line 207 of file FootprintWizardBase.py.