Python and footprint wizard: fix issues and update to be compatible

with recent changes in Kicad code.
This commit is contained in:
jean-pierre charras 2023-04-15 10:30:33 +02:00
parent 4a3f77cd9d
commit 27ebba6b33
7 changed files with 22 additions and 25 deletions

View File

@ -49,7 +49,6 @@ class FPC_FootprintWizard(FootprintWizardBase.FootprintWizard):
pad.SetShape(pcbnew.PAD_SHAPE_RECT) pad.SetShape(pcbnew.PAD_SHAPE_RECT)
pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD) pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD)
pad.SetLayerSet( pad.SMDMask() ) pad.SetLayerSet( pad.SMDMask() )
pad.SetPos0(pos)
pad.SetPosition(pos) pad.SetPosition(pos)
pad.SetName(name) pad.SetName(name)
return pad return pad

View File

@ -486,7 +486,7 @@ class FootprintWizardDrawingAids:
"""! """!
Draw a line from (x1, y1) to (x2, y2) Draw a line from (x1, y1) to (x2, y2)
""" """
outline = pcbnew.FP_SHAPE(self.module) outline = pcbnew.PCB_SHAPE(self.module)
outline.SetWidth(self.GetLineThickness()) outline.SetWidth(self.GetLineThickness())
outline.SetLayer(self.GetLayer()) outline.SetLayer(self.GetLayer())
outline.SetShape(pcbnew.S_SEGMENT) outline.SetShape(pcbnew.S_SEGMENT)
@ -508,7 +508,7 @@ class FootprintWizardDrawingAids:
DC line thickness DC line thickness
""" """
circle = pcbnew.FP_SHAPE(self.module) circle = pcbnew.PCB_SHAPE(self.module)
start = self.TransformPoint(x, y) start = self.TransformPoint(x, y)
if filled: if filled:
@ -548,7 +548,7 @@ class FootprintWizardDrawingAids:
@param sy: the y coordinate of the arc start point @param sy: the y coordinate of the arc start point
@param angle: the arc's central angle (in deci-degrees) @param angle: the arc's central angle (in deci-degrees)
""" """
arc = pcbnew.FP_SHAPE(self.module) arc = pcbnew.PCB_SHAPE(self.module)
arc.SetShape(pcbnew.SHAPE_T_ARC) arc.SetShape(pcbnew.SHAPE_T_ARC)
arc.SetWidth(self.dc['lineThickness']) arc.SetWidth(self.dc['lineThickness'])
@ -564,7 +564,7 @@ class FootprintWizardDrawingAids:
arc.SetCenter(center) arc.SetCenter(center)
arc.SetStart(start) arc.SetStart(start)
arc.SetArcAngleAndEnd(angle, True) arc.SetArcAngleAndEnd(angle, True)
arc.SetLocalCoord() #arc.SetLocalCoord()
self.module.Add(arc) self.module.Add(arc)
def HLine(self, x, y, l): def HLine(self, x, y, l):
@ -635,9 +635,7 @@ class FootprintWizardDrawingAids:
text_size = pcbnew.VECTOR2I(size, size) text_size = pcbnew.VECTOR2I(size, size)
self.module.Reference().SetPos0(self.TransformPoint(x, y)) self.module.Reference().SetPosition( self.TransformPoint(x, y) )
self.module.Reference().SetPosition(
self.module.Reference().GetPos0())
self.module.Reference().SetTextSize(text_size) self.module.Reference().SetTextSize(text_size)
self.module.Reference().SetTextAngle( pcbnew.EDA_ANGLE( orientation_degree, pcbnew.DEGREES_T ) ) self.module.Reference().SetTextAngle( pcbnew.EDA_ANGLE( orientation_degree, pcbnew.DEGREES_T ) )
@ -652,8 +650,7 @@ class FootprintWizardDrawingAids:
""" """
text_size = pcbnew.VECTOR2I(size, size) text_size = pcbnew.VECTOR2I(size, size)
self.module.Value().SetPos0(self.TransformPoint(x, y)) self.module.Value().SetPosition(self.TransformPoint(x, y))
self.module.Value().SetPosition(self.module.Value().GetPos0())
self.module.Value().SetTextSize(text_size) self.module.Value().SetTextSize(text_size)
self.module.Value().SetLayer(self.DefaultTextValueLayer()) self.module.Value().SetLayer(self.DefaultTextValueLayer())
self.module.Value().SetTextAngle( pcbnew.EDA_ANGLE( orientation_degree, pcbnew.DEGREES_T ) ) self.module.Value().SetTextAngle( pcbnew.EDA_ANGLE( orientation_degree, pcbnew.DEGREES_T ) )

