Annular Checker & Snap2Grid update
This commit is contained in:
@ -45,7 +45,7 @@
|
|||||||
<property name="minimum_size"></property>
|
<property name="minimum_size"></property>
|
||||||
<property name="name">AnnularDlg</property>
|
<property name="name">AnnularDlg</property>
|
||||||
<property name="pos"></property>
|
<property name="pos"></property>
|
||||||
<property name="size">380,317</property>
|
<property name="size">533,529</property>
|
||||||
<property name="style">wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
<property name="style">wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
||||||
<property name="subclass"></property>
|
<property name="subclass"></property>
|
||||||
<property name="title">Annular Ring Checker</property>
|
<property name="title">Annular Ring Checker</property>
|
||||||
|
@ -17,7 +17,7 @@ import wx.xrc
|
|||||||
class AnnularDlg ( wx.Dialog ):
|
class AnnularDlg ( wx.Dialog ):
|
||||||
|
|
||||||
def __init__( self, parent ):
|
def __init__( self, parent ):
|
||||||
wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Annular Ring Checker", pos = wx.DefaultPosition, size = wx.Size( 380,317 ), style = wx.CAPTION|wx.CLOSE_BOX|wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER )
|
wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Annular Ring Checker", pos = wx.DefaultPosition, size = wx.Size( 533,529 ), style = wx.CAPTION|wx.CLOSE_BOX|wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER )
|
||||||
|
|
||||||
self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
|
self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@
|
|||||||
<property name="minimum_size"></property>
|
<property name="minimum_size"></property>
|
||||||
<property name="name">AnnularResultDlg</property>
|
<property name="name">AnnularResultDlg</property>
|
||||||
<property name="pos"></property>
|
<property name="pos"></property>
|
||||||
<property name="size">383,521</property>
|
<property name="size">539,659</property>
|
||||||
<property name="style">wxDEFAULT_DIALOG_STYLE</property>
|
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
||||||
<property name="subclass">; forward_declare</property>
|
<property name="subclass">; forward_declare</property>
|
||||||
<property name="title">Annular Checker</property>
|
<property name="title">Annular Checker</property>
|
||||||
<property name="tooltip"></property>
|
<property name="tooltip"></property>
|
||||||
@ -69,7 +69,7 @@
|
|||||||
<property name="permission">none</property>
|
<property name="permission">none</property>
|
||||||
<object class="sizeritem" expanded="1">
|
<object class="sizeritem" expanded="1">
|
||||||
<property name="border">5</property>
|
<property name="border">5</property>
|
||||||
<property name="flag">wxALL</property>
|
<property name="flag">wxALL|wxEXPAND</property>
|
||||||
<property name="proportion">0</property>
|
<property name="proportion">0</property>
|
||||||
<object class="wxStaticText" expanded="1">
|
<object class="wxStaticText" expanded="1">
|
||||||
<property name="BottomDockable">1</property>
|
<property name="BottomDockable">1</property>
|
||||||
@ -163,14 +163,14 @@
|
|||||||
<property name="max_size"></property>
|
<property name="max_size"></property>
|
||||||
<property name="maximize_button">0</property>
|
<property name="maximize_button">0</property>
|
||||||
<property name="maximum_size"></property>
|
<property name="maximum_size"></property>
|
||||||
<property name="min_size"></property>
|
<property name="min_size">-1,-1</property>
|
||||||
<property name="minimize_button">0</property>
|
<property name="minimize_button">0</property>
|
||||||
<property name="minimum_size">-1,400</property>
|
<property name="minimum_size">-1,400</property>
|
||||||
<property name="moveable">1</property>
|
<property name="moveable">1</property>
|
||||||
<property name="name">m_richTextResult</property>
|
<property name="name">m_richTextResult</property>
|
||||||
<property name="pane_border">1</property>
|
<property name="pane_border">1</property>
|
||||||
<property name="pane_position"></property>
|
<property name="pane_position"></property>
|
||||||
<property name="pane_size"></property>
|
<property name="pane_size">-1,-1</property>
|
||||||
<property name="permission">protected</property>
|
<property name="permission">protected</property>
|
||||||
<property name="pin_button">1</property>
|
<property name="pin_button">1</property>
|
||||||
<property name="pos"></property>
|
<property name="pos"></property>
|
||||||
@ -192,7 +192,7 @@
|
|||||||
</object>
|
</object>
|
||||||
<object class="sizeritem" expanded="1">
|
<object class="sizeritem" expanded="1">
|
||||||
<property name="border">5</property>
|
<property name="border">5</property>
|
||||||
<property name="flag">wxEXPAND</property>
|
<property name="flag">wxALIGN_TOP|wxEXPAND</property>
|
||||||
<property name="proportion">1</property>
|
<property name="proportion">1</property>
|
||||||
<object class="wxGridSizer" expanded="1">
|
<object class="wxGridSizer" expanded="1">
|
||||||
<property name="cols">2</property>
|
<property name="cols">2</property>
|
||||||
|
@ -18,7 +18,7 @@ import wx.richtext
|
|||||||
class AnnularResultDlg ( wx.Dialog ):
|
class AnnularResultDlg ( wx.Dialog ):
|
||||||
|
|
||||||
def __init__( self, parent ):
|
def __init__( self, parent ):
|
||||||
wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Annular Checker", pos = wx.DefaultPosition, size = wx.Size( 383,521 ), style = wx.DEFAULT_DIALOG_STYLE )
|
wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Annular Checker", pos = wx.DefaultPosition, size = wx.Size( 539,659 ), style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER )
|
||||||
|
|
||||||
self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
|
self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ class AnnularResultDlg ( wx.Dialog ):
|
|||||||
self.m_staticTitle = wx.StaticText( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
|
self.m_staticTitle = wx.StaticText( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||||
self.m_staticTitle.Wrap( -1 )
|
self.m_staticTitle.Wrap( -1 )
|
||||||
|
|
||||||
bSizer2.Add( self.m_staticTitle, 0, wx.ALL, 5 )
|
bSizer2.Add( self.m_staticTitle, 0, wx.ALL|wx.EXPAND, 5 )
|
||||||
|
|
||||||
self.m_richTextResult = wx.richtext.RichTextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_READONLY|wx.VSCROLL|wx.HSCROLL|wx.NO_BORDER|wx.WANTS_CHARS )
|
self.m_richTextResult = wx.richtext.RichTextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_READONLY|wx.VSCROLL|wx.HSCROLL|wx.NO_BORDER|wx.WANTS_CHARS )
|
||||||
self.m_richTextResult.SetMinSize( wx.Size( -1,400 ) )
|
self.m_richTextResult.SetMinSize( wx.Size( -1,400 ) )
|
||||||
@ -45,7 +45,7 @@ class AnnularResultDlg ( wx.Dialog ):
|
|||||||
gSizer3.Add( self.copy_btn, 0, wx.ALL, 5 )
|
gSizer3.Add( self.copy_btn, 0, wx.ALL, 5 )
|
||||||
|
|
||||||
|
|
||||||
bSizer2.Add( gSizer3, 1, wx.EXPAND, 5 )
|
bSizer2.Add( gSizer3, 1, wx.ALIGN_TOP|wx.EXPAND, 5 )
|
||||||
|
|
||||||
|
|
||||||
bSizer1.Add( bSizer2, 1, wx.EXPAND, 5 )
|
bSizer1.Add( bSizer2, 1, wx.EXPAND, 5 )
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
global mm_ius, DRL_EXTRA, AR_SET, AR_SET_V, DRL_EXTRA_ius, MIN_AR_SIZE, MIN_AR_SIZE_V, found_violations, LogMsg, ___version___
|
global mm_ius, DRL_EXTRA, AR_SET, AR_SET_V, DRL_EXTRA_ius, MIN_AR_SIZE, MIN_AR_SIZE_V, found_violations, LogMsg, ___version___
|
||||||
|
|
||||||
___version___="1.6.3"
|
___version___="1.6.4"
|
||||||
|
|
||||||
#wx.LogMessage("My message")
|
#wx.LogMessage("My message")
|
||||||
mm_ius = 1000000.0
|
mm_ius = 1000000.0
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
<property name="minimum_size"></property>
|
<property name="minimum_size"></property>
|
||||||
<property name="name">Snap2GridDlg</property>
|
<property name="name">Snap2GridDlg</property>
|
||||||
<property name="pos"></property>
|
<property name="pos"></property>
|
||||||
<property name="size">499,394</property>
|
<property name="size">499,491</property>
|
||||||
<property name="style">wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
<property name="style">wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
||||||
<property name="subclass"></property>
|
<property name="subclass"></property>
|
||||||
<property name="title">Snap to Grid</property>
|
<property name="title">Snap to Grid</property>
|
||||||
@ -500,6 +500,70 @@
|
|||||||
<property name="window_style"></property>
|
<property name="window_style"></property>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="sizeritem" expanded="1">
|
||||||
|
<property name="border">5</property>
|
||||||
|
<property name="flag">wxALL</property>
|
||||||
|
<property name="proportion">0</property>
|
||||||
|
<object class="wxRadioButton" expanded="1">
|
||||||
|
<property name="BottomDockable">1</property>
|
||||||
|
<property name="LeftDockable">1</property>
|
||||||
|
<property name="RightDockable">1</property>
|
||||||
|
<property name="TopDockable">1</property>
|
||||||
|
<property name="aui_layer"></property>
|
||||||
|
<property name="aui_name"></property>
|
||||||
|
<property name="aui_position"></property>
|
||||||
|
<property name="aui_row"></property>
|
||||||
|
<property name="best_size"></property>
|
||||||
|
<property name="bg"></property>
|
||||||
|
<property name="caption"></property>
|
||||||
|
<property name="caption_visible">1</property>
|
||||||
|
<property name="center_pane">0</property>
|
||||||
|
<property name="close_button">1</property>
|
||||||
|
<property name="context_help"></property>
|
||||||
|
<property name="context_menu">1</property>
|
||||||
|
<property name="default_pane">0</property>
|
||||||
|
<property name="dock">Dock</property>
|
||||||
|
<property name="dock_fixed">0</property>
|
||||||
|
<property name="docking">Left</property>
|
||||||
|
<property name="enabled">1</property>
|
||||||
|
<property name="fg"></property>
|
||||||
|
<property name="floatable">1</property>
|
||||||
|
<property name="font"></property>
|
||||||
|
<property name="gripper">0</property>
|
||||||
|
<property name="hidden">0</property>
|
||||||
|
<property name="id">wxID_ANY</property>
|
||||||
|
<property name="label">Top Left (0,0)</property>
|
||||||
|
<property name="max_size"></property>
|
||||||
|
<property name="maximize_button">0</property>
|
||||||
|
<property name="maximum_size"></property>
|
||||||
|
<property name="min_size"></property>
|
||||||
|
<property name="minimize_button">0</property>
|
||||||
|
<property name="minimum_size"></property>
|
||||||
|
<property name="moveable">1</property>
|
||||||
|
<property name="name">m_radioBtnZero</property>
|
||||||
|
<property name="pane_border">1</property>
|
||||||
|
<property name="pane_position"></property>
|
||||||
|
<property name="pane_size"></property>
|
||||||
|
<property name="permission">protected</property>
|
||||||
|
<property name="pin_button">1</property>
|
||||||
|
<property name="pos"></property>
|
||||||
|
<property name="resize">Resizable</property>
|
||||||
|
<property name="show">1</property>
|
||||||
|
<property name="size"></property>
|
||||||
|
<property name="style"></property>
|
||||||
|
<property name="subclass">; ; forward_declare</property>
|
||||||
|
<property name="toolbar_pane">0</property>
|
||||||
|
<property name="tooltip"></property>
|
||||||
|
<property name="validator_data_type"></property>
|
||||||
|
<property name="validator_style">wxFILTER_NONE</property>
|
||||||
|
<property name="validator_type">wxDefaultValidator</property>
|
||||||
|
<property name="validator_variable"></property>
|
||||||
|
<property name="value">0</property>
|
||||||
|
<property name="window_extra_style"></property>
|
||||||
|
<property name="window_name"></property>
|
||||||
|
<property name="window_style"></property>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
<object class="sizeritem" expanded="1">
|
<object class="sizeritem" expanded="1">
|
||||||
<property name="border">5</property>
|
<property name="border">5</property>
|
||||||
<property name="flag">wxEXPAND | wxALL</property>
|
<property name="flag">wxEXPAND | wxALL</property>
|
||||||
|
@ -17,7 +17,7 @@ import wx.xrc
|
|||||||
class Snap2GridDlg ( wx.Dialog ):
|
class Snap2GridDlg ( wx.Dialog ):
|
||||||
|
|
||||||
def __init__( self, parent ):
|
def __init__( self, parent ):
|
||||||
wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Snap to Grid", pos = wx.DefaultPosition, size = wx.Size( 499,394 ), style = wx.CAPTION|wx.CLOSE_BOX|wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER )
|
wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Snap to Grid", pos = wx.DefaultPosition, size = wx.Size( 499,491 ), style = wx.CAPTION|wx.CLOSE_BOX|wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER )
|
||||||
|
|
||||||
self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
|
self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
|
||||||
|
|
||||||
@ -55,6 +55,9 @@ class Snap2GridDlg ( wx.Dialog ):
|
|||||||
self.m_radioBtnAO = wx.RadioButton( self, wx.ID_ANY, u"AuxOrigin reference", wx.DefaultPosition, wx.DefaultSize, 0 )
|
self.m_radioBtnAO = wx.RadioButton( self, wx.ID_ANY, u"AuxOrigin reference", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||||
bSizer3.Add( self.m_radioBtnAO, 0, wx.ALL, 5 )
|
bSizer3.Add( self.m_radioBtnAO, 0, wx.ALL, 5 )
|
||||||
|
|
||||||
|
self.m_radioBtnZero = wx.RadioButton( self, wx.ID_ANY, u"Top Left (0,0)", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||||
|
bSizer3.Add( self.m_radioBtnZero, 0, wx.ALL, 5 )
|
||||||
|
|
||||||
self.m_staticline2 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
|
self.m_staticline2 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
|
||||||
bSizer3.Add( self.m_staticline2, 0, wx.EXPAND |wx.ALL, 5 )
|
bSizer3.Add( self.m_staticline2, 0, wx.EXPAND |wx.ALL, 5 )
|
||||||
|
|
||||||
|
@ -9,10 +9,9 @@
|
|||||||
#import snaptogrid; import importlib; importlib.reload(snaptogrid)
|
#import snaptogrid; import importlib; importlib.reload(snaptogrid)
|
||||||
|
|
||||||
### plugins errors
|
### plugins errors
|
||||||
#import pcbnew
|
#import pcbnew;pcbnew.GetWizardsBackTrace()
|
||||||
#pcbnew.GetWizardsBackTrace()
|
|
||||||
|
|
||||||
__version__ = '1.0.2'
|
__version__ = '1.1.0'
|
||||||
import sys, os
|
import sys, os
|
||||||
import pcbnew
|
import pcbnew
|
||||||
import datetime
|
import datetime
|
||||||
@ -109,15 +108,17 @@ class snap_to_grid( pcbnew.ActionPlugin ):
|
|||||||
grid = aParameters.m_comboBoxGrid.GetStringSelection()
|
grid = aParameters.m_comboBoxGrid.GetStringSelection()
|
||||||
gridSizeMM = float(grid.split('mm')[0])
|
gridSizeMM = float(grid.split('mm')[0])
|
||||||
if aParameters.m_radioBtnGO.GetValue():
|
if aParameters.m_radioBtnGO.GetValue():
|
||||||
use_grid_origin = True
|
use_grid = 'gridorigin'
|
||||||
|
elif aParameters.m_radioBtnAO.GetValue():
|
||||||
|
use_grid = 'auxorigin'
|
||||||
else:
|
else:
|
||||||
use_grid_origin = False
|
use_grid = 'topleft'
|
||||||
snap2grid(gridSizeMM,use_grid_origin)
|
snap2grid(gridSizeMM,use_grid)
|
||||||
else:
|
else:
|
||||||
None # Cancel
|
None # Cancel
|
||||||
##
|
##
|
||||||
|
|
||||||
def snap2grid(gridSizeMM,use_grid_origin):
|
def snap2grid(gridSizeMM,use_grid):
|
||||||
|
|
||||||
pcb = pcbnew.GetBoard()
|
pcb = pcbnew.GetBoard()
|
||||||
gridOrigin = pcb.GetGridOrigin()
|
gridOrigin = pcb.GetGridOrigin()
|
||||||
@ -127,7 +128,7 @@ def snap2grid(gridSizeMM,use_grid_origin):
|
|||||||
#wxPoint(77470000, 135890000)
|
#wxPoint(77470000, 135890000)
|
||||||
for module in pcb.GetModules():
|
for module in pcb.GetModules():
|
||||||
if module.IsSelected():
|
if module.IsSelected():
|
||||||
if use_grid_origin:
|
if 'grid' in use_grid:
|
||||||
mpx = module.GetPosition().x - gridOrigin.x
|
mpx = module.GetPosition().x - gridOrigin.x
|
||||||
mpy = module.GetPosition().y - gridOrigin.y
|
mpy = module.GetPosition().y - gridOrigin.y
|
||||||
#print(mpx,mpy)
|
#print(mpx,mpy)
|
||||||
@ -150,7 +151,7 @@ def snap2grid(gridSizeMM,use_grid_origin):
|
|||||||
#module.SetPosition(wxPoint(mpOnGx+FromMM(100.0),mpOnGy+FromMM(2.0)))
|
#module.SetPosition(wxPoint(mpOnGx+FromMM(100.0),mpOnGy+FromMM(2.0)))
|
||||||
#module.SetOrientation(10)
|
#module.SetOrientation(10)
|
||||||
#Y_POS='{0:.4f}'.format(-1*pcbnew.ToMM(module.GetPosition().y - gridOrigin.y))
|
#Y_POS='{0:.4f}'.format(-1*pcbnew.ToMM(module.GetPosition().y - gridOrigin.y))
|
||||||
else: # AuxOrigin
|
elif 'aux' in use_grid: # AuxOrigin
|
||||||
mpx = module.GetPosition().x - auxOrigin.x
|
mpx = module.GetPosition().x - auxOrigin.x
|
||||||
mpy = module.GetPosition().y - auxOrigin.y
|
mpy = module.GetPosition().y - auxOrigin.y
|
||||||
#print(mpx,mpy)
|
#print(mpx,mpy)
|
||||||
@ -173,6 +174,20 @@ def snap2grid(gridSizeMM,use_grid_origin):
|
|||||||
#module.SetPosition(wxPoint(mpOnGx+FromMM(100.0),mpOnGy+FromMM(2.0)))
|
#module.SetPosition(wxPoint(mpOnGx+FromMM(100.0),mpOnGy+FromMM(2.0)))
|
||||||
#module.SetOrientation(10)
|
#module.SetOrientation(10)
|
||||||
#Y_POS='{0:.4f}'.format(-1*pcbnew.ToMM(module.GetPosition().y - gridOrigin.y))
|
#Y_POS='{0:.4f}'.format(-1*pcbnew.ToMM(module.GetPosition().y - gridOrigin.y))
|
||||||
|
else:
|
||||||
|
mpx = module.GetPosition().x #- auxOrigin.x
|
||||||
|
mpy = module.GetPosition().y #- auxOrigin.y
|
||||||
|
mpxOnG = int(mpx/FromMM(gridSizeMM))*FromMM(gridSizeMM) #+ auxOrigin.x
|
||||||
|
mpyOnG = int(mpy/FromMM(gridSizeMM))*FromMM(gridSizeMM) #+ auxOrigin.y
|
||||||
|
locked=''
|
||||||
|
if not module.IsLocked():
|
||||||
|
module.SetPosition(wxPoint(mpxOnG,mpyOnG))
|
||||||
|
else:
|
||||||
|
locked='LOCKED'
|
||||||
|
X_POS=str(module.GetPosition().x) # - gridOrigin.x)
|
||||||
|
X_POS="{0:<11}".format(X_POS)
|
||||||
|
Y_POS=str(module.GetPosition().y) # - gridOrigin.y)
|
||||||
|
Y_POS="{0:<11}".format(Y_POS)
|
||||||
Reference="{0:<10}".format(str(module.GetReference()))
|
Reference="{0:<10}".format(str(module.GetReference()))
|
||||||
Value = str(module.GetValue())
|
Value = str(module.GetValue())
|
||||||
Value=(Value[:17] + '..') if len(Value) > 19 else Value
|
Value=(Value[:17] + '..') if len(Value) > 19 else Value
|
||||||
@ -199,12 +214,15 @@ def snap2grid(gridSizeMM,use_grid_origin):
|
|||||||
if len(content)>0:
|
if len(content)>0:
|
||||||
content+=str(pcbnew.FromMM(gridSizeMM))+'\n'
|
content+=str(pcbnew.FromMM(gridSizeMM))+'\n'
|
||||||
info='Snapped to grid: '+str(gridSizeMM)+'mm\n'
|
info='Snapped to grid: '+str(gridSizeMM)+'mm\n'
|
||||||
if use_grid_origin:
|
if 'grid' in use_grid:
|
||||||
content+="Using GridOrigin as Ref"+'\n'
|
content+="Using GridOrigin as Ref"+'\n'
|
||||||
info+="Using GridOrigin as Ref"+'\n'
|
info+="Using GridOrigin as Ref"+'\n'
|
||||||
else:
|
elif 'aux' in use_grid:
|
||||||
content+="Using AuxOrigin as Ref"+'\n'
|
content+="Using AuxOrigin as Ref"+'\n'
|
||||||
info+="Using AuxOrigin as Ref"+'\n'
|
info+="Using AuxOrigin as Ref"+'\n'
|
||||||
|
else:
|
||||||
|
content+="Using Top Left Origin as Ref"+'\n'
|
||||||
|
info+="Using Top Left Origin as Ref"+'\n'
|
||||||
if debug:
|
if debug:
|
||||||
wxLogDebug(content,debug)
|
wxLogDebug(content,debug)
|
||||||
#else:
|
#else:
|
||||||
|
@ -8,7 +8,11 @@
|
|||||||
|
|
||||||
#import snaptogrid; import importlib; importlib.reload(snaptogrid)
|
#import snaptogrid; import importlib; importlib.reload(snaptogrid)
|
||||||
|
|
||||||
__version__ = '1.0.1'
|
### plugins errors
|
||||||
|
#import pcbnew
|
||||||
|
#pcbnew.GetWizardsBackTrace()
|
||||||
|
|
||||||
|
__version__ = '1.0.2'
|
||||||
import sys, os
|
import sys, os
|
||||||
import pcbnew
|
import pcbnew
|
||||||
import datetime
|
import datetime
|
||||||
@ -17,11 +21,11 @@ from pcbnew import *
|
|||||||
|
|
||||||
use_grid_origin = True
|
use_grid_origin = True
|
||||||
|
|
||||||
gridReference = 2.54 #1.27 #mm pcbnew.FromMM(1.0) #0.1mm
|
gridReference = 0.1 #1.27 #mm pcbnew.FromMM(1.0) #0.1mm
|
||||||
|
|
||||||
gridSizeMM = gridReference
|
gridSizeMM = gridReference
|
||||||
|
|
||||||
#from . import Send2GridDlg
|
from . import Snap2GridDlg
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(__file__))
|
sys.path.append(os.path.dirname(__file__))
|
||||||
|
|
||||||
@ -32,36 +36,38 @@ def wxLogDebug(msg,dbg):
|
|||||||
wx.LogMessage(msg)
|
wx.LogMessage(msg)
|
||||||
#
|
#
|
||||||
|
|
||||||
#class Snap2Grid_Dlg(Snap2GridDlg.Snap2GridDlg):
|
class Snap2Grid_Dlg(Snap2GridDlg.Snap2GridDlg):
|
||||||
# # from https://github.com/MitjaNemec/Kicad_action_plugins
|
# from https://github.com/MitjaNemec/Kicad_action_plugins
|
||||||
# # hack for new wxFormBuilder generating code incompatible with old wxPython
|
# hack for new wxFormBuilder generating code incompatible with old wxPython
|
||||||
# # noinspection PyMethodOverriding
|
# noinspection PyMethodOverriding
|
||||||
# def SetSizeHints(self, sz1, sz2):
|
def SetSizeHints(self, sz1, sz2):
|
||||||
# if wx.__version__ < '4.0':
|
if wx.__version__ < '4.0':
|
||||||
# self.SetSizeHintsSz(sz1, sz2)
|
self.SetSizeHintsSz(sz1, sz2)
|
||||||
# else:
|
else:
|
||||||
# super(RoundTrack_Dlg, self).SetSizeHints(sz1, sz2)
|
super(Snap2Grid_Dlg, self).SetSizeHints(sz1, sz2)
|
||||||
#
|
|
||||||
# # def onDeleteClick(self, event):
|
# def onDeleteClick(self, event):
|
||||||
# # return self.EndModal(wx.ID_DELETE)
|
# return self.EndModal(wx.ID_DELETE)
|
||||||
# #
|
#
|
||||||
# # def onConnectClick(self, event):
|
# def onConnectClick(self, event):
|
||||||
# # return self.EndModal(wx.ID_REVERT)
|
# return self.EndModal(wx.ID_REVERT)
|
||||||
#
|
|
||||||
# def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
# import wx
|
import wx
|
||||||
# Send2GridDlg.Send2GridDlg.__init__(self, parent)
|
Snap2GridDlg.Snap2GridDlg.__init__(self, parent)
|
||||||
# #self.GetSizer().Fit(self)
|
#self.GetSizer().Fit(self)
|
||||||
# self.SetMinSize(self.GetSize())
|
self.SetMinSize(self.GetSize())
|
||||||
# #self.m_buttonDelete.Bind(wx.EVT_BUTTON, self.onDeleteClick)
|
self.m_bitmapS2G.SetBitmap(wx.Bitmap(os.path.join(os.path.dirname(__file__), "./snap2grid.png")))
|
||||||
# #self.m_buttonReconnect.Bind(wx.EVT_BUTTON, self.onConnectClick)
|
#self.SetIcon(wx.IconFromBitmap(wx.Bitmap(os.path.join(os.path.dirname(__file__), "./snap2grid.png"))))
|
||||||
# #if wx.__version__ < '4.0':
|
#self.m_buttonDelete.Bind(wx.EVT_BUTTON, self.onDeleteClick)
|
||||||
# # self.m_buttonReconnect.SetToolTipString( u"Select two converging Tracks to re-connect them\nor Select tracks including one round corner to be straighten" )
|
#self.m_buttonReconnect.Bind(wx.EVT_BUTTON, self.onConnectClick)
|
||||||
# # self.m_buttonRound.SetToolTipString( u"Select two connected Tracks to round the corner\nThen choose distance from intersection and the number of segments" )
|
#if wx.__version__ < '4.0':
|
||||||
# #else:
|
# self.m_buttonReconnect.SetToolTipString( u"Select two converging Tracks to re-connect them\nor Select tracks including one round corner to be straighten" )
|
||||||
# # self.m_buttonReconnect.SetToolTip( u"Select two converging Tracks to re-connect them\nor Select tracks including one round corner to be straighten" )
|
# self.m_buttonRound.SetToolTipString( u"Select two connected Tracks to round the corner\nThen choose distance from intersection and the number of segments" )
|
||||||
# # self.m_buttonRound.SetToolTip( u"Select two connected Tracks to round the corner\nThen choose distance from intersection and the number of segments" )
|
#else:
|
||||||
#
|
# self.m_buttonReconnect.SetToolTip( u"Select two converging Tracks to re-connect them\nor Select tracks including one round corner to be straighten" )
|
||||||
|
# self.m_buttonRound.SetToolTip( u"Select two connected Tracks to round the corner\nThen choose distance from intersection and the number of segments" )
|
||||||
|
|
||||||
# Python plugin stuff
|
# Python plugin stuff
|
||||||
class snap_to_grid( pcbnew.ActionPlugin ):
|
class snap_to_grid( pcbnew.ActionPlugin ):
|
||||||
"""
|
"""
|
||||||
@ -77,9 +83,9 @@ class snap_to_grid( pcbnew.ActionPlugin ):
|
|||||||
self.description should be a comprehensive description
|
self.description should be a comprehensive description
|
||||||
of the plugin
|
of the plugin
|
||||||
"""
|
"""
|
||||||
self.name = "Snap Selected Module(s) to Grid\nversion "+__version__
|
self.name = "Snap Selected Footprint(s) to Grid \nversion "+__version__
|
||||||
self.category = "Modify PCB"
|
self.category = "Modify PCB"
|
||||||
self.description = "Automaticaly Snap Selected Module(s) to Grid on an existing PCB"
|
self.description = "Automaticaly Snap Selected Footprint Module(s) to Grid on an existing PCB"
|
||||||
#self.pcbnew_icon_support = hasattr(self, "show_toolbar_button")
|
#self.pcbnew_icon_support = hasattr(self, "show_toolbar_button")
|
||||||
self.show_toolbar_button = True
|
self.show_toolbar_button = True
|
||||||
self.icon_file_name = os.path.join(os.path.dirname(__file__), './snap2grid.png')
|
self.icon_file_name = os.path.join(os.path.dirname(__file__), './snap2grid.png')
|
||||||
@ -89,111 +95,131 @@ class snap_to_grid( pcbnew.ActionPlugin ):
|
|||||||
#self.pcb = GetBoard()
|
#self.pcb = GetBoard()
|
||||||
import sys,os
|
import sys,os
|
||||||
#mm_ius = 1000000.0
|
#mm_ius = 1000000.0
|
||||||
|
_pcbnew_frame = [x for x in wx.GetTopLevelWindows() if x.GetTitle().lower().startswith('pcbnew')][0]
|
||||||
|
#aParameters = RoundTrackDlg(None)
|
||||||
|
aParameters = Snap2Grid_Dlg(_pcbnew_frame)
|
||||||
|
gridIndex = aParameters.m_comboBoxGrid.FindString('0.1mm (3.94mils)')
|
||||||
|
aParameters.m_comboBoxGrid.SetSelection(gridIndex)
|
||||||
|
#aParameters.m_comboBoxGrid.Append('0.1mm (3.94mils)')
|
||||||
|
aParameters.m_radioBtnGO.SetValue(True)
|
||||||
|
aParameters.Show()
|
||||||
|
|
||||||
pcb = pcbnew.GetBoard()
|
modal_result = aParameters.ShowModal()
|
||||||
gridOrigin = pcb.GetGridOrigin()
|
if modal_result == wx.ID_OK:
|
||||||
auxOrigin = pcb.GetAuxOrigin()
|
grid = aParameters.m_comboBoxGrid.GetStringSelection()
|
||||||
content=''
|
gridSizeMM = float(grid.split('mm')[0])
|
||||||
locked_fp=''
|
if aParameters.m_radioBtnGO.GetValue():
|
||||||
#wxPoint(77470000, 135890000)
|
use_grid_origin = True
|
||||||
for module in pcb.GetModules():
|
else:
|
||||||
if module.IsSelected():
|
use_grid_origin = False
|
||||||
if use_grid_origin:
|
snap2grid(gridSizeMM,use_grid_origin)
|
||||||
mpx = module.GetPosition().x - gridOrigin.x
|
|
||||||
mpy = module.GetPosition().y - gridOrigin.y
|
|
||||||
print(mpx,mpy)
|
|
||||||
mpxOnG = int(mpx/FromMM(gridSizeMM))*FromMM(gridSizeMM)+ gridOrigin.x
|
|
||||||
mpyOnG = int(mpy/FromMM(gridSizeMM))*FromMM(gridSizeMM)+ gridOrigin.y
|
|
||||||
print(mpxOnG,mpyOnG)
|
|
||||||
locked=''
|
|
||||||
if not module.IsLocked():
|
|
||||||
module.SetPosition(wxPoint(mpxOnG,mpyOnG))
|
|
||||||
else:
|
|
||||||
locked='LOCKED'
|
|
||||||
X_POS=str(module.GetPosition().x) # - gridOrigin.x)
|
|
||||||
#X_POS='{0:.4f}'.format(pcbnew.ToMM(module.GetPosition().x - gridOrigin.x ))
|
|
||||||
X_POS="{0:<11}".format(X_POS)
|
|
||||||
Y_POS=str(module.GetPosition().y) # - gridOrigin.y)
|
|
||||||
Y_POS="{0:<11}".format(Y_POS)
|
|
||||||
## mpOnGx = PutOnGridMM(module.GetPosition().x, gridSizeMM)
|
|
||||||
## mpOnGy = PutOnGridMM(module.GetPosition().y, gridSizeMM)
|
|
||||||
## module.SetPosition(wxPoint(mpOnGx,mpOnGy))
|
|
||||||
#module.SetPosition(wxPoint(mpOnGx+FromMM(100.0),mpOnGy+FromMM(2.0)))
|
|
||||||
#module.SetOrientation(10)
|
|
||||||
#Y_POS='{0:.4f}'.format(-1*pcbnew.ToMM(module.GetPosition().y - gridOrigin.y))
|
|
||||||
# else:
|
|
||||||
# mpx = module.GetPosition().x - auxOrigin().x
|
|
||||||
# mpy = module.GetPosition().y - auxOrigin().y
|
|
||||||
# X_POS='{0:.4f}'.format(pcbnew.ToMM(module.GetPosition().x - auxOrigin().x ))
|
|
||||||
# X_POS="{0:<11}".format(X_POS)
|
|
||||||
# Y_POS='{0:.4f}'.format(-1*pcbnew.ToMM(module.GetPosition().y - auxOrigin().y))
|
|
||||||
# Y_POS="{0:<11}".format(Y_POS)
|
|
||||||
Reference="{0:<10}".format(str(module.GetReference()))
|
|
||||||
Value = str(module.GetValue())
|
|
||||||
Value=(Value[:17] + '..') if len(Value) > 19 else Value
|
|
||||||
Value="{0:<20}".format(Value)
|
|
||||||
Rotation='{0:.1f}'.format((module.GetOrientation()/10))
|
|
||||||
Rotation="{0:>6}".format(Rotation)+' '
|
|
||||||
if module.GetLayer() == 0:
|
|
||||||
Layer=" top"
|
|
||||||
else:
|
|
||||||
Layer=" bottom"
|
|
||||||
#Side="## Side :"+Layer+lsep
|
|
||||||
Layer="{0:<10}".format(Layer)
|
|
||||||
content+=Reference
|
|
||||||
if 'LOCKED' in locked:
|
|
||||||
locked_fp+=Reference + ' LOCKED'+'\n' #os.linesep
|
|
||||||
#content+=Value
|
|
||||||
content+=X_POS
|
|
||||||
content+=Y_POS
|
|
||||||
#content+=str(mpOnGx)
|
|
||||||
#content+=str(mpOnGy)
|
|
||||||
content+=str(mpxOnG)
|
|
||||||
content+=str(mpyOnG)
|
|
||||||
content+=Layer+'\n' #os.linesep
|
|
||||||
if len(content)>0:
|
|
||||||
content+=str(pcbnew.FromMM(gridReference))
|
|
||||||
wxLogDebug(content,debug)
|
|
||||||
if len (locked_fp)>0:
|
|
||||||
locked_fp+='\n'+'NOT Moved'
|
|
||||||
wxLogDebug(locked_fp,True)
|
|
||||||
else:
|
else:
|
||||||
wxLogDebug('No Modules Selected',True)
|
None # Cancel
|
||||||
Refresh()
|
##
|
||||||
#return content
|
|
||||||
|
|
||||||
#if 0:
|
def snap2grid(gridSizeMM,use_grid_origin):
|
||||||
# #from https://github.com/MitjaNemec/Kicad_action_plugins
|
|
||||||
# #hack wxFormBuilder py2/py3
|
|
||||||
# _pcbnew_frame = [x for x in wx.GetTopLevelWindows() if x.GetTitle().lower().startswith('pcbnew')][0]
|
|
||||||
# #aParameters = RoundTrackDlg(None)
|
|
||||||
# aParameters = RoundTrack_Dlg(_pcbnew_frame)
|
|
||||||
# #aParameters = RoundTrack_DlgEx(_pcbnew_frame)
|
|
||||||
# aParameters.Show()
|
|
||||||
# #end hack
|
|
||||||
# aParameters.m_distanceMM.SetValue("5")
|
|
||||||
# aParameters.m_segments.SetValue("16")
|
|
||||||
# aParameters.m_bitmap1.SetBitmap(wx.Bitmap( os.path.join(os.path.dirname(os.path.realpath(__file__)), "round_track_help.png") ) )
|
|
||||||
# modal_result = aParameters.ShowModal()
|
|
||||||
# segments = self.CheckSegmentsInput(
|
|
||||||
# aParameters.m_segments.GetValue(), "number of segments")
|
|
||||||
# distI = FromMM(self.CheckDistanceInput(aParameters.m_distanceMM.GetValue(), "distance from intersection"))
|
|
||||||
# if segments is not None and distI is not None:
|
|
||||||
# if modal_result == wx.ID_OK:
|
|
||||||
# Round_Selection(pcb, distI, segments)
|
|
||||||
# elif modal_result == wx.ID_DELETE:
|
|
||||||
# Delete_Segments(pcb)
|
|
||||||
# #wx.LogMessage('Round Segments on Track Net Deleted')
|
|
||||||
# elif modal_result == wx.ID_REVERT:
|
|
||||||
# wxLogDebug('Connecting Tracks',debug)
|
|
||||||
# Connect_Segments(pcb)
|
|
||||||
# else:
|
|
||||||
# None # Cancel
|
|
||||||
# else:
|
|
||||||
# None # Invalid input
|
|
||||||
# aParameters.Destroy()
|
|
||||||
|
|
||||||
|
|
||||||
|
pcb = pcbnew.GetBoard()
|
||||||
|
gridOrigin = pcb.GetGridOrigin()
|
||||||
|
auxOrigin = pcb.GetAuxOrigin()
|
||||||
|
content=''
|
||||||
|
locked_fp=''
|
||||||
|
#wxPoint(77470000, 135890000)
|
||||||
|
for module in pcb.GetModules():
|
||||||
|
if module.IsSelected():
|
||||||
|
if use_grid_origin:
|
||||||
|
mpx = module.GetPosition().x - gridOrigin.x
|
||||||
|
mpy = module.GetPosition().y - gridOrigin.y
|
||||||
|
#print(mpx,mpy)
|
||||||
|
mpxOnG = int(mpx/FromMM(gridSizeMM))*FromMM(gridSizeMM)+ gridOrigin.x
|
||||||
|
mpyOnG = int(mpy/FromMM(gridSizeMM))*FromMM(gridSizeMM)+ gridOrigin.y
|
||||||
|
#print(mpxOnG,mpyOnG)
|
||||||
|
locked=''
|
||||||
|
if not module.IsLocked():
|
||||||
|
module.SetPosition(wxPoint(mpxOnG,mpyOnG))
|
||||||
|
else:
|
||||||
|
locked='LOCKED'
|
||||||
|
X_POS=str(module.GetPosition().x) # - gridOrigin.x)
|
||||||
|
#X_POS='{0:.4f}'.format(pcbnew.ToMM(module.GetPosition().x - gridOrigin.x ))
|
||||||
|
X_POS="{0:<11}".format(X_POS)
|
||||||
|
Y_POS=str(module.GetPosition().y) # - gridOrigin.y)
|
||||||
|
Y_POS="{0:<11}".format(Y_POS)
|
||||||
|
## mpOnGx = PutOnGridMM(module.GetPosition().x, gridSizeMM)
|
||||||
|
## mpOnGy = PutOnGridMM(module.GetPosition().y, gridSizeMM)
|
||||||
|
## module.SetPosition(wxPoint(mpOnGx,mpOnGy))
|
||||||
|
#module.SetPosition(wxPoint(mpOnGx+FromMM(100.0),mpOnGy+FromMM(2.0)))
|
||||||
|
#module.SetOrientation(10)
|
||||||
|
#Y_POS='{0:.4f}'.format(-1*pcbnew.ToMM(module.GetPosition().y - gridOrigin.y))
|
||||||
|
else: # AuxOrigin
|
||||||
|
mpx = module.GetPosition().x - auxOrigin.x
|
||||||
|
mpy = module.GetPosition().y - auxOrigin.y
|
||||||
|
#print(mpx,mpy)
|
||||||
|
mpxOnG = int(mpx/FromMM(gridSizeMM))*FromMM(gridSizeMM)+ auxOrigin.x
|
||||||
|
mpyOnG = int(mpy/FromMM(gridSizeMM))*FromMM(gridSizeMM)+ auxOrigin.y
|
||||||
|
#print(mpxOnG,mpyOnG)
|
||||||
|
locked=''
|
||||||
|
if not module.IsLocked():
|
||||||
|
module.SetPosition(wxPoint(mpxOnG,mpyOnG))
|
||||||
|
else:
|
||||||
|
locked='LOCKED'
|
||||||
|
X_POS=str(module.GetPosition().x) # - gridOrigin.x)
|
||||||
|
#X_POS='{0:.4f}'.format(pcbnew.ToMM(module.GetPosition().x - gridOrigin.x ))
|
||||||
|
X_POS="{0:<11}".format(X_POS)
|
||||||
|
Y_POS=str(module.GetPosition().y) # - gridOrigin.y)
|
||||||
|
Y_POS="{0:<11}".format(Y_POS)
|
||||||
|
## mpOnGx = PutOnGridMM(module.GetPosition().x, gridSizeMM)
|
||||||
|
## mpOnGy = PutOnGridMM(module.GetPosition().y, gridSizeMM)
|
||||||
|
## module.SetPosition(wxPoint(mpOnGx,mpOnGy))
|
||||||
|
#module.SetPosition(wxPoint(mpOnGx+FromMM(100.0),mpOnGy+FromMM(2.0)))
|
||||||
|
#module.SetOrientation(10)
|
||||||
|
#Y_POS='{0:.4f}'.format(-1*pcbnew.ToMM(module.GetPosition().y - gridOrigin.y))
|
||||||
|
Reference="{0:<10}".format(str(module.GetReference()))
|
||||||
|
Value = str(module.GetValue())
|
||||||
|
Value=(Value[:17] + '..') if len(Value) > 19 else Value
|
||||||
|
Value="{0:<20}".format(Value)
|
||||||
|
Rotation='{0:.1f}'.format((module.GetOrientation()/10))
|
||||||
|
Rotation="{0:>6}".format(Rotation)+' '
|
||||||
|
if module.GetLayer() == 0:
|
||||||
|
Layer=" top"
|
||||||
|
else:
|
||||||
|
Layer=" bottom"
|
||||||
|
#Side="## Side :"+Layer+lsep
|
||||||
|
Layer="{0:<10}".format(Layer)
|
||||||
|
content+=Reference
|
||||||
|
if 'LOCKED' in locked:
|
||||||
|
locked_fp+=Reference + ' LOCKED'+'\n' #os.linesep
|
||||||
|
#content+=Value
|
||||||
|
content+=X_POS
|
||||||
|
content+=Y_POS
|
||||||
|
#content+=str(mpOnGx)
|
||||||
|
#content+=str(mpOnGy)
|
||||||
|
content+=str(mpxOnG)
|
||||||
|
content+=str(mpyOnG)
|
||||||
|
content+=Layer+'\n' #os.linesep
|
||||||
|
if len(content)>0:
|
||||||
|
content+=str(pcbnew.FromMM(gridSizeMM))+'\n'
|
||||||
|
info='Snapped to grid: '+str(gridSizeMM)+'mm\n'
|
||||||
|
if use_grid_origin:
|
||||||
|
content+="Using GridOrigin as Ref"+'\n'
|
||||||
|
info+="Using GridOrigin as Ref"+'\n'
|
||||||
|
else:
|
||||||
|
content+="Using AuxOrigin as Ref"+'\n'
|
||||||
|
info+="Using AuxOrigin as Ref"+'\n'
|
||||||
|
if debug:
|
||||||
|
wxLogDebug(content,debug)
|
||||||
|
#else:
|
||||||
|
wxLogDebug(info,True)
|
||||||
|
if len (locked_fp)>0:
|
||||||
|
locked_fp+='\n'+'NOT Moved (Locked fp)'
|
||||||
|
locked_fp+='\n'+info
|
||||||
|
wxLogDebug(locked_fp,True)
|
||||||
|
else:
|
||||||
|
wxLogDebug(info,True)
|
||||||
|
else:
|
||||||
|
wxLogDebug('No Modules Selected',True)
|
||||||
|
Refresh()
|
||||||
|
#return content
|
||||||
|
|
||||||
# wxLogDebug('showing Selected Tracks',debug)
|
# wxLogDebug('showing Selected Tracks',debug)
|
||||||
# wx.LogMessage('Select Tracks to calculate the Length\nor One Pad to select connected Tracks')
|
# wx.LogMessage('Select Tracks to calculate the Length\nor One Pad to select connected Tracks')
|
||||||
#
|
#
|
||||||
|
Reference in New Issue
Block a user