From f6023d22e44cc53e096edddea2ec2dffc4dd61a4 Mon Sep 17 00:00:00 2001 From: Christoph Riehl Date: Wed, 3 Jan 2018 17:11:27 +0100 Subject: [PATCH] Minor Python pad array improvement. Allow selection of square pads and allow to rotate the pads in the circular pad array wizard --- pcbnew/python/plugins/PadArray.py | 8 +++++++- pcbnew/python/plugins/circular_pad_array_wizard.py | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/pcbnew/python/plugins/PadArray.py b/pcbnew/python/plugins/PadArray.py index 3d7c0821d3..28b8d4bbb7 100644 --- a/pcbnew/python/plugins/PadArray.py +++ b/pcbnew/python/plugins/PadArray.py @@ -228,7 +228,7 @@ class PadLineArray(PadGridArray): class PadCircleArray(PadArray): def __init__(self, pad, n, r, angle_offset=0, centre=pcbnew.wxPoint(0, 0), - clockwise=True): + clockwise=True, padRotationEnable=False, padRotationOffset =0): PadArray.__init__(self) # this pad is more of a "context", we will use it as a source of # pad data, but not actually add it @@ -238,6 +238,8 @@ class PadCircleArray(PadArray): self.angle_offset = angle_offset self.centre = centre self.clockwise = clockwise + self.padRotationEnable = padRotationEnable + self.padRotationOffset = padRotationOffset # around the circle, CW or CCW according to the flag def NamingFunction(self, n): @@ -255,6 +257,10 @@ class PadCircleArray(PadArray): pos_y = -math.cos(angle * math.pi / 180) * self.r pos = dc.TransformPoint(pos_x, pos_y) pad = self.GetPad(pin == 0, pos) + padAngle = self.padRotationOffset + if self.padRotationEnable: + padAngle -=angle + pad.SetOrientation(padAngle*10) pad.SetName(self.GetName(pin)) self.AddPad(pad) diff --git a/pcbnew/python/plugins/circular_pad_array_wizard.py b/pcbnew/python/plugins/circular_pad_array_wizard.py index 42c08c9c7a..28ee00d03d 100644 --- a/pcbnew/python/plugins/circular_pad_array_wizard.py +++ b/pcbnew/python/plugins/circular_pad_array_wizard.py @@ -37,6 +37,11 @@ class circular_pad_array_wizard(FootprintWizardBase.FootprintWizard): self.AddParam("Pads", "diameter", self.uMM, 1.5) self.AddParam("Pads", "drill", self.uMM, 0.8) self.AddParam("Pads", "angle", self.uDegrees, 0, designator='a') + self.AddParam("Pads", "rectangle", self.uBool, False) + + + self.AddParam("Pad rotation", "pad rotation", self.uBool, False, designator='r') + self.AddParam("Pad rotation", "pad angle offset", self.uDegrees, 0, designator='o') self.AddParam("Numbering", "initial", self.uInteger, 1, min_value=1) #self.AddParam("Numbering", "increment", self.uInteger, 1, min_value=1) @@ -50,6 +55,7 @@ class circular_pad_array_wizard(FootprintWizardBase.FootprintWizard): pads = self.parameters['Pads'] numbering = self.parameters['Numbering'] outline = self.parameters['Outline'] + padRotation = self.parameters['Pad rotation'] # Check that pads do not overlap pad_dia = pcbnew.ToMM(pads['diameter']) @@ -73,16 +79,20 @@ class circular_pad_array_wizard(FootprintWizardBase.FootprintWizard): pads = self.parameters['Pads'] numbering = self.parameters['Numbering'] outline = self.parameters['Outline'] + padRotation = self.parameters['Pad rotation'] pad_size = pads['diameter'] + pad_shape = pcbnew.PAD_SHAPE_RECT if pads["rectangle"] else pcbnew.PAD_SHAPE_OVAL - pad = PA.PadMaker(self.module).THPad(pads['diameter'], pads['diameter'], pads['drill']) + pad = PA.PadMaker(self.module).THPad(pads['diameter'], pads['diameter'], pads['drill'], shape=pad_shape) array = PA.PadCircleArray( pad, pads['count'], pads['center diameter'] / 2, angle_offset=pads["angle"], centre=pcbnew.wxPoint(0, 0), - clockwise=numbering["clockwise"]) + clockwise=numbering["clockwise"], + padRotationEnable= padRotation["pad rotation"], + padRotationOffset = padRotation["pad angle offset"]) array.SetFirstPadInArray(numbering["initial"])