Skip to content

Commit

Permalink
Merge pull request #13 from sparkfun/release_candidate
Browse files Browse the repository at this point in the history
v1.3.1
  • Loading branch information
PaulZC authored Sep 24, 2024
2 parents 874a6ef + f7f7116 commit 0fb2422
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
33 changes: 23 additions & 10 deletions SparkFunKiCadPanelizer/panelizer/panelizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
panelOutputFile = os.path.split(board.GetFileName())[1] # Get the file path tail
panelOutputFile = os.path.join(panelOutputPath, os.path.splitext(panelOutputFile)[0] + "_panelized.kicad_pcb")

# Check if PCB needs to be saved
# Check if PCB needs to be saved first
#if board.IsModified(): # This doesn't work. Need to find something that does...
if wx.GetApp() is not None:
resp = wx.MessageBox("Do you want to save the PCB first?",
Expand All @@ -226,6 +226,18 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
else:
board.Save(board.GetFileName())

# Check if user wants to build zone fills
if wx.GetApp() is not None:
resp = wx.MessageBox("Do you want to build the zone fills?",
'Fill zones?', wx.YES_NO | wx.ICON_INFORMATION)
if resp == wx.YES:
report += "Zones filled by user.\n"
fillerTool = pcbnew.ZONE_FILLER(board)
fillerTool.Fill(board.Zones())
else:
fillerTool = pcbnew.ZONE_FILLER(board)
fillerTool.Fill(board.Zones())

if board is None:
report += "Could not load board. Quitting.\n"
sysExit = 2
Expand Down Expand Up @@ -522,14 +534,15 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
ref = sourceModule.Reference().GetText()
prodIDs.append([sourceModule.GetPropertyNative("PROD_ID"), ref])
else: # Move source modules which are outside the bounding box
# If the drawing is below the bottom edge and likely to clip the rail, move it below the rail
if (pos.y > boardBottomEdge) and (pos.y < (boardBottomEdge + (2 * int(HORIZONTAL_EDGE_RAIL_WIDTH * SCALE)))):
sourceModule.Move(pcbnew.VECTOR2I(0, int(HORIZONTAL_EDGE_RAIL_WIDTH * SCALE)))
elif pos.y < boardTopEdge: # If the drawing is above the top edge, move it above the panel
# If the module is below the bottom edge and likely to clip the rail, move it below the rail
if pos.y > boardBottomEdge:
if pos.y < (boardBottomEdge + (2 * int(HORIZONTAL_EDGE_RAIL_WIDTH * SCALE))):
sourceModule.Move(pcbnew.VECTOR2I(0, int(HORIZONTAL_EDGE_RAIL_WIDTH * SCALE)))
elif pos.y < boardTopEdge: # If the module is above the top edge, move it above the panel
sourceModule.Move(pcbnew.VECTOR2I(0, int((-(NUM_Y - 1) * boardHeight) - (HORIZONTAL_EDGE_RAIL_WIDTH * SCALE))))
elif pos.x > boardRightEdge: # If the drawing is to the right, move it beyond the panel
elif pos.x > boardRightEdge: # If the module is to the right, move it beyond the panel
sourceModule.Move(pcbnew.VECTOR2I(int(((NUM_X - 1) * boardWidth) + (VERTICAL_EDGE_RAIL_WIDTH * SCALE)), 0))
else: # elif pos.x < boardLeftEdge: # If the drawing is to the left, move it outside the rail
else: # elif pos.x < boardLeftEdge: # If the module is to the left, move it outside the rail
sourceModule.Move(pcbnew.VECTOR2I(int(-VERTICAL_EDGE_RAIL_WIDTH * SCALE), 0))

for module in newModules:
Expand Down Expand Up @@ -620,12 +633,12 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
#if txt is not None: # Copy all text outside the bounding box to the report
# report += txt + "\n"
if pos.y > boardBottomEdge: # If the drawing is below the bottom edge, move it below the rail
if pos.y < (boardBottomEdge + (HORIZONTAL_EDGE_RAIL_WIDTH * SCALE)): # But only if in the way
if pos.y < (boardBottomEdge + (2 * int(HORIZONTAL_EDGE_RAIL_WIDTH * SCALE))): # But only if in the way
sourceDrawing.Move(pcbnew.VECTOR2I(0, int(HORIZONTAL_EDGE_RAIL_WIDTH * SCALE)))
elif pos.x > boardRightEdge: # If the drawing is to the right, move it beyond the panel
sourceDrawing.Move(pcbnew.VECTOR2I(int(((NUM_X - 1) * boardWidth) + (VERTICAL_EDGE_RAIL_WIDTH * SCALE)), 0))
elif pos.y < boardTopEdge: # If the drawing is above the top edge, move it above the panel
sourceDrawing.Move(pcbnew.VECTOR2I(0, int((-(NUM_Y - 1) * boardHeight) - (HORIZONTAL_EDGE_RAIL_WIDTH * SCALE))))
elif pos.x > boardRightEdge: # If the drawing is to the right, move it beyond the panel
sourceDrawing.Move(pcbnew.VECTOR2I(int(((NUM_X - 1) * boardWidth) + (VERTICAL_EDGE_RAIL_WIDTH * SCALE)), 0))
else: # elif pos.x < boardLeftEdge: # If the drawing is to the left, move it outside the rail
sourceDrawing.Move(pcbnew.VECTOR2I(int(-VERTICAL_EDGE_RAIL_WIDTH * SCALE), 0))

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.0"
__version__ = "1.3.1"

0 comments on commit 0fb2422

Please sign in to comment.