Skip to content

Commit d262465

Browse files
committed
Changes:
Remove possibleOrderingInstructions and orderingInstructionsSeen. Warn if default instructions are used. Only nudge text below the bottom edge if it is likely to clip the rail.
1 parent 9d53a83 commit d262465

File tree

1 file changed

+15
-41
lines changed

1 file changed

+15
-41
lines changed

SparkFunKiCadPanelizer/panelizer/panelizer.py

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,6 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
148148
# Any PCB_TEXT containing any of these keywords will be copied into the ordering instructions
149149
possibleExtras = ['clean', 'Clean', 'CLEAN', 'stackup', 'Stackup', 'STACKUP']
150150

151-
# Permutations for Ordering Instructions
152-
possibleOrderingInstructions = [
153-
"Ordering_Instructions",
154-
"ORDERING_INSTRUCTIONS",
155-
"Ordering Instructions",
156-
"ORDERING INSTRUCTIONS"
157-
]
158-
159151
sysExit = -1 # -1 indicates sysExit has not (yet) been set. The code below will set this to 0, 1, 2.
160152
report = "\nSTART: " + datetime.now().isoformat() + "\n"
161153

@@ -444,7 +436,6 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
444436
if PANEL_X or PANEL_Y:
445437
report += "You can fit " + str(NUM_X) + " x " + str(NUM_Y) + " boards on the panel.\n"
446438

447-
orderingInstructionsSeen = False
448439
sparkfunLogoSeen = False
449440
sparkxLogoSeen = False
450441
solderMask = None
@@ -496,9 +487,6 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
496487
newModules = []
497488
prodIDs = []
498489
for sourceModule in modules:
499-
for instruction in possibleOrderingInstructions:
500-
if instruction in sourceModule.GetFPIDAsString():
501-
orderingInstructionsSeen = True
502490
if "SparkFun_Logo" in sourceModule.GetFPIDAsString():
503491
sparkfunLogoSeen = True
504492
if "SparkX_Logo" in sourceModule.GetFPIDAsString():
@@ -534,12 +522,13 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
534522
ref = sourceModule.Reference().GetText()
535523
prodIDs.append([sourceModule.GetPropertyNative("PROD_ID"), ref])
536524
else: # Move source modules which are outside the bounding box
537-
if pos.y > boardBottomEdge: # If the drawing is below the bottom edge, move it below the rail
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)))):
538527
sourceModule.Move(pcbnew.VECTOR2I(0, int(HORIZONTAL_EDGE_RAIL_WIDTH * SCALE)))
539-
elif pos.x > boardRightEdge: # If the drawing is to the right, move it beyond the panel
540-
sourceModule.Move(pcbnew.VECTOR2I(int(((NUM_X - 1) * boardWidth) + (VERTICAL_EDGE_RAIL_WIDTH * SCALE)), 0))
541528
elif pos.y < boardTopEdge: # If the drawing is above the top edge, move it above the panel
542529
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+
sourceModule.Move(pcbnew.VECTOR2I(int(((NUM_X - 1) * boardWidth) + (VERTICAL_EDGE_RAIL_WIDTH * SCALE)), 0))
543532
else: # elif pos.x < boardLeftEdge: # If the drawing is to the left, move it outside the rail
544533
sourceModule.Move(pcbnew.VECTOR2I(int(-VERTICAL_EDGE_RAIL_WIDTH * SCALE), 0))
545534

@@ -1191,13 +1180,6 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
11911180
sysExit = 1
11921181

11931182
# Add ordering instructions:
1194-
if not orderingInstructionsSeen:
1195-
if wx.GetApp() is not None:
1196-
resp = wx.MessageBox("Ordering Instructions not found!\nNo futher warnings will be given.",
1197-
'Warning', wx.OK | wx.ICON_WARNING)
1198-
report += "Ordering Instructions not found! No futher ordering warnings will be given.\n"
1199-
sysExit = 1
1200-
12011183
if ordering is None:
12021184
report += "\nOrdering Instructions:\n"
12031185
report += (
@@ -1237,6 +1219,7 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
12371219
report += orderingExtras
12381220
else:
12391221
try:
1222+
defaultsUsed = False
12401223
with open(ordering, 'w') as oi:
12411224
oi.write("Ordering Instructions:\n")
12421225
oi.write(
@@ -1249,39 +1232,27 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
12491232
if material is not None:
12501233
oi.write(material + "\n")
12511234
if solderMask is None:
1252-
if wx.GetApp() is not None and orderingInstructionsSeen:
1253-
resp = wx.MessageBox("Solder mask color not found!",
1254-
'Warning', wx.OK | wx.ICON_WARNING)
1235+
defaultsUsed = True
12551236
solderMask = "Solder Mask: Red (Default)"
12561237
oi.write(solderMask + "\n")
12571238
if silkscreen is None:
1258-
if wx.GetApp() is not None and orderingInstructionsSeen:
1259-
resp = wx.MessageBox("Silkscreen color not found!",
1260-
'Warning', wx.OK | wx.ICON_WARNING)
1239+
defaultsUsed = True
12611240
silkscreen = "Silkscreen: White (Default)"
12621241
oi.write(silkscreen + "\n")
12631242
if copperLayers is None:
1264-
if wx.GetApp() is not None and orderingInstructionsSeen:
1265-
resp = wx.MessageBox("Number of layers not found!",
1266-
'Warning', wx.OK | wx.ICON_WARNING)
1243+
defaultsUsed = True
12671244
copperLayers = "Layers: 2 (Default)"
12681245
oi.write(copperLayers + "\n")
12691246
if finish is None:
1270-
if wx.GetApp() is not None and orderingInstructionsSeen:
1271-
resp = wx.MessageBox("PCB finish not found!",
1272-
'Warning', wx.OK | wx.ICON_WARNING)
1247+
defaultsUsed = True
12731248
finish = "Finish: HASL Lead-free (Default)"
12741249
oi.write(finish + "\n")
12751250
if thickness is None:
1276-
if wx.GetApp() is not None and orderingInstructionsSeen:
1277-
resp = wx.MessageBox("PCB thickness not found!",
1278-
'Warning', wx.OK | wx.ICON_WARNING)
1251+
defaultsUsed = True
12791252
thickness = "Thickness: 1.6mm (Default)"
12801253
oi.write(thickness + "\n")
12811254
if copperWeight is None:
1282-
if wx.GetApp() is not None and orderingInstructionsSeen:
1283-
resp = wx.MessageBox("Copper weight not found!",
1284-
'Warning', wx.OK | wx.ICON_WARNING)
1255+
defaultsUsed = True
12851256
copperWeight = "Copper weight: 1oz (Default)"
12861257
oi.write(copperWeight + "\n")
12871258
if minTrackWidth < INVALID_WIDTH:
@@ -1292,6 +1263,9 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
12921263
float(minViaDrill) / SCALE, float(minViaDrill) * 1000 / (SCALE * 25.4)))
12931264
if orderingExtras is not None:
12941265
oi.write(orderingExtras)
1266+
if defaultsUsed:
1267+
report += "Warning: Ordering Instructions contains default values.\n"
1268+
sysExit = 1
12951269
except Exception as e:
12961270
# Don't throw exception if we can't save ordering instructions
12971271
pass
@@ -1311,7 +1285,7 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
13111285
refs += ref
13121286
else:
13131287
refs += "," + ref
1314-
if wx.GetApp() is not None and orderingInstructionsSeen:
1288+
if wx.GetApp() is not None:
13151289
resp = wx.MessageBox("Empty (undefined) PROD_IDs found!\n" + refs,
13161290
'Warning', wx.OK | wx.ICON_WARNING)
13171291
report += "Empty (undefined) PROD_IDs found: " + refs + "\n"

0 commit comments

Comments
 (0)