From c599385c8b37644a299d847e50594bc4f85ab276 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 16 Apr 2023 16:51:07 +0200 Subject: [PATCH] footprint wizards: fixes and enhancements From master branch --- pcbnew/python/plugins/FPC_wizard.py | 2 +- pcbnew/python/plugins/FootprintWizardBase.py | 5 ++-- pcbnew/python/plugins/bga_wizard.py | 10 ++++++- .../python/plugins/microMatch_connectors.py | 2 +- .../python/plugins/mutualcap_button_wizard.py | 28 +++++++++++++++---- pcbnew/python/plugins/qfn_wizard.py | 2 +- pcbnew/python/plugins/qfp_wizard.py | 2 +- pcbnew/python/plugins/sdip_wizard.py | 4 +-- pcbnew/python/plugins/touch_slider_wizard.py | 2 +- pcbnew/python/plugins/zip_wizard.py | 4 +-- 10 files changed, 43 insertions(+), 18 deletions(-) diff --git a/pcbnew/python/plugins/FPC_wizard.py b/pcbnew/python/plugins/FPC_wizard.py index 07e7b8473c..1382fe777c 100644 --- a/pcbnew/python/plugins/FPC_wizard.py +++ b/pcbnew/python/plugins/FPC_wizard.py @@ -133,7 +133,7 @@ class FPC_FootprintWizard(FootprintWizardBase.FootprintWizard): self.draw.Line(-xstart, posy, -xend, yend) # set SMD attribute - self.module.SetAttributes(pcbnew.PAD_ATTRIB_SMD) + self.module.SetAttributes(pcbnew.FP_SMD) # vertical segment at left of the pad xstart = xend diff --git a/pcbnew/python/plugins/FootprintWizardBase.py b/pcbnew/python/plugins/FootprintWizardBase.py index 51eebb0d93..1a3a727267 100644 --- a/pcbnew/python/plugins/FootprintWizardBase.py +++ b/pcbnew/python/plugins/FootprintWizardBase.py @@ -603,9 +603,10 @@ class FootprintWizardDrawingAids: for i in range(0, len(pts) - 1): self.Line(pts[i][0], pts[i][1], pts[i+1][0], pts[i+1][1]) - _PolyLineInternal(pts) # original + if mirrorX is None and mirrorY is None: + _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 _PolyLineInternal(pts) self.PopTransform() diff --git a/pcbnew/python/plugins/bga_wizard.py b/pcbnew/python/plugins/bga_wizard.py index e757de4453..13fdf5d69f 100644 --- a/pcbnew/python/plugins/bga_wizard.py +++ b/pcbnew/python/plugins/bga_wizard.py @@ -163,7 +163,15 @@ class BGAWizard(FootprintWizardBase.FootprintWizard): self.draw.Value(0, ypos, text_size) self.draw.Reference(0, -ypos, text_size) + # Add a extra text (${REFERENCE}) on the F_Fab layer + extra_text = pcbnew.FP_TEXT( self.module, pcbnew.FP_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 - self.module.SetAttributes(pcbnew.PAD_ATTRIB_SMD) + self.module.SetAttributes(pcbnew.FP_SMD) BGAWizard().register() diff --git a/pcbnew/python/plugins/microMatch_connectors.py b/pcbnew/python/plugins/microMatch_connectors.py index 27cda2ca29..26a7e794aa 100644 --- a/pcbnew/python/plugins/microMatch_connectors.py +++ b/pcbnew/python/plugins/microMatch_connectors.py @@ -136,7 +136,7 @@ class MicroMaTchWizard(FPWbase.FootprintWizard): # Use value to fill the modules description desc = self.GetValue() self.module.SetDescription(desc) - self.module.SetAttributes(1) + self.module.SetAttributes( pcbnew.FP_SMD ) # add in the pads pad = self.GetPad() diff --git a/pcbnew/python/plugins/mutualcap_button_wizard.py b/pcbnew/python/plugins/mutualcap_button_wizard.py index 9843a5b220..3c99570917 100644 --- a/pcbnew/python/plugins/mutualcap_button_wizard.py +++ b/pcbnew/python/plugins/mutualcap_button_wizard.py @@ -1,4 +1,5 @@ # Copyright 2019-2020 Julian Fellinger +# Copyright (C) 2023 KiCad Developers. # # 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 @@ -17,7 +18,6 @@ import FootprintWizardBase import pcbnew -from pcbnew import * class MutualcapButtonWizard(FootprintWizardBase.FootprintWizard): @@ -55,10 +55,10 @@ class MutualcapButtonWizard(FootprintWizardBase.FootprintWizard): # build a rectangular pad def smdRectPad(self,module,size,pos,name): - pad = PAD(module) + pad = pcbnew.PAD(module) pad.SetSize(size) - pad.SetShape(PAD_SHAPE_RECT) - pad.SetAttribute(PAD_ATTRIB_SMD) + pad.SetShape(pcbnew.PAD_SHAPE_RECT) + pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD) layerset = pcbnew.LSET() layerset.AddLayer(pcbnew.F_Cu) @@ -87,7 +87,7 @@ class MutualcapButtonWizard(FootprintWizardBase.FootprintWizard): clearance = oew/2 ###border h - self.module.SetLayer(F_Cu) + self.module.SetLayer(pcbnew.F_Cu) size_pad = pcbnew.VECTOR2I( w, oew ) self.module.Add(self.smdRectPad(self.module,size_pad, pcbnew.VECTOR2I(0, (int)((-h/2)+oew/2) ), @@ -130,8 +130,24 @@ class MutualcapButtonWizard(FootprintWizardBase.FootprintWizard): self.draw.Value(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.FP_TEXT( self.module, pcbnew.FP_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 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() diff --git a/pcbnew/python/plugins/qfn_wizard.py b/pcbnew/python/plugins/qfn_wizard.py index d2416893e0..cd652c1044 100644 --- a/pcbnew/python/plugins/qfn_wizard.py +++ b/pcbnew/python/plugins/qfn_wizard.py @@ -227,7 +227,7 @@ class QFNWizard(FootprintWizardBase.FootprintWizard): self.draw.Reference(0, -text_offset, text_size) # set SMD attribute - self.module.SetAttributes(pcbnew.PAD_ATTRIB_SMD) + self.module.SetAttributes(pcbnew.FP_SMD) QFNWizard().register() diff --git a/pcbnew/python/plugins/qfp_wizard.py b/pcbnew/python/plugins/qfp_wizard.py index 3959789278..17bfee9a4c 100644 --- a/pcbnew/python/plugins/qfp_wizard.py +++ b/pcbnew/python/plugins/qfp_wizard.py @@ -166,6 +166,6 @@ class QFPWizard(FootprintWizardBase.FootprintWizard): self.draw.Reference(0, -text_offset, text_size) # set SMD attribute - self.module.SetAttributes(pcbnew.PAD_ATTRIB_SMD) + self.module.SetAttributes(pcbnew.FP_SMD) QFPWizard().register() diff --git a/pcbnew/python/plugins/sdip_wizard.py b/pcbnew/python/plugins/sdip_wizard.py index b1a6af9c89..4af2c1eb54 100644 --- a/pcbnew/python/plugins/sdip_wizard.py +++ b/pcbnew/python/plugins/sdip_wizard.py @@ -132,9 +132,9 @@ class RowedFootprint(FootprintWizardBase.FootprintWizard): # set the attribute if self.GetName() == "S-DIP": - self.module.SetAttributes(pcbnew.PAD_ATTRIB_PTH) + self.module.SetAttributes(pcbnew.FP_THROUGH_HOLE) elif self.GetName() == "SOIC": - self.module.SetAttributes(pcbnew.PAD_ATTRIB_SMD) + self.module.SetAttributes(pcbnew.FP_SMD) class SDIPWizard(RowedFootprint): diff --git a/pcbnew/python/plugins/touch_slider_wizard.py b/pcbnew/python/plugins/touch_slider_wizard.py index e2fb27644f..c110d70eb4 100644 --- a/pcbnew/python/plugins/touch_slider_wizard.py +++ b/pcbnew/python/plugins/touch_slider_wizard.py @@ -189,7 +189,7 @@ class TouchSliderWizard(FootprintWizardBase.FootprintWizard): self.draw.Reference(0, -ypos, t_size) # set SMD attribute - self.module.SetAttributes(PAD_ATTRIB_SMD) + self.module.SetAttributes(FP_SMD) # starting pad band_width = touch_width/bands diff --git a/pcbnew/python/plugins/zip_wizard.py b/pcbnew/python/plugins/zip_wizard.py index a17b534637..92272b724d 100644 --- a/pcbnew/python/plugins/zip_wizard.py +++ b/pcbnew/python/plugins/zip_wizard.py @@ -113,9 +113,9 @@ class RowedFootprint(FootprintWizardBase.FootprintWizard): # set SMD attribute if self.GetName() == "ZIP": - self.module.SetAttributes(pcbnew.PAD_ATTRIB_PTH) + self.module.SetAttributes(pcbnew.FP_THROUGH_HOLE) elif self.GetName() == "ZOIC": - self.module.SetAttributes(pcbnew.PAD_ATTRIB_SMD) + self.module.SetAttributes(pcbnew.FP_SMD) def DrawBox(self, sizex, sizey):