diff --git a/ViaStitching/FillArea.py b/ViaStitching/FillArea.py index 2b3e55c..97f09b3 100755 --- a/ViaStitching/FillArea.py +++ b/ViaStitching/FillArea.py @@ -77,9 +77,9 @@ class FillArea: # Step between via self.SetStepMM(2.54) # Size of the via (diameter of copper) - self.SetSizeMM(0.35) + self.SetSizeMM(0.46) # Size of the drill (diameter) - self.SetDrillMM(0.30) + self.SetDrillMM(0.20) # Isolation between via and other elements # ie: radius from the border of the via self.SetClearanceMM(0.2) @@ -93,6 +93,7 @@ class FillArea: self.netname = None self.debug = False self.random = False + self.star = False if self.netname is None: self.SetNetname("GND") @@ -112,6 +113,10 @@ class FillArea: self.random = True return self + def SetStar(self): + self.star = True + return self + def SetPCB(self, pcb): self.pcb = pcb if self.pcb is not None: @@ -156,36 +161,6 @@ class FillArea: print() print() - def PrepareFootprint(self): - """Don't use via since it's not possible to force a Net. - So use a fake footprint (only one THPad) - """ - self.tmp_dir = tempfile.mkdtemp(".pretty") - module_txt = """(module VIA_MATRIX (layer F.Cu) (tedit 5862471A) - (fp_text reference REF** (at 0 0) (layer F.SilkS) hide - (effects (font (size 0 0) (thickness 0.0))) - ) - (fp_text value VIA_MATRIX (at 0 0) (layer F.Fab) hide - (effects (font (size 0 0) (thickness 0.0))) - ) - (pad 1 thru_hole circle (at 0 0) (size 1.5 1.5) (drill 0.762) (layers *.Cu)) -)""" - - # Create the footprint on a temp directory - f = open(os.path.join(self.tmp_dir, "VIA_MATRIX.kicad_mod"), 'w') - f.write(module_txt) - f.close() - - plugin = IO_MGR.PluginFind( - IO_MGR.GuessPluginTypeFromLibPath(self.tmp_dir)) - module = plugin.FootprintLoad(self.tmp_dir, "VIA_MATRIX") - module.FindPadByName("1").SetSize(wxSize(self.size, self.size)) - module.FindPadByName("1").SetDrillSize(wxSize(self.drill, self.drill)) - module.FindPadByName("1").SetLocalClearance(int(self.clearance)) - module.FindPadByName("1").SetNet(self.pcb.FindNet(self.netname)) - module.FindPadByName("1").SetZoneConnection(PAD_ZONE_CONN_FULL) - return module - def CleanupFootprint(self): """ cleanup temp footprint @@ -193,16 +168,15 @@ class FillArea: if self.tmp_dir and os.path.isdir(self.tmp_dir): shutil.rmtree(self.tmp_dir) - def AddModule(self, module, position, x, y): - m = MODULE(module) + def AddVia(self, position, x, y): + m = VIA(self.pcb) m.SetPosition(position) - m.SetReference("V%s_%s" % (x, y)) - m.SetValue("AUTO_VIA") - m.SetLastEditTime() - m.SetAttributes(MOD_VIRTUAL) - m.thisown = 0 - self.pcb.AddNative(m, ADD_APPEND) - m.SetFlag(IS_NEW) + m.SetNet(self.pcb.FindNet(self.netname)) + m.SetViaType(VIA_THROUGH) + m.SetDrill(int(self.drill)) + m.SetWidth(int(self.size)) + m.SetTimeStamp(33) # USE 33 as timestamp to mark this via as generated + self.pcb.Add(m) def RefillBoardAreas(self): for i in range(self.pcb.GetAreaCount()): @@ -218,18 +192,18 @@ class FillArea: """ if self.delete_vias: - for module in self.pcb.GetModules(): - if self.debug: - print("* Deleting module: %s" % module.GetValue()) - if module.GetValue() == "AUTO_VIA": - self.pcb.RemoveNative(module) + for via in self.pcb.GetTracks(): + if via.Type() == PCB_VIA_T: + if via.GetTimeStamp() == 33: + if self.debug: + print("* Deleting via %u" % via.GetTimeStamp()) + self.pcb.RemoveNative(via) self.RefillBoardAreas() return # no need to run the rest of logic lboard = self.pcb.ComputeBoundingBox() rectangle = [] origin = lboard.GetPosition() - module = self.PrepareFootprint() # Create an initial rectangle: all is off # get a margin to avoid out of range @@ -265,7 +239,7 @@ class FillArea: for y in range(rectangle[0].__len__()): for x in range(rectangle.__len__()): testResult = not keepOutMode # = False if is Keepout - offset = self.clearance + self.size / 2 + offset = (self.clearance) + self.size / 2 # For keepout area: Deny Via # For same net area: Allow if not denied by keepout current_x = origin.x + (x * self.step) @@ -404,9 +378,21 @@ class FillArea: (self.step / 4.0) ran_y = (random.random() * self.step / 2.0) - \ (self.step / 4.0) - self.AddModule( - module, wxPoint(origin.x + (self.step * x) + ran_x, - origin.y + (self.step * y) + ran_y), x, y) + if self.star: + if y % 2: + if ((x + 1) % 2): + self.AddVia( + wxPoint(origin.x + (self.step * x) + ran_x, + origin.y + (self.step * y) + ran_y), x, y) + else: + if (x % 2): + self.AddVia( + wxPoint(origin.x + (self.step * x) + ran_x, + origin.y + (self.step * y) + ran_y), x, y) + else: + self.AddVia( + wxPoint(origin.x + (self.step * x) + ran_x, + origin.y + (self.step * y) + ran_y), x, y) self.RefillBoardAreas() diff --git a/ViaStitching/FillAreaAction.py b/ViaStitching/FillAreaAction.py index c15ae77..8068745 100644 --- a/ViaStitching/FillAreaAction.py +++ b/ViaStitching/FillAreaAction.py @@ -38,11 +38,12 @@ class FillAreaAction(pcbnew.ActionPlugin): def Run(self): a = FillAreaDialogEx(None) - a.m_SizeMM.SetValue("0.35") + a.m_SizeMM.SetValue("0.46") a.m_StepMM.SetValue("2.54") - a.m_DrillMM.SetValue("0.3") + a.m_DrillMM.SetValue("0.2") a.m_Netname.SetValue("auto") a.m_ClearanceMM.SetValue("0.2") + a.m_Star.SetValue(True) modal_result = a.ShowModal() if modal_result == wx.ID_OK: fill = FillArea.FillArea() @@ -57,6 +58,8 @@ class FillAreaAction(pcbnew.ActionPlugin): fill.SetDebug() if a.m_Random.IsChecked(): fill.SetRandom() + if a.m_Star.IsChecked(): + fill.SetStar() if a.m_only_selected.IsChecked(): fill.OnlyOnSelectedArea() fill.Run() diff --git a/ViaStitching/FillAreaDialog.py b/ViaStitching/FillAreaDialog.py index 32f7ef1..42999e1 100644 --- a/ViaStitching/FillAreaDialog.py +++ b/ViaStitching/FillAreaDialog.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- ########################################################################### -## Python code generated with wxFormBuilder (version Feb 16 2016) +## Python code generated with wxFormBuilder (version Dec 21 2016) ## http://www.wxformbuilder.org/ ## ## PLEASE DO "NOT" EDIT THIS FILE! @@ -78,6 +78,13 @@ class FillAreaDialog ( wx.Dialog ): self.m_Random = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) fgSizer1.Add( self.m_Random, 0, wx.ALL, 5 ) + self.m_staticText42 = wx.StaticText( self, wx.ID_ANY, u"Star Pattern", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText42.Wrap( -1 ) + fgSizer1.Add( self.m_staticText42, 0, wx.ALL, 5 ) + + self.m_Star = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) + fgSizer1.Add( self.m_Star, 0, wx.ALL, 5 ) + self.m_staticText81 = wx.StaticText( self, wx.ID_ANY, u"Only under selected Zone", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText81.Wrap( -1 ) fgSizer1.Add( self.m_staticText81, 0, wx.ALL, 5 ) diff --git a/ViaStitching/FillAreaTpl.fbp b/ViaStitching/FillAreaTpl.fbp index 5701cfd..be9e913 100644 --- a/ViaStitching/FillAreaTpl.fbp +++ b/ViaStitching/FillAreaTpl.fbp @@ -1321,6 +1321,177 @@ + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Star Pattern + + 0 + + + 0 + + 1 + m_staticText42 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + + 1 + m_Star + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxALL