Skip to content

Commit b914fef

Browse files
committed
Make the drawing and module edge checks consistent
1 parent 874a6ef commit b914fef

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

SparkFunKiCadPanelizer/panelizer/panelizer.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -522,14 +522,15 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
522522
ref = sourceModule.Reference().GetText()
523523
prodIDs.append([sourceModule.GetPropertyNative("PROD_ID"), ref])
524524
else: # Move source modules which are outside the bounding box
525-
# If the drawing is below the bottom edge and likely to clip the rail, move it below the rail
526-
if (pos.y > boardBottomEdge) and (pos.y < (boardBottomEdge + (2 * int(HORIZONTAL_EDGE_RAIL_WIDTH * SCALE)))):
527-
sourceModule.Move(pcbnew.VECTOR2I(0, int(HORIZONTAL_EDGE_RAIL_WIDTH * SCALE)))
528-
elif pos.y < boardTopEdge: # If the drawing is above the top edge, move it above the panel
525+
# If the module is below the bottom edge and likely to clip the rail, move it below the rail
526+
if pos.y > boardBottomEdge:
527+
if pos.y < (boardBottomEdge + (2 * int(HORIZONTAL_EDGE_RAIL_WIDTH * SCALE))):
528+
sourceModule.Move(pcbnew.VECTOR2I(0, int(HORIZONTAL_EDGE_RAIL_WIDTH * SCALE)))
529+
elif pos.y < boardTopEdge: # If the module is above the top edge, move it above the panel
529530
sourceModule.Move(pcbnew.VECTOR2I(0, int((-(NUM_Y - 1) * boardHeight) - (HORIZONTAL_EDGE_RAIL_WIDTH * SCALE))))
530-
elif pos.x > boardRightEdge: # If the drawing is to the right, move it beyond the panel
531+
elif pos.x > boardRightEdge: # If the module is to the right, move it beyond the panel
531532
sourceModule.Move(pcbnew.VECTOR2I(int(((NUM_X - 1) * boardWidth) + (VERTICAL_EDGE_RAIL_WIDTH * SCALE)), 0))
532-
else: # elif pos.x < boardLeftEdge: # If the drawing is to the left, move it outside the rail
533+
else: # elif pos.x < boardLeftEdge: # If the module is to the left, move it outside the rail
533534
sourceModule.Move(pcbnew.VECTOR2I(int(-VERTICAL_EDGE_RAIL_WIDTH * SCALE), 0))
534535

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

0 commit comments

Comments
 (0)