footprint wizards: fixes and enhancements

This commit is contained in:
jean-pierre charras 2023-04-16 16:51:07 +02:00
parent b76ef8c7e2
commit 50502c450f
10 changed files with 43 additions and 18 deletions

View File

@ -132,7 +132,7 @@ class FPC_FootprintWizard(FootprintWizardBase.FootprintWizard):
self.draw.Line(-xstart, posy, -xend, yend) self.draw.Line(-xstart, posy, -xend, yend)
# set SMD attribute # set SMD attribute
self.module.SetAttributes(pcbnew.PAD_ATTRIB_SMD) self.module.SetAttributes(pcbnew.FP_SMD)
# vertical segment at left of the pad # vertical segment at left of the pad
xstart = xend xstart = xend

View File

@ -603,9 +603,10 @@ class FootprintWizardDrawingAids:
for i in range(0, len(pts) - 1): for i in range(0, len(pts) - 1):
self.Line(pts[i][0], pts[i][1], pts[i+1][0], pts[i+1][1]) self.Line(pts[i][0], pts[i][1], pts[i+1][0], pts[i+1][1])
if mirrorX is None and mirrorY is None:
_PolyLineInternal(pts) # original _PolyLineInternal(pts) # original
if mirrorX is not None and mirrorY is not None: elif mirrorX is not None and mirrorY is not None:
self.TransformFlip(mirrorX, mirrorY, self.flipBoth) # both self.TransformFlip(mirrorX, mirrorY, self.flipBoth) # both
_PolyLineInternal(pts) _PolyLineInternal(pts)
self.PopTransform() self.PopTransform()

View File

@ -163,7 +163,15 @@ class BGAWizard(FootprintWizardBase.FootprintWizard):
self.draw.Value(0, ypos, text_size) self.draw.Value(0, ypos, text_size)
self.draw.Reference(0, -ypos, text_size) self.draw.Reference(0, -ypos, text_size)
# Add a extra text (${REFERENCE}) on the F_Fab layer
extra_text = pcbnew.PCB_TEXT( self.module, pcbnew.PCB_TEXT.TEXT_is_DIVERS )
extra_text.SetLayer( pcbnew.F_Fab )
extra_text.SetPosition( pcbnew.VECTOR2I( 0, 0) )
extra_text.SetTextSize( pcbnew.VECTOR2I( text_size, text_size ) )
extra_text.SetText( "${REFERENCE}" )
self.module.Add( extra_text )
# set SMD attribute # set SMD attribute
self.module.SetAttributes(pcbnew.PAD_ATTRIB_SMD) self.module.SetAttributes(pcbnew.FP_SMD)
BGAWizard().register() BGAWizard().register()

View File

@ -136,7 +136,7 @@ class MicroMaTchWizard(FPWbase.FootprintWizard):
# Use value to fill the modules description # Use value to fill the modules description
desc = self.GetValue() desc = self.GetValue()
self.module.SetDescription(desc) self.module.SetDescription(desc)
self.module.SetAttributes(1) self.module.SetAttributes( pcbnew.FP_SMD )
# add in the pads # add in the pads
pad = self.GetPad() pad = self.GetPad()

View File

@ -1,4 +1,5 @@
# Copyright 2019-2020 Julian Fellinger # Copyright 2019-2020 Julian Fellinger
# Copyright (C) 2023 KiCad Developers.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -17,7 +18,6 @@
import FootprintWizardBase import FootprintWizardBase
import pcbnew import pcbnew
from pcbnew import *
class MutualcapButtonWizard(FootprintWizardBase.FootprintWizard): class MutualcapButtonWizard(FootprintWizardBase.FootprintWizard):
@ -55,10 +55,10 @@ class MutualcapButtonWizard(FootprintWizardBase.FootprintWizard):
# build a rectangular pad # build a rectangular pad
def smdRectPad(self,module,size,pos,name): def smdRectPad(self,module,size,pos,name):
pad = PAD(module) pad = pcbnew.PAD(module)
pad.SetSize(size) pad.SetSize(size)
pad.SetShape(PAD_SHAPE_RECT) pad.SetShape(pcbnew.PAD_SHAPE_RECT)
pad.SetAttribute(PAD_ATTRIB_SMD) pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD)
layerset = pcbnew.LSET() layerset = pcbnew.LSET()
layerset.AddLayer(pcbnew.F_Cu) layerset.AddLayer(pcbnew.F_Cu)
@ -86,7 +86,7 @@ class MutualcapButtonWizard(FootprintWizardBase.FootprintWizard):
clearance = oew/2 clearance = oew/2
###border h ###border h
self.module.SetLayer(F_Cu) self.module.SetLayer(pcbnew.F_Cu)
size_pad = pcbnew.VECTOR2I( w, oew ) size_pad = pcbnew.VECTOR2I( w, oew )
self.module.Add(self.smdRectPad(self.module,size_pad, self.module.Add(self.smdRectPad(self.module,size_pad,
pcbnew.VECTOR2I(0, (int)((-h/2)+oew/2) ), pcbnew.VECTOR2I(0, (int)((-h/2)+oew/2) ),
@ -129,8 +129,24 @@ class MutualcapButtonWizard(FootprintWizardBase.FootprintWizard):
self.draw.Value(0, h/2+textSize, textSize) self.draw.Value(0, h/2+textSize, textSize)
self.draw.Reference(0, -h/2-textSize, textSize) self.draw.Reference(0, -h/2-textSize, textSize)
# Add a extra text (${REFERENCE}) on the F_Fab layer
extra_text = pcbnew.PCB_TEXT( self.module, pcbnew.PCB_TEXT.TEXT_is_DIVERS )
extra_text.SetLayer( pcbnew.F_Fab )
extra_text.SetPosition( pcbnew.VECTOR2I( 0, 0) )
extra_text.SetTextSize( pcbnew.VECTOR2I( textSize, textSize ) )
extra_text.SetText( "${REFERENCE}" )
self.module.Add( extra_text )
#optionally draw silkscreen line around button #optionally draw silkscreen line around button
if(drawBox): if(drawBox):
self.draw.Box(0,0,w,h) self.draw.SetLayer( pcbnew.F_SilkS )
self.draw.SetLineThickness( pcbnew.FromMM( 0.12 ) ) #Default per KLC F5.3
self.draw.Box( 0, 0, w, h )
# draw coutyard around button
self.draw.SetLayer( pcbnew.F_CrtYd )
self.draw.SetLineThickness( pcbnew.FromMM( 0.05 ) ) #Default per KLC F5.3
margin = pcbnew.FromMM( 0.25 ) #Default per KLC F5.3
self.draw.Box( 0, 0, w + margin*2 , h + margin*2 )
MutualcapButtonWizard().register() MutualcapButtonWizard().register()

View File

@ -227,7 +227,7 @@ class QFNWizard(FootprintWizardBase.FootprintWizard):
self.draw.Reference(0, -text_offset, text_size) self.draw.Reference(0, -text_offset, text_size)
# set SMD attribute # set SMD attribute
self.module.SetAttributes(pcbnew.PAD_ATTRIB_SMD) self.module.SetAttributes(pcbnew.FP_SMD)
QFNWizard().register() QFNWizard().register()

View File

@ -166,6 +166,6 @@ class QFPWizard(FootprintWizardBase.FootprintWizard):
self.draw.Reference(0, -text_offset, text_size) self.draw.Reference(0, -text_offset, text_size)
# set SMD attribute # set SMD attribute
self.module.SetAttributes(pcbnew.PAD_ATTRIB_SMD) self.module.SetAttributes(pcbnew.FP_SMD)
QFPWizard().register() QFPWizard().register()

View File

@ -132,9 +132,9 @@ class RowedFootprint(FootprintWizardBase.FootprintWizard):
# set the attribute # set the attribute
if self.GetName() == "S-DIP": if self.GetName() == "S-DIP":
self.module.SetAttributes(pcbnew.PAD_ATTRIB_PTH) self.module.SetAttributes(pcbnew.FP_PTH)
elif self.GetName() == "SOIC": elif self.GetName() == "SOIC":
self.module.SetAttributes(pcbnew.PAD_ATTRIB_SMD) self.module.SetAttributes(pcbnew.FP_SMD)
class SDIPWizard(RowedFootprint): class SDIPWizard(RowedFootprint):

View File

@ -187,7 +187,7 @@ class TouchSliderWizard(FootprintWizardBase.FootprintWizard):
self.draw.Reference(0, -ypos, t_size) self.draw.Reference(0, -ypos, t_size)
# set SMD attribute # set SMD attribute
self.module.SetAttributes(PAD_ATTRIB_SMD) self.module.SetAttributes(FP_SMD)
# starting pad # starting pad
band_width = touch_width/bands band_width = touch_width/bands

View File

@ -113,9 +113,9 @@ class RowedFootprint(FootprintWizardBase.FootprintWizard):
# set SMD attribute # set SMD attribute
if self.GetName() == "ZIP": if self.GetName() == "ZIP":
self.module.SetAttributes(pcbnew.PAD_ATTRIB_PTH) self.module.SetAttributes(pcbnew.FP_PTH)
elif self.GetName() == "ZOIC": elif self.GetName() == "ZOIC":
self.module.SetAttributes(pcbnew.PAD_ATTRIB_SMD) self.module.SetAttributes(pcbnew.FP_SMD)
def DrawBox(self, sizex, sizey): def DrawBox(self, sizex, sizey):