Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions SparkFunKiCadPanelizer/dialog/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ class GeneralPanel(dialog_text_base.GeneralPanelBase):
def __init__(self, parent):
dialog_text_base.GeneralPanelBase.__init__(self, parent)

self.m_buttonGapsVerticalHelp.SetLabelText("")
# Icon by Icons8 https://icons8.com : https://icons8.com/icon/63308/info
self.m_buttonGapsVerticalHelp.SetBitmap(get_btn_bitmap("info-15.png"))

self.m_buttonGapsHorizontalHelp.SetLabelText("")
# Icon by Icons8 https://icons8.com : https://icons8.com/icon/63308/info
self.m_buttonGapsHorizontalHelp.SetBitmap(get_btn_bitmap("info-15.png"))

self.m_buttonFiducialsHelp.SetLabelText("")
# Icon by Icons8 https://icons8.com : https://icons8.com/icon/63308/info
self.m_buttonFiducialsHelp.SetBitmap(get_btn_bitmap("info-15.png"))
Expand All @@ -225,6 +233,28 @@ def __init__(self, parent):
# Icon by Icons8 https://icons8.com : https://icons8.com/icon/63308/info
self.m_buttonEdgeHelp.SetBitmap(get_btn_bitmap("info-15.png"))

def ClickGapsVerticalHelp( self, event ):
wx.MessageBox("\
This sets the width of the vertical gaps\n\
within the panel. Vertical gaps run from\n\
the bottom rail to the top rail. The width\n\
is defined in X.\n\
\n\
The gap width should be at least 0.3\" to\n\
aid automated inspection.\
", 'Info', wx.OK | wx.ICON_INFORMATION)

def ClickGapsHorizontalHelp( self, event ):
wx.MessageBox("\
This sets the width of the horizontal gaps\n\
within the panel. Horizontal gaps run from\n\
the left rail to the right rail. The width\n\
is defined in Y.\n\
\n\
The gap width should be at least 0.3\" to\n\
aid automated inspection.\
", 'Info', wx.OK | wx.ICON_INFORMATION)

def ClickFiducialsHelp( self, event ):
wx.MessageBox("\
By default, the panel fiducials are placed in\n\
Expand Down
45 changes: 37 additions & 8 deletions SparkFunKiCadPanelizer/dialog/dialog_text_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,34 +159,55 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.

sbSizer3 = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, _(u"Gaps:") ), wx.VERTICAL )

fgSizerGaps = wx.FlexGridSizer( 0, 2, 4, 4 )
fgSizerGaps.SetFlexibleDirection( wx.BOTH )
fgSizerGaps.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
fgSizerVerticalGaps = wx.FlexGridSizer( 0, 3, 0, 0 )
fgSizerVerticalGaps.SetFlexibleDirection( wx.BOTH )
fgSizerVerticalGaps.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )

self.m_gapsVerticalLabel = wx.StaticText( sbSizer3.GetStaticBox(), wx.ID_ANY, _(u"Vertical Gap (X):"), wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_LEFT )
self.m_gapsVerticalLabel.Wrap( -1 )

