Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions kikit/fab/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
31 changes: 20 additions & 11 deletions kikit/fab/jlcpcb.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

def collectBom(components, lscsFields, ignore):
bom = {}
ref_comp = {}
for c in components:
if getUnit(c) != 1:
continue
Expand All @@ -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:
Expand Down Expand Up @@ -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}
Expand Down
12 changes: 12 additions & 0 deletions kikit/panelize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down