diff --git a/kikit/fab/common.py b/kikit/fab/common.py index 0fbef8d1..ba790f07 100644 --- a/kikit/fab/common.py +++ b/kikit/fab/common.py @@ -162,8 +162,6 @@ def collectPosData(board, correctionFields, posFilter=lambda x : True, """ if bom is None: bom = {} - else: - bom = { getReference(comp): comp for comp in bom } correctionPatterns = [] if correctionFile is not None: diff --git a/kikit/fab/jlcpcb.py b/kikit/fab/jlcpcb.py index 430d27af..51266a07 100644 --- a/kikit/fab/jlcpcb.py +++ b/kikit/fab/jlcpcb.py @@ -11,6 +11,7 @@ def collectBom(components, lscsFields, ignore): bom = {} + ref_comp = {} for c in components: if getUnit(c) != 1: continue @@ -27,18 +28,26 @@ def collectBom(components, lscsFields, ignore): continue if hasattr(c, "dnp") and c.dnp: continue - orderCode = None + orderCodes = [] for fieldName in lscsFields: orderCode = getField(c, fieldName) if orderCode is not None and orderCode.strip() != "": - break - cType = ( - getField(c, "Value"), - getField(c, "Footprint"), - orderCode - ) - bom[cType] = bom.get(cType, []) + [reference] - return bom + orderCodes.append(orderCode) + for i in range(len(orderCodes)): + cType = ( + getField(c, "Value"), + getField(c, "Footprint"), + orderCodes[i] + ) + if i < 1: + bom_ref = reference + else: + bom_ref = "{}_{}".format(reference, i + 1) + + ref_comp[bom_ref] = c + + bom[cType] = bom.get(cType, []) + [bom_ref] + return bom, ref_comp def bomToCsv(bomData, filename): with open(filename, "w", newline="", encoding="utf-8") as csvfile: @@ -90,10 +99,10 @@ def exportJlcpcb(board, outputdir, assembly, schematic, ignore, field, correctionFields = [x.strip() for x in corrections.split(",")] components = extractComponents(schematic) ordercodeFields = [x.strip() for x in field.split(",")] - bom = collectBom(components, ordercodeFields, refsToIgnore) + bom, ref_comp = collectBom(components, ordercodeFields, refsToIgnore) posData = collectPosData(loadedBoard, correctionFields, - bom=components, posFilter=noFilter, correctionFile=correctionpatterns) + bom=ref_comp, posFilter=noFilter, correctionFile=correctionpatterns) boardReferences = set([x[0] for x in posData]) bom = {key: [v for v in val if v in boardReferences] for key, val in bom.items()} bom = {key: val for key, val in bom.items() if len(val) > 0} diff --git a/kikit/panelize.py b/kikit/panelize.py index 9027dc1e..d35a9dd0 100644 --- a/kikit/panelize.py +++ b/kikit/panelize.py @@ -878,6 +878,18 @@ def appendBoard(self, filename: Union[str, Path], destination: VECTOR2I, if refRenamer is not None: renameRefs(board, lambda x: refRenamer(len(self.substrates), x)) + for footprint in board.GetFootprints(): + value = footprint.GetValue() + if '*' in value: + ref = footprint.Reference().GetText() + + cnt = value.split('*')[1] + mod = len(self.substrates) % int(cnt) + + if mod > 0: + new_ref = "{}_{}".format(ref, mod + 1) + footprint.Reference().SetText(new_ref) + drawings = collectItems(board.GetDrawings(), enlargedSourceArea) footprints = collectFootprints(board.GetFootprints(), enlargedSourceArea) tracks = collectItems(board.GetTracks(), enlargedSourceArea)