fgSizerGaps.Add( self.m_gapsVerticalLabel, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
self.m_gapsVerticalLabel.SetMinSize( wx.Size( 120,-1 ) )

fgSizerVerticalGaps.Add( self.m_gapsVerticalLabel, 1, wx.ALIGN_CENTER_VERTICAL, 5 )

self.m_gapsVerticalCtrl = wx.TextCtrl( sbSizer3.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_PROCESS_ENTER )
self.m_gapsVerticalCtrl.SetMaxLength( 0 )
self.m_gapsVerticalCtrl.SetMinSize( wx.Size( 64,-1 ) )

fgSizerGaps.Add( self.m_gapsVerticalCtrl, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
fgSizerVerticalGaps.Add( self.m_gapsVerticalCtrl, 1, wx.ALIGN_CENTER_VERTICAL, 5 )

self.m_buttonGapsVerticalHelp = wx.Button( sbSizer3.GetStaticBox(), wx.ID_ANY, _(u"MyButton"), wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_buttonGapsVerticalHelp.SetMinSize( wx.Size( 15,15 ) )

fgSizerVerticalGaps.Add( self.m_buttonGapsVerticalHelp, 0, wx.ALL, 5 )


sbSizer3.Add( fgSizerVerticalGaps, 1, wx.EXPAND, 5 )

fgSizerHorizontalGaps = wx.FlexGridSizer( 0, 3, 0, 0 )
fgSizerHorizontalGaps.SetFlexibleDirection( wx.BOTH )
fgSizerHorizontalGaps.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )

self.m_gapsHorizontalLabel = wx.StaticText( sbSizer3.GetStaticBox(), wx.ID_ANY, _(u"Horizontal Gap (Y):"), wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_LEFT )
self.m_gapsHorizontalLabel.Wrap( -1 )

fgSizerGaps.Add( self.m_gapsHorizontalLabel, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
self.m_gapsHorizontalLabel.SetMinSize( wx.Size( 120,-1 ) )

fgSizerHorizontalGaps.Add( self.m_gapsHorizontalLabel, 1, wx.ALIGN_CENTER_VERTICAL, 5 )

self.m_gapsHorizontalCtrl = wx.TextCtrl( sbSizer3.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_PROCESS_ENTER )
self.m_gapsHorizontalCtrl.SetMaxLength( 0 )
self.m_gapsHorizontalCtrl.SetMinSize( wx.Size( 64,-1 ) )

fgSizerGaps.Add( self.m_gapsHorizontalCtrl, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
fgSizerHorizontalGaps.Add( self.m_gapsHorizontalCtrl, 1, wx.ALIGN_CENTER_VERTICAL, 5 )

self.m_buttonGapsHorizontalHelp = wx.Button( sbSizer3.GetStaticBox(), wx.ID_ANY, _(u"MyButton"), wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_buttonGapsHorizontalHelp.SetMinSize( wx.Size( 15,15 ) )

sbSizer3.Add( fgSizerGaps, 0, wx.ALL, 10 )
fgSizerHorizontalGaps.Add( self.m_buttonGapsHorizontalHelp, 0, wx.ALL, 5 )


sbSizer3.Add( fgSizerHorizontalGaps, 1, wx.EXPAND, 5 )

self.m_removeRightVerticalCheck = wx.CheckBox( sbSizer3.GetStaticBox(), wx.ID_ANY, _(u"Remove right-most vertical gap and use v-score instead"), wx.DefaultPosition, wx.DefaultSize, 0 )
sbSizer3.Add( self.m_removeRightVerticalCheck, 0, wx.ALL, 5 )
Expand Down Expand Up @@ -238,6 +259,8 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.
bMainSizer.Fit( self )

# Connect Events
self.m_buttonGapsVerticalHelp.Bind( wx.EVT_BUTTON, self.ClickGapsVerticalHelp )
self.m_buttonGapsHorizontalHelp.Bind( wx.EVT_BUTTON, self.ClickGapsHorizontalHelp )
self.m_buttonFiducialsHelp.Bind( wx.EVT_BUTTON, self.ClickFiducialsHelp )
self.m_buttonEdgeHelp.Bind( wx.EVT_BUTTON, self.ClickEdgeHelp )

Expand All @@ -246,6 +269,12 @@ def __del__( self ):


# Virtual event handlers, override them in your derived class
def ClickGapsVerticalHelp( self, event ):
pass

def ClickGapsHorizontalHelp( self, event ):
pass

def ClickFiducialsHelp( self, event ):
pass

Expand Down
7 changes: 7 additions & 0 deletions SparkFunKiCadPanelizer/panelizer/panelizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
SMALLER_THAN = True

# Check gaps
if (GAP_X < 0.0) or (GAP_Y < 0.0):
report += "Gap width can not be negative. Quitting.\n"
sysExit = 2
return sysExit, report
if (GAP_X != 0.0) and (GAP_Y != 0.0):
report += "Specify X or Y gaps, not both. Quitting.\n"
sysExit = 2
Expand All @@ -327,6 +331,9 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
report += "Can not have Y gaps without vertical rails. Quitting.\n"
sysExit = 2
return sysExit, report
if ((GAP_X > 0.0) and (GAP_X < 7.62)) or ((GAP_Y > 0.0) and (GAP_Y < 7.62)): # Check non-zero gaps are 0.3" for AOI
report += "Gaps should be at least 0.3\" for AOI.\n"
sysExit = 1

# Check exposed edge
if EXPOSED_EDGE:
Expand Down
150 changes: 75 additions & 75 deletions SparkFunKiCadPanelizer/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self):

self._pcbnew_frame = None

self.supportedVersions = ['7.','8.']
self.supportedVersions = ['7.','8.','9.']

self.kicad_build_version = pcbnew.GetBuildVersion()

Expand Down Expand Up @@ -96,84 +96,84 @@ def Run(self):
def run_panelizer(dlg, p_panelizer):
self.logger.log(logging.INFO, "Running Panelizer")

if self.IsSupported():
command = []

convertDimensions = 1.0
if dlg.CurrentSettings()["dimensionsInchesBtn"]:
convertDimensions = 25.4

panelx = float(dlg.CurrentSettings()["panelSizeXCtrl"]) * convertDimensions
panely = float(dlg.CurrentSettings()["panelSizeYCtrl"]) * convertDimensions
command.extend(['--panelx','{:.6f}'.format(panelx)])
command.extend(['--panely','{:.6f}'.format(panely)])

smallerThan = dlg.CurrentSettings()["panelSizeSmallerBtn"]
if smallerThan:
command.append('--smaller')
else:
command.append('--larger')

vscorelayer = dlg.CurrentSettings()[dlg.vscore_layer]
command.extend(['--vscorelayer', vscorelayer, '--vscoretextlayer', vscorelayer])

gapx = float(dlg.CurrentSettings()["gapsVerticalCtrl"]) * convertDimensions
gapy = float(dlg.CurrentSettings()["gapsHorizontalCtrl"]) * convertDimensions
command.extend(['--gapx','{:.6f}'.format(gapx)])
command.extend(['--gapy','{:.6f}'.format(gapy)])

removeRight = dlg.CurrentSettings()["removeRightVerticalCheck"]
if removeRight:
command.append('--norightgap')

exposeedge = dlg.CurrentSettings()["productionExposeCheck"]
if exposeedge:
command.append('--exposeedge')

fiducials = dlg.CurrentSettings()["productionBordersCheck"]
leftright = dlg.CurrentSettings()["productionFiducialsCheck"]
if not exposeedge:
if fiducials:
# Default the rail width to 1/4" and nudge by 1/4 of the rail width.
# This provides the clearance needed for clamping and AOI Inspection of the fiducials.
# This is nasty. The default should be in panelizer.py. But I can't think of a solution
# which is good for everyone - including anyone running the panelizer from the command line.
command.extend(['--hrail','6.35','--vrail','6.35'])
command.extend(['--fiducialpos','0.25'])
if leftright:
command.append('--fiducialslr')
else:
command.append('--fiducialstb')
else:
if fiducials:
# Same comment as above
command.extend(['--vrail','6.35'])
command.extend(['--fiducialpos','0.25'])
command.append('--fiducialslr')
if not self.IsSupported():
# Log a warning if this version of KiCad has not been tested
self.logger.log(logging.WARNING, "Version check failed. \"{}\" may not be supported. Panelizing may fail".format(self.kicad_build_version))

command = []

convertDimensions = 1.0
if dlg.CurrentSettings()["dimensionsInchesBtn"]:
convertDimensions = 25.4

panelx = float(dlg.CurrentSettings()["panelSizeXCtrl"]) * convertDimensions
panely = float(dlg.CurrentSettings()["panelSizeYCtrl"]) * convertDimensions
command.extend(['--panelx','{:.6f}'.format(panelx)])
command.extend(['--panely','{:.6f}'.format(panely)])

self.logger.log(logging.INFO, command)

board = pcbnew.GetBoard()

if board is not None:
sysExit, report = p_panelizer.startPanelizerCommand(command, board, self.ordering_instructions, self.logger)
logWarn = logging.INFO
if sysExit >= 1:
logWarn = logging.WARN
if sysExit >= 2:
logWarn = logging.ERROR
self.logger.log(logWarn, report)
if sysExit > 0:
wx.MessageBox("Panelizer " + ("warning" if (sysExit == 1) else "error") + ".\nPlease check panelizer.log for details.",
("Warning" if (sysExit == 1) else "Error"), wx.OK | (wx.ICON_WARNING if (sysExit == 1) else wx.ICON_ERROR))
smallerThan = dlg.CurrentSettings()["panelSizeSmallerBtn"]
if smallerThan:
command.append('--smaller')
else:
command.append('--larger')

vscorelayer = dlg.CurrentSettings()[dlg.vscore_layer]
command.extend(['--vscorelayer', vscorelayer, '--vscoretextlayer', vscorelayer])

gapx = float(dlg.CurrentSettings()["gapsVerticalCtrl"]) * convertDimensions
gapy = float(dlg.CurrentSettings()["gapsHorizontalCtrl"]) * convertDimensions
command.extend(['--gapx','{:.6f}'.format(gapx)])
command.extend(['--gapy','{:.6f}'.format(gapy)])

removeRight = dlg.CurrentSettings()["removeRightVerticalCheck"]
if removeRight:
command.append('--norightgap')

exposeedge = dlg.CurrentSettings()["productionExposeCheck"]
if exposeedge:
command.append('--exposeedge')

fiducials = dlg.CurrentSettings()["productionBordersCheck"]
leftright = dlg.CurrentSettings()["productionFiducialsCheck"]
if not exposeedge:
if fiducials:
# Default the rail width to 1/4" and nudge by 1/4 of the rail width.
# This provides the clearance needed for clamping and AOI Inspection of the fiducials.
# This is nasty. The default should be in panelizer.py. But I can't think of a solution
# which is good for everyone - including anyone running the panelizer from the command line.
command.extend(['--hrail','6.35','--vrail','6.35'])
command.extend(['--fiducialpos','0.25'])
if leftright:
command.append('--fiducialslr')
else:
wx.MessageBox("Panelizer complete.\nPlease check panelizer.log for details.",
"Info", wx.OK | wx.ICON_INFORMATION)
command.append('--fiducialstb')
else:
if fiducials:
# Same comment as above
command.extend(['--vrail','6.35'])
command.extend(['--fiducialpos','0.25'])
command.append('--fiducialslr')

self.logger.log(logging.INFO, command)

board = pcbnew.GetBoard()

if board is not None:
sysExit, report = p_panelizer.startPanelizerCommand(command, board, self.ordering_instructions, self.logger)
logWarn = logging.INFO
if sysExit >= 1:
logWarn = logging.WARNING
if sysExit >= 2:
logWarn = logging.ERROR
self.logger.log(logWarn, report)
if sysExit > 0:
wx.MessageBox("Panelizer " + ("warning" if (sysExit == 1) else "error") + ".\nPlease check panelizer.log for details.",
("Warning" if (sysExit == 1) else "Error"), wx.OK | (wx.ICON_WARNING if (sysExit == 1) else wx.ICON_ERROR))
else:
self.logger.log(logging.ERROR, "Could not get the board")

wx.MessageBox("Panelizer complete.\nPlease check panelizer.log for details.",
"Info", wx.OK | wx.ICON_INFORMATION)
else:
self.logger.log(logging.ERROR, "Version check failed. \"{}\" not supported".format(self.kicad_build_version))
self.logger.log(logging.ERROR, "Could not get the board")

dlg.GetParent().EndModal(wx.ID_OK)

Expand Down
2 changes: 1 addition & 1 deletion SparkFunKiCadPanelizer/resource/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.3.2"
__version__ = "1.4.0"
Loading