View File

@ -156,7 +156,7 @@ class PadArray(object):
def AddPad(self, pad): def AddPad(self, pad):
"""! """!
Add a pad to the array, under the same moodule as the main Add a pad to the array, under the same footprint as the main
prototype pad prototype pad
@param pad: pad to add @param pad: pad to add
""" """
@ -175,7 +175,6 @@ class PadArray(object):
# create a new pad with same characteristics # create a new pad with same characteristics
pad = pad.Duplicate() pad = pad.Duplicate()
pad.SetPos0(pos)
pad.SetPosition(pos) pad.SetPosition(pos)
return pad return pad

View File

@ -64,7 +64,6 @@ class MutualcapButtonWizard(FootprintWizardBase.FootprintWizard):
layerset.AddLayer(pcbnew.F_Cu) layerset.AddLayer(pcbnew.F_Cu)
pad.SetLayerSet(layerset) pad.SetLayerSet(layerset)
pad.SetPos0(pos)
pad.SetPosition(pos) pad.SetPosition(pos)
pad.SetName(name) pad.SetName(name)
return pad return pad

View File

@ -66,8 +66,8 @@ class QRCodeWizard(FootprintWizardBase.FootprintWizard):
self.qr.make() self.qr.make()
def drawPixelSquareArea( self, layer, size, xposition, yposition): def drawPixelSquareArea( self, layer, size, xposition, yposition):
# creates a FP_SHAPE of rectangle type. The rectangle is square # creates a PCB_SHAPE of rectangle type. The rectangle is square
rectangle = pcbnew.FP_SHAPE(self.module) rectangle = pcbnew.PCB_SHAPE(self.module)
rectangle.SetShape(pcbnew.S_RECT) rectangle.SetShape(pcbnew.S_RECT)
rectangle.SetWidth( 0 ) rectangle.SetWidth( 0 )
rectangle.SetFilled( True ) rectangle.SetFilled( True )
@ -77,8 +77,6 @@ class QRCodeWizard(FootprintWizardBase.FootprintWizard):
rectangle.SetStartY( -halfsize+yposition ) rectangle.SetStartY( -halfsize+yposition )
rectangle.SetEndX( halfsize+xposition ) rectangle.SetEndX( halfsize+xposition )
rectangle.SetEndY( halfsize+yposition ) rectangle.SetEndY( halfsize+yposition )
rectangle.SetStart0( rectangle.GetStart() )
rectangle.SetEnd0( rectangle.GetEnd() )
return rectangle return rectangle
@ -90,7 +88,6 @@ class QRCodeWizard(FootprintWizardBase.FootprintWizard):
pad.SetSize(pcbnew.VECTOR2I(self.X, self.X)) pad.SetSize(pcbnew.VECTOR2I(self.X, self.X))
pad_pos = pcbnew.VECTOR2I(xposition,yposition) pad_pos = pcbnew.VECTOR2I(xposition,yposition)
pad.SetPosition(pad_pos) pad.SetPosition(pad_pos)
pad.SetPos0(pad_pos)
pad.SetShape(pcbnew.PAD_SHAPE_RECT) pad.SetShape(pcbnew.PAD_SHAPE_RECT)
pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD) pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD)
pad.SetName("") pad.SetName("")
@ -149,7 +146,6 @@ class QRCodeWizard(FootprintWizardBase.FootprintWizard):
textPosition = int((self.textHeight) + ((1 + half_number_of_elements) * self.X)) textPosition = int((self.textHeight) + ((1 + half_number_of_elements) * self.X))
pos = pcbnew.VECTOR2I(0, - textPosition) pos = pcbnew.VECTOR2I(0, - textPosition)
self.module.Value().SetPosition(pos) self.module.Value().SetPosition(pos)
self.module.Value().SetPos0(pos)
self.module.Value().SetTextHeight(self.textHeight) self.module.Value().SetTextHeight(self.textHeight)
self.module.Value().SetTextWidth(self.textWidth) self.module.Value().SetTextWidth(self.textWidth)
self.module.Value().SetTextThickness(self.textThickness) self.module.Value().SetTextThickness(self.textThickness)
@ -157,7 +153,6 @@ class QRCodeWizard(FootprintWizardBase.FootprintWizard):
# Add Reference field # Add Reference field
pos = pcbnew.VECTOR2I(0, textPosition) pos = pcbnew.VECTOR2I(0, textPosition)
self.module.Reference().SetPosition(pos) self.module.Reference().SetPosition(pos)
self.module.Reference().SetPos0(pos)
self.module.Reference().SetTextHeight(self.textHeight) self.module.Reference().SetTextHeight(self.textHeight)
self.module.Reference().SetTextWidth(self.textWidth) self.module.Reference().SetTextWidth(self.textWidth)
self.module.Reference().SetTextThickness(self.textThickness) self.module.Reference().SetTextThickness(self.textThickness)

View File

@ -66,7 +66,6 @@ class TouchSliderWizard(FootprintWizardBase.FootprintWizard):
pad.SetShape(PAD_SHAPE_RECT) pad.SetShape(PAD_SHAPE_RECT)
pad.SetAttribute(PAD_ATTRIB_SMD) pad.SetAttribute(PAD_ATTRIB_SMD)
pad.SetLayerSet(pad.ConnSMDMask()) pad.SetLayerSet(pad.ConnSMDMask())
pad.SetPos0(pos)
pad.SetPosition(pos) pad.SetPosition(pos)
pad.SetName(name) pad.SetName(name)
return pad return pad
@ -78,7 +77,6 @@ class TouchSliderWizard(FootprintWizardBase.FootprintWizard):
pad.SetShape(PAD_SHAPE_TRAPEZOID) pad.SetShape(PAD_SHAPE_TRAPEZOID)
pad.SetAttribute(PAD_ATTRIB_SMD) pad.SetAttribute(PAD_ATTRIB_SMD)
pad.SetLayerSet(pad.ConnSMDMask()) pad.SetLayerSet(pad.ConnSMDMask())
pad.SetPos0(pos)
pad.SetPosition(pos) pad.SetPosition(pos)
pad.SetName(name) pad.SetName(name)
pad.SetDelta(VECTOR2I(left_right*size[1],up_down*size[0])) pad.SetDelta(VECTOR2I(left_right*size[1],up_down*size[0]))

View File

@ -166,15 +166,25 @@ static PCB_BITMAP* Cast_to_PCB_BITMAP( BOARD_ITEM* );
else: else:
raise TypeError("Unsupported drawing class: %s" % ct) raise TypeError("Unsupported drawing class: %s" % ct)
"""
Needed to cast BOARD_ITEM::Duplicate() to the suitable type
"""
def Duplicate(self):
ct = self.GetClass()
if ct=="BOARD":
return None
else:
return Cast_to_BOARD_ITEM( _pcbnew.BOARD_ITEM_Duplicate(self) ).Cast()
def SetPos(self,p): def SetPos(self,p):
self.SetPosition(p) self.SetPosition(p)
self.SetPos0(p) #self.SetPos0(p)
def SetStartEnd(self,start,end): def SetStartEnd(self,start,end):
self.SetStart(start) self.SetStart(start)
self.SetStart0(start) #self.SetStart0(start)
self.SetEnd(end) self.SetEnd(end)
self.SetEnd0(end) #self.SetEnd0(end)
%} %}
} }