Skip to content

Commit 43bb637

Browse files
committed
Better parsing of ordering instructions
1 parent b1ef84b commit 43bb637

File tree

1 file changed

+33
-22
lines changed

1 file changed

+33
-22
lines changed

SparkFunKiCadPanelizer/panelizer/panelizer.py

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
124124
# Any PCB_TEXT containing any of these keywords will be copied into the ordering instructions
125125
possibleExtras = ['clean', 'Clean', 'CLEAN']
126126

127+
# Permutations for Ordering Instructions
128+
possibleOrderingInstructions = [
129+
"Ordering_Instructions",
130+
"ORDERING_INSTRUCTIONS",
131+
"Ordering Instructions",
132+
"ORDERING INSTRUCTIONS"
133+
]
134+
127135
sysExit = -1 # -1 indicates sysExit has not (yet) been set. The code below will set this to 0, 1, 2.
128136
report = "\nSTART: " + datetime.now().isoformat() + "\n"
129137

@@ -433,8 +441,9 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
433441
newModules = []
434442
prodIDs = []
435443
for sourceModule in modules:
436-
if "Ordering_Instructions" in sourceModule.GetFPIDAsString():
437-
orderingInstructionsSeen = True
444+
for instruction in possibleOrderingInstructions:
445+
if instruction in sourceModule.GetFPIDAsString():
446+
orderingInstructionsSeen = True
438447
if "SparkFun_Logo" in sourceModule.GetFPIDAsString():
439448
sparkfunLogoSeen = True
440449
if "SparkX_Logo" in sourceModule.GetFPIDAsString():
@@ -520,26 +529,28 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
520529
for sourceDrawing in drawings:
521530
if isinstance(sourceDrawing, pcbnew.PCB_TEXT):
522531
txt = sourceDrawing.GetShownText()
523-
if "mask" in txt or "Mask" in txt or "MASK" in txt:
524-
solderMask = txt
525-
if "layers" in txt or "Layers" in txt or "LAYERS" in txt:
526-
if numLayers is None: # Should we trust the instructions or the tracks?!
527-
numLayers = txt
528-
if "impedance" in txt or "Impedance" in txt or "IMPEDANCE" in txt:
529-
controlledImpedance = txt
530-
if "finish" in txt or "Finish" in txt or "FINISH" in txt:
531-
finish = txt
532-
if "thickness" in txt or "Thickness" in txt or "THICKNESS" in txt:
533-
thickness = txt
534-
if "material" in txt or "Material" in txt or "MATERIAL" in txt:
535-
material = txt
536-
if "weight" in txt or "Weight" in txt or "WEIGHT" in txt or "oz" in txt or "Oz" in txt or "OZ" in txt:
537-
copperWeight = txt
538-
for extra in possibleExtras:
539-
if extra in txt:
540-
if orderingExtras is None:
541-
orderingExtras = ""
542-
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"
543554
pos = sourceDrawing.GetPosition() # Check if drawing is outside the bounding box
544555
if pos.x >= boardLeftEdge and pos.x <= boardRightEdge and \
545556
pos.y >= boardTopEdge and pos.y <= boardBottomEdge:

0 commit comments

Comments
 (0)