diff --git a/CircularZone/CircularZone.py b/CircularZone/CircularZone.py new file mode 100644 index 0000000..5c0a442 --- /dev/null +++ b/CircularZone/CircularZone.py @@ -0,0 +1,55 @@ +from math import * +import pcbnew +from CircularZoneDlg import CircularZoneDlg +import wx + + +class CircularZone(pcbnew.ActionPlugin): + + def defaults(self): + self.name = "Create a circular zone" + self.category = "Undefined" + self.description = "" + + def build(self, center_x, center_y, radius, keepout): + sp = pcbnew.SHAPE_POLY_SET() + sp.NewOutline() + cnt = 100 + for i in range(cnt): + x = int(center_x + radius * cos(i * 2 * pi / cnt)) + y = int(center_y + radius * sin(i * 2 * pi / cnt)) + sp.Append(x, y) + # sp.OutlineCount() + sp.thisown = 0 + zone = pcbnew.ZONE_CONTAINER(self.pcb) + zone.SetOutline(sp) + zone.SetLayer(pcbnew.F_Cu) + zone.SetIsKeepout(keepout) + zone.thisown = 0 + self.pcb.Add(zone) + + def Run(self): + self.pcb = pcbnew.GetBoard() + a = CircularZoneDlg(None) + x = 0 + y = 0 + reference = None + for module in self.pcb.GetModules(): + if module.IsSelected(): + x = module.GetPosition().x + y = module.GetPosition().y + reference = module.GetReference() + break + if reference is None: + a.m_comment.SetLabel("No reference position: start at origin") + else: + a.m_comment.SetLabel("Using %s as position reference" % reference) + + a.m_radiusMM.SetValue("10") + modal_result = a.ShowModal() + if modal_result == wx.ID_OK: + self.build(x, y, pcbnew.FromMM( + int(a.m_radiusMM.GetValue())), a.m_radio_out.GetValue()) + else: + print "Cancel" + a.Destroy() diff --git a/CircularZone/CircularZoneDlg.fbp b/CircularZone/CircularZoneDlg.fbp new file mode 100644 index 0000000..44e2e77 --- /dev/null +++ b/CircularZone/CircularZoneDlg.fbp @@ -0,0 +1,828 @@ + + + + + + Python + 1 + source_name + 0 + 0 + res + UTF-8 + connect + CircularZoneDlg + 1000 + none + 0 + CircularZoneDlg + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + CircularZoneDlg + + 373,219 + wxDEFAULT_DIALOG_STYLE + + Circular zone parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer3 + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + + 1 + m_comment + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + bSizer31 + wxHORIZONTAL + none + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Radius (mm) + + 0 + + + 0 + + 1 + m_staticText3 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + 1000,-1 + 1 + m_radiusMM + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxTextValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + wxID_ANY + Type of Zone + + sbSizer1 + wxVERTICAL + 1 + none + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Standard + + 0 + + + 0 + + 1 + m_radio_std + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Keepout + + 0 + + + 0 + + 1 + m_radio_out + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALIGN_RIGHT + 1 + + + bSizer1 + wxHORIZONTAL + none + + 5 + wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + + 1 + m_staticText101 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + + 1 + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_OK + Create + + 0 + + + 0 + + 1 + m_button1 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_CANCEL + Cancel + + 0 + + + 0 + + 1 + m_button2 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CircularZone/CircularZoneDlg.py b/CircularZone/CircularZoneDlg.py new file mode 100644 index 0000000..99867ca --- /dev/null +++ b/CircularZone/CircularZoneDlg.py @@ -0,0 +1,80 @@ +# -*- coding: utf-8 -*- + +########################################################################### +## Python code generated with wxFormBuilder (version Feb 16 2016) +## http://www.wxformbuilder.org/ +## +## PLEASE DO "NOT" EDIT THIS FILE! +########################################################################### + +import wx +import wx.xrc + +########################################################################### +## Class CircularZoneDlg +########################################################################### + +class CircularZoneDlg ( wx.Dialog ): + + def __init__( self, parent ): + wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Circular zone parameters", pos = wx.DefaultPosition, size = wx.Size( 373,219 ), style = wx.DEFAULT_DIALOG_STYLE ) + + self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) + + bSizer3 = wx.BoxSizer( wx.VERTICAL ) + + self.m_comment = wx.StaticText( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_comment.Wrap( -1 ) + bSizer3.Add( self.m_comment, 0, wx.ALL|wx.EXPAND, 5 ) + + bSizer31 = wx.BoxSizer( wx.HORIZONTAL ) + + self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, u"Radius (mm)", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText3.Wrap( -1 ) + bSizer31.Add( self.m_staticText3, 1, wx.ALL|wx.EXPAND, 5 ) + + self.m_radiusMM = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_radiusMM.SetMinSize( wx.Size( 1000,-1 ) ) + + bSizer31.Add( self.m_radiusMM, 1, wx.ALL|wx.EXPAND, 5 ) + + + bSizer3.Add( bSizer31, 0, wx.EXPAND, 5 ) + + sbSizer1 = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"Type of Zone" ), wx.VERTICAL ) + + self.m_radio_std = wx.RadioButton( sbSizer1.GetStaticBox(), wx.ID_ANY, u"Standard", wx.DefaultPosition, wx.DefaultSize, 0 ) + sbSizer1.Add( self.m_radio_std, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + + self.m_radio_out = wx.RadioButton( sbSizer1.GetStaticBox(), wx.ID_ANY, u"Keepout", wx.DefaultPosition, wx.DefaultSize, 0 ) + sbSizer1.Add( self.m_radio_out, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + + + bSizer3.Add( sbSizer1, 1, wx.EXPAND, 5 ) + + bSizer1 = wx.BoxSizer( wx.HORIZONTAL ) + + self.m_staticText101 = wx.StaticText( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText101.Wrap( -1 ) + bSizer1.Add( self.m_staticText101, 1, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, 5 ) + + self.m_button1 = wx.Button( self, wx.ID_OK, u"Create", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_button1.SetDefault() + bSizer1.Add( self.m_button1, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + + self.m_button2 = wx.Button( self, wx.ID_CANCEL, u"Cancel", wx.DefaultPosition, wx.DefaultSize, 0 ) + bSizer1.Add( self.m_button2, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + + + bSizer3.Add( bSizer1, 1, wx.EXPAND|wx.ALIGN_RIGHT, 5 ) + + + self.SetSizer( bSizer3 ) + self.Layout() + + self.Centre( wx.BOTH ) + + def __del__( self ): + pass + + diff --git a/CircularZone/__init__.py b/CircularZone/__init__.py new file mode 100644 index 0000000..7cd25fb --- /dev/null +++ b/CircularZone/__init__.py @@ -0,0 +1,3 @@ +from .CircularZone import * +CircularZone().register() +print "ici" diff --git a/README.md b/README.md index 54b8527..ac75a66 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,26 @@ interface. Then the result should be: ![The result](images/via2.png) + +## CircularZone + +A pure python script to create circular zone. + +Select a component. This composent will be used as center of the +circular zone. If no component is selected, the origin (0,0) will be +used as center. + +After select "Create a circular zone" in the Tools menu, choose the +radius and the type of zone (normal or keep out). + +![The interface](image/circular1.png) + +A circular zone will be created. Select it to change properties: + +![Select zone](image/circular2.png) + +![Open properties](image/circular3.png) + +Refill the area (B hotkey) then the circular zone is ready. + +![Final result](image/circular4.png) diff --git a/ViaStitching/FillArea.py b/ViaStitching/FillArea.py index af65484..6c042bb 100755 --- a/ViaStitching/FillArea.py +++ b/ViaStitching/FillArea.py @@ -372,7 +372,7 @@ class FillArea: self.PrintRect(rectangle) # Same job with existing text - for draw in self.pcb.m_Drawings: + for draw in self.pcb.DrawingsList(): if (draw.GetClass() == 'PTEXT' and self.pcb.GetLayerID(draw.GetLayerName()) in (F_Cu, B_Cu)): inter = float(self.clearance + self.size) diff --git a/ViaStitching/FillAreaAction.py b/ViaStitching/FillAreaAction.py index 2427d4e..e6a5468 100644 --- a/ViaStitching/FillAreaAction.py +++ b/ViaStitching/FillAreaAction.py @@ -22,13 +22,13 @@ import FillArea import wx import FillAreaDialog + class FillAreaDialogEx(FillAreaDialog.FillAreaDialog): - def onDeleteClick( self, event ): + def onDeleteClick(self, event): return self.EndModal(wx.ID_DELETE) - class FillAreaAction(pcbnew.ActionPlugin): def defaults(self): @@ -62,7 +62,7 @@ class FillAreaAction(pcbnew.ActionPlugin): fill.Run() except Exception: wx.MessageDialog(None, "Invalid parameter") - if modal_result == wx.ID_DELETE: + elif modal_result == wx.ID_DELETE: try: fill = FillArea.FillArea() if a.m_Debug.IsChecked(): diff --git a/images/circular1.png b/images/circular1.png new file mode 100644 index 0000000..051a896 Binary files /dev/null and b/images/circular1.png differ diff --git a/images/circular2.png b/images/circular2.png new file mode 100644 index 0000000..868d6ca Binary files /dev/null and b/images/circular2.png differ diff --git a/images/circular3.png b/images/circular3.png new file mode 100644 index 0000000..7222072 Binary files /dev/null and b/images/circular3.png differ diff --git a/images/circular4.png b/images/circular4.png new file mode 100644 index 0000000..c0081fd Binary files /dev/null and b/images/circular4.png differ