Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For JLCPCB, flip orientation (incl. compensation angle) for bottom parts #767

Closed
Closed
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
12 changes: 8 additions & 4 deletions kikit/fab/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ def footprintPosition(footprint, placeOffset, compensation):
pos += VECTOR2I(fromMm(x), fromMm(y))
return pos

def footprintOrientation(footprint, compensation):
return (footprint.GetOrientation().AsDegrees() + compensation[2]) % 360
def footprintOrientation(footprint, compensation, flipBottomOrientation=False):
if flipBottomOrientation and layerToSide(footprint.GetLayer()) == "B":
angle = 180 - footprint.GetOrientation().AsDegrees()
else:
angle = footprint.GetOrientation().AsDegrees()
return (angle + compensation[2]) % 360

def parseCompensation(compensation):
compParts = compensation.split(";")
Expand Down Expand Up @@ -158,7 +162,7 @@ def noFilter(footprint):

def collectPosData(board, correctionFields, posFilter=lambda x : True,
footprintX=defaultFootprintX, footprintY=defaultFootprintY, bom=None,
correctionFile=None):
correctionFile=None, flipBottomOrientation=False):
"""
Extract position data of the footprints.

Expand Down Expand Up @@ -204,7 +208,7 @@ def getCompensation(footprint):
footprintX(footprint, placeOffset, getCompensation(footprint)),
footprintY(footprint, placeOffset, getCompensation(footprint)),
layerToSide(footprint.GetLayer()),
footprintOrientation(footprint, getCompensation(footprint))) for footprint in footprints]
footprintOrientation(footprint, getCompensation(footprint), flipBottomOrientation)) for footprint in footprints]

def posDataToFile(posData, filename):
with open(filename, "w", newline="", encoding="utf-8") as csvfile:
Expand Down
2 changes: 1 addition & 1 deletion kikit/fab/jlcpcb.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def exportJlcpcb(board, outputdir, assembly, schematic, ignore, field,
bom_components = [c for c in components if getReference(c) in bom_refs]

posData = collectPosData(loadedBoard, correctionFields,
bom=bom_components, posFilter=noFilter, correctionFile=correctionpatterns)
bom=bom_components, posFilter=noFilter, correctionFile=correctionpatterns, flipBottomOrientation=True)
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