← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Allow selection of square pads and allow to rotate the pads in the circular pad array wizard

 

Christoph,

I merged your patch into the master branch.  For future reference,
please follow the commit message policy[1] when submitting patches to
KiCad.  Thank you for your contribution.

Cheers,

Wayne

[1]: http://docs.kicad-pcb.org/doxygen/commit_messages.html

On 01/03/2018 11:24 AM, f4eru wrote:
> 
> ---
>  pcbnew/python/plugins/PadArray.py                  |  8 +++++++-
>  pcbnew/python/plugins/circular_pad_array_wizard.py | 14 ++++++++++++--
>  2 files changed, 19 insertions(+), 3 deletions(-)
> 
> 
> --------------2.7.4
> Content-Type: text/x-patch;
> name="0001-Allow-selection-of-square-pads-and-allow-to-rotate-t.patch"
> Content-Transfer-Encoding: 8bit
> Content-Disposition: attachment;
> filename="0001-Allow-selection-of-square-pads-and-allow-to-rotate-t.patch"
> 
> diff --git a/pcbnew/python/plugins/PadArray.py
> b/pcbnew/python/plugins/PadArray.py
> index 3d7c082..28b8d4b 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 42c08c9..28ee00d 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"])
> 
> 
> --------------2.7.4--
> 
> 
> 
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
> 


References