@@ -118,10 +118,20 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
118
118
# Minimum spacer for exposed edge panels
119
119
MINIMUM_SPACER = 6.35 # mm
120
120
121
+ INVALID_WIDTH = 999999999
122
+
121
123
# 'Extra' ordering instructions
122
124
# Any PCB_TEXT containing any of these keywords will be copied into the ordering instructions
123
125
possibleExtras = ['clean' , 'Clean' , 'CLEAN' ]
124
126
127
+ # Permutations for Ordering Instructions
128
+ possibleOrderingInstructions = [
129
+ "Ordering_Instructions" ,
130
+ "ORDERING_INSTRUCTIONS" ,
131
+ "Ordering Instructions" ,
132
+ "ORDERING INSTRUCTIONS"
133
+ ]
134
+
125
135
sysExit = - 1 # -1 indicates sysExit has not (yet) been set. The code below will set this to 0, 1, 2.
126
136
report = "\n START: " + datetime .now ().isoformat () + "\n "
127
137
@@ -390,8 +400,8 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
390
400
# Array of tracks
391
401
# Note: Duplicate uses the same net name for the duplicated track.
392
402
# This creates DRC unconnected net errors. (KiKit does this properly...)
393
- minTrackWidth = 999999999
394
- minViaDrill = 999999999
403
+ minTrackWidth = INVALID_WIDTH
404
+ minViaDrill = INVALID_WIDTH
395
405
tracks = board .GetTracks ()
396
406
newTracks = []
397
407
for sourceTrack in tracks : # iterate through each track to be copied
@@ -431,8 +441,9 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
431
441
newModules = []
432
442
prodIDs = []
433
443
for sourceModule in modules :
434
- if "Ordering_Instructions" in sourceModule .GetFPIDAsString ():
435
- orderingInstructionsSeen = True
444
+ for instruction in possibleOrderingInstructions :
445
+ if instruction in sourceModule .GetFPIDAsString ():
446
+ orderingInstructionsSeen = True
436
447
if "SparkFun_Logo" in sourceModule .GetFPIDAsString ():
437
448
sparkfunLogoSeen = True
438
449
if "SparkX_Logo" in sourceModule .GetFPIDAsString ():
@@ -518,26 +529,28 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
518
529
for sourceDrawing in drawings :
519
530
if isinstance (sourceDrawing , pcbnew .PCB_TEXT ):
520
531
txt = sourceDrawing .GetShownText ()
521
- if "mask" in txt or "Mask" in txt or "MASK" in txt :
522
- solderMask = txt
523
- if "layers" in txt or "Layers" in txt or "LAYERS" in txt :
524
- if numLayers is None : # Should we trust the instructions or the tracks?!
525
- numLayers = txt
526
- if "impedance" in txt or "Impedance" in txt or "IMPEDANCE" in txt :
527
- controlledImpedance = txt
528
- if "finish" in txt or "Finish" in txt or "FINISH" in txt :
529
- finish = txt
530
- if "thickness" in txt or "Thickness" in txt or "THICKNESS" in txt :
531
- thickness = txt
532
- if "material" in txt or "Material" in txt or "MATERIAL" in txt :
533
- material = txt
534
- if "weight" in txt or "Weight" in txt or "WEIGHT" in txt or "oz" in txt or "Oz" in txt or "OZ" in txt :
535
- copperWeight = txt
536
- for extra in possibleExtras :
537
- if extra in txt :
538
- if orderingExtras is None :
539
- orderingExtras = ""
540
- orderingExtras += txt + "\n "
532
+ lines = txt .splitlines ()
533
+ for line in lines :
534
+ if "mask" in line or "Mask" in line or "MASK" in line :
535
+ solderMask = line
536
+ if "layers" in line or "Layers" in line or "LAYERS" in line :
537
+ if numLayers is None : # Should we trust the instructions or the tracks?!
538
+ numLayers = line
539
+ if "impedance" in line or "Impedance" in line or "IMPEDANCE" in line :
540
+ controlledImpedance = line
541
+ if "finish" in line or "Finish" in line or "FINISH" in line :
542
+ finish = line
543
+ if "thickness" in line or "Thickness" in line or "THICKNESS" in line :
544
+ thickness = line
545
+ if "material" in line or "Material" in line or "MATERIAL" in line :
546
+ material = line
547
+ if "weight" in line or "Weight" in line or "WEIGHT" in line or "oz" in line or "Oz" in line or "OZ" in line :
548
+ copperWeight = line
549
+ for extra in possibleExtras :
550
+ if extra in line :
551
+ if orderingExtras is None :
552
+ orderingExtras = ""
553
+ orderingExtras += line + "\n "
541
554
pos = sourceDrawing .GetPosition () # Check if drawing is outside the bounding box
542
555
if pos .x >= boardLeftEdge and pos .x <= boardRightEdge and \
543
556
pos .y >= boardTopEdge and pos .y <= boardBottomEdge :
@@ -1070,27 +1083,29 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
1070
1083
if material is not None :
1071
1084
report += material + "\n "
1072
1085
if solderMask is None :
1073
- solderMask = "Solder Mask: Red"
1086
+ solderMask = "Solder Mask: Red (Default) "
1074
1087
report += solderMask + "\n "
1075
1088
if silkscreen is None :
1076
- silkscreen = "Silkscreen: White"
1089
+ silkscreen = "Silkscreen: White (Default) "
1077
1090
report += silkscreen + "\n "
1078
1091
if numLayers is None :
1079
- numLayers = "Layers: 2"
1092
+ numLayers = "Layers: 2 (Default) "
1080
1093
report += numLayers + "\n "
1081
1094
if finish is None :
1082
- finish = "Finish: HASL Lead-free"
1095
+ finish = "Finish: HASL Lead-free (Default) "
1083
1096
report += finish + "\n "
1084
1097
if thickness is None :
1085
- thickness = "Thickness: 1.6mm"
1098
+ thickness = "Thickness: 1.6mm (Default) "
1086
1099
report += thickness + "\n "
1087
1100
if copperWeight is None :
1088
- copperWeight = "Copper weight: 1oz"
1101
+ copperWeight = "Copper weight: 1oz (Default) "
1089
1102
report += copperWeight + "\n "
1090
- report += "Minimum track width: {:.2f}mm ({:.2f}mil)\n " .format (
1091
- float (minTrackWidth ) / SCALE , float (minTrackWidth ) * 1000 / (SCALE * 25.4 ))
1092
- report += "Minimum via drill: {:.2f}mm ({:.2f}mil)\n " .format (
1093
- float (minViaDrill ) / SCALE , float (minViaDrill ) * 1000 / (SCALE * 25.4 ))
1103
+ if minTrackWidth < INVALID_WIDTH :
1104
+ report += "Minimum track width: {:.2f}mm ({:.2f}mil)\n " .format (
1105
+ float (minTrackWidth ) / SCALE , float (minTrackWidth ) * 1000 / (SCALE * 25.4 ))
1106
+ if minViaDrill < INVALID_WIDTH :
1107
+ report += "Minimum via drill: {:.2f}mm ({:.2f}mil)\n " .format (
1108
+ float (minViaDrill ) / SCALE , float (minViaDrill ) * 1000 / (SCALE * 25.4 ))
1094
1109
if orderingExtras is not None :
1095
1110
report += orderingExtras
1096
1111
else :
@@ -1110,66 +1125,69 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
1110
1125
if wx .GetApp () is not None and orderingInstructionsSeen :
1111
1126
resp = wx .MessageBox ("Solder mask color not found!" ,
1112
1127
'Warning' , wx .OK | wx .ICON_WARNING )
1113
- solderMask = "Solder Mask: Red"
1128
+ solderMask = "Solder Mask: Red (Default) "
1114
1129
oi .write (solderMask + "\n " )
1115
1130
if silkscreen is None :
1116
1131
if wx .GetApp () is not None and orderingInstructionsSeen :
1117
1132
resp = wx .MessageBox ("Silkscreen color not found!" ,
1118
1133
'Warning' , wx .OK | wx .ICON_WARNING )
1119
- silkscreen = "Silkscreen: White"
1134
+ silkscreen = "Silkscreen: White (Default) "
1120
1135
oi .write (silkscreen + "\n " )
1121
1136
if numLayers is None :
1122
1137
if wx .GetApp () is not None and orderingInstructionsSeen :
1123
1138
resp = wx .MessageBox ("Number of layers not found!" ,
1124
1139
'Warning' , wx .OK | wx .ICON_WARNING )
1125
- numLayers = "Layers: 2"
1140
+ numLayers = "Layers: 2 (Default) "
1126
1141
oi .write (numLayers + "\n " )
1127
1142
if finish is None :
1128
1143
if wx .GetApp () is not None and orderingInstructionsSeen :
1129
1144
resp = wx .MessageBox ("PCB finish not found!" ,
1130
1145
'Warning' , wx .OK | wx .ICON_WARNING )
1131
- finish = "Finish: HASL Lead-free"
1146
+ finish = "Finish: HASL Lead-free (Default) "
1132
1147
oi .write (finish + "\n " )
1133
1148
if thickness is None :
1134
1149
if wx .GetApp () is not None and orderingInstructionsSeen :
1135
1150
resp = wx .MessageBox ("PCB thickness not found!" ,
1136
1151
'Warning' , wx .OK | wx .ICON_WARNING )
1137
- thickness = "Thickness: 1.6mm"
1152
+ thickness = "Thickness: 1.6mm (Default) "
1138
1153
oi .write (thickness + "\n " )
1139
1154
if copperWeight is None :
1140
1155
if wx .GetApp () is not None and orderingInstructionsSeen :
1141
1156
resp = wx .MessageBox ("Copper weight not found!" ,
1142
1157
'Warning' , wx .OK | wx .ICON_WARNING )
1143
- copperWeight = "Copper weight: 1oz"
1158
+ copperWeight = "Copper weight: 1oz (Default) "
1144
1159
oi .write (copperWeight + "\n " )
1145
- oi .write ("Minimum track width: {:.2f}mm ({:.2f}mil)\n " .format (
1146
- float (minTrackWidth ) / SCALE , float (minTrackWidth ) * 1000 / (SCALE * 25.4 )))
1147
- oi .write ("Minimum via drill: {:.2f}mm ({:.2f}mil)\n " .format (
1148
- float (minViaDrill ) / SCALE , float (minViaDrill ) * 1000 / (SCALE * 25.4 )))
1160
+ if minTrackWidth < INVALID_WIDTH :
1161
+ oi .write ("Minimum track width: {:.2f}mm ({:.2f}mil)\n " .format (
1162
+ float (minTrackWidth ) / SCALE , float (minTrackWidth ) * 1000 / (SCALE * 25.4 )))
1163
+ if minViaDrill < INVALID_WIDTH :
1164
+ oi .write ("Minimum via drill: {:.2f}mm ({:.2f}mil)\n " .format (
1165
+ float (minViaDrill ) / SCALE , float (minViaDrill ) * 1000 / (SCALE * 25.4 )))
1149
1166
if orderingExtras is not None :
1150
1167
oi .write (orderingExtras )
1151
1168
except Exception as e :
1152
1169
# Don't throw exception if we can't save ordering instructions
1153
1170
pass
1154
1171
1155
- if (prodIDs is not None ) :
1172
+ if len (prodIDs ) > 0 :
1156
1173
emptyProdIDs = {}
1157
1174
for prodID in prodIDs :
1158
1175
if (prodID [0 ] == '' ) or (prodID [0 ] == ' ' ):
1159
1176
if prodID [1 ] not in emptyProdIDs :
1160
1177
emptyProdIDs [prodID [1 ]] = 1
1161
1178
else :
1162
1179
emptyProdIDs [prodID [1 ]] = emptyProdIDs [prodID [1 ]] + 1
1163
- if wx . GetApp () is not None and orderingInstructionsSeen and emptyProdIDs :
1180
+ if len ( emptyProdIDs ) > 0 :
1164
1181
refs = ""
1165
- for keys , value in emptyProdIDs .items ():
1182
+ for ref , num in emptyProdIDs .items ():
1166
1183
if refs == "" :
1167
- refs += keys
1184
+ refs += ref
1168
1185
else :
1169
- refs += "," + keys
1170
- resp = wx .MessageBox ("Empty (undefined) PROD_IDs found!\n " + refs ,
1171
- 'Warning' , wx .OK | wx .ICON_WARNING )
1172
- report += "Empty (undefined) PROD_IDs found!" + refs + "\n "
1186
+ refs += "," + ref
1187
+ if wx .GetApp () is not None and orderingInstructionsSeen :
1188
+ resp = wx .MessageBox ("Empty (undefined) PROD_IDs found!\n " + refs ,
1189
+ 'Warning' , wx .OK | wx .ICON_WARNING )
1190
+ report += "Empty (undefined) PROD_IDs found: " + refs + "\n "
1173
1191
sysExit = 1
1174
1192
1175
1193
if sysExit < 0 :
0 commit comments