Minor Python pad array improvement.
Allow selection of square pads and allow to rotate the pads in the circular pad array wizard
This commit is contained in:
parent
b98f6a2fd1
commit
f6023d22e4
|
@ -228,7 +228,7 @@ class PadLineArray(PadGridArray):
|
||||||
class PadCircleArray(PadArray):
|
class PadCircleArray(PadArray):
|
||||||
|
|
||||||
def __init__(self, pad, n, r, angle_offset=0, centre=pcbnew.wxPoint(0, 0),
|
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)
|
PadArray.__init__(self)
|
||||||
# this pad is more of a "context", we will use it as a source of
|
# this pad is more of a "context", we will use it as a source of
|
||||||
# pad data, but not actually add it
|
# pad data, but not actually add it
|
||||||
|
@ -238,6 +238,8 @@ class PadCircleArray(PadArray):
|
||||||
self.angle_offset = angle_offset
|
self.angle_offset = angle_offset
|
||||||
self.centre = centre
|
self.centre = centre
|
||||||
self.clockwise = clockwise
|
self.clockwise = clockwise
|
||||||
|
self.padRotationEnable = padRotationEnable
|
||||||
|
self.padRotationOffset = padRotationOffset
|
||||||
|
|
||||||
# around the circle, CW or CCW according to the flag
|
# around the circle, CW or CCW according to the flag
|
||||||
def NamingFunction(self, n):
|
def NamingFunction(self, n):
|
||||||
|
@ -255,6 +257,10 @@ class PadCircleArray(PadArray):
|
||||||
pos_y = -math.cos(angle * math.pi / 180) * self.r
|
pos_y = -math.cos(angle * math.pi / 180) * self.r
|
||||||
pos = dc.TransformPoint(pos_x, pos_y)
|
pos = dc.TransformPoint(pos_x, pos_y)
|
||||||
pad = self.GetPad(pin == 0, pos)
|
pad = self.GetPad(pin == 0, pos)
|
||||||
|
padAngle = self.padRotationOffset
|
||||||
|
if self.padRotationEnable:
|
||||||
|
padAngle -=angle
|
||||||
|
pad.SetOrientation(padAngle*10)
|
||||||
pad.SetName(self.GetName(pin))
|
pad.SetName(self.GetName(pin))
|
||||||
self.AddPad(pad)
|
self.AddPad(pad)
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,11 @@ class circular_pad_array_wizard(FootprintWizardBase.FootprintWizard):
|
||||||
self.AddParam("Pads", "diameter", self.uMM, 1.5)
|
self.AddParam("Pads", "diameter", self.uMM, 1.5)
|
||||||
self.AddParam("Pads", "drill", self.uMM, 0.8)
|
self.AddParam("Pads", "drill", self.uMM, 0.8)
|
||||||
self.AddParam("Pads", "angle", self.uDegrees, 0, designator='a')
|
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", "initial", self.uInteger, 1, min_value=1)
|
||||||
#self.AddParam("Numbering", "increment", 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']
|
pads = self.parameters['Pads']
|
||||||
numbering = self.parameters['Numbering']
|
numbering = self.parameters['Numbering']
|
||||||
outline = self.parameters['Outline']
|
outline = self.parameters['Outline']
|
||||||
|
padRotation = self.parameters['Pad rotation']
|
||||||
|
|
||||||
# Check that pads do not overlap
|
# Check that pads do not overlap
|
||||||
pad_dia = pcbnew.ToMM(pads['diameter'])
|
pad_dia = pcbnew.ToMM(pads['diameter'])
|
||||||
|
@ -73,16 +79,20 @@ class circular_pad_array_wizard(FootprintWizardBase.FootprintWizard):
|
||||||
pads = self.parameters['Pads']
|
pads = self.parameters['Pads']
|
||||||
numbering = self.parameters['Numbering']
|
numbering = self.parameters['Numbering']
|
||||||
outline = self.parameters['Outline']
|
outline = self.parameters['Outline']
|
||||||
|
padRotation = self.parameters['Pad rotation']
|
||||||
|
|
||||||
pad_size = pads['diameter']
|
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(
|
array = PA.PadCircleArray(
|
||||||
pad, pads['count'], pads['center diameter'] / 2,
|
pad, pads['count'], pads['center diameter'] / 2,
|
||||||
angle_offset=pads["angle"],
|
angle_offset=pads["angle"],
|
||||||
centre=pcbnew.wxPoint(0, 0),
|
centre=pcbnew.wxPoint(0, 0),
|
||||||
clockwise=numbering["clockwise"])
|
clockwise=numbering["clockwise"],
|
||||||
|
padRotationEnable= padRotation["pad rotation"],
|
||||||
|
padRotationOffset = padRotation["pad angle offset"])
|
||||||
|
|
||||||
array.SetFirstPadInArray(numbering["initial"])
|
array.SetFirstPadInArray(numbering["initial"])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue