Skip to content

Commit

Permalink
Separate vertial and horizontal frame width
Browse files Browse the repository at this point in the history
  • Loading branch information
yaqwsx committed Jan 29, 2025
1 parent 03edf1f commit d4f1478
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
23 changes: 13 additions & 10 deletions kikit/panelize.py
Original file line number Diff line number Diff line change
Expand Up @@ -1375,8 +1375,8 @@ def makeGrid(self, boardfile: str, sourceArea: BOX2I, rows: int, cols: int,

return self.substrates[substrateCount:]

def makeFrame(self, width: KiLength, hspace: KiLength, vspace: KiLength,
minWidth: KiLength = 0, minHeight: KiLength = 0,
def makeFrame(self, widthH: KiLength, widthV: KiLength, hspace: KiLength,
vspace: KiLength, minWidth: KiLength = 0, minHeight: KiLength = 0,
maxWidth: Optional[KiLength] = None, maxHeight: Optional[KiLength] = None) \
-> Tuple[Iterable[LineString], Iterable[LineString]]:
"""
Expand All @@ -1386,7 +1386,8 @@ def makeFrame(self, width: KiLength, hspace: KiLength, vspace: KiLength,
Parameters:
width - width of substrate around board outlines
widthH, WidthV - width of substrate around board outlines - horizontal
and vertial direction
slotwidth - width of milled-out perimeter around board outline
Expand All @@ -1400,10 +1401,11 @@ def makeFrame(self, width: KiLength, hspace: KiLength, vspace: KiLength,
maxWidth - if the panel doesn't meet this width, error is set and marked
maxHeight - if the panel doesn't meet this height, error is set and marked
maxHeight - if the panel doesn't meet this height, error is set and
marked
"""
frameInnerRect = expandRect(shpBoxToRect(self.boardsBBox()), hspace, vspace)
frameOuterRect = expandRect(frameInnerRect, width)
frameOuterRect = expandRect(frameInnerRect, widthH, widthV)

sizeErrors = []
if maxWidth is not None and frameOuterRect.GetWidth() > maxWidth:
Expand Down Expand Up @@ -1434,17 +1436,18 @@ def makeFrame(self, width: KiLength, hspace: KiLength, vspace: KiLength,
frameCutsH = self.makeFrameCutsH(innerArea, frameInnerRect, frameOuterRect)
return frameCutsV, frameCutsH

def makeTightFrame(self, width: KiLength, slotwidth: KiLength,
def makeTightFrame(self, widthH: KiLength, widthV: KiLength, slotwidth: KiLength,
hspace: KiLength, vspace: KiLength, minWidth: KiLength=0,
minHeight: KiLength=0, maxWidth: Optional[KiLength] = None,
maxHeight: Optional[KiLength] = None) -> None:
"""
Build a full frame with board perimeter milled out.
Add your boards to the panel first using appendBoard or makeGrid.
Build a full frame with board perimeter milled out. Add your boards to
the panel first using appendBoard or makeGrid.
Parameters:
width - width of substrate around board outlines
widthH, widthV - width of substrate around board outlines - horizontal
and verital size.
slotwidth - width of milled-out perimeter around board outline
Expand All @@ -1460,7 +1463,7 @@ def makeTightFrame(self, width: KiLength, slotwidth: KiLength,
maxHeight - if the panel doesn't meet this height, error is set
"""
self.makeFrame(width, hspace, vspace, minWidth, minHeight, maxWidth, maxHeight)
self.makeFrame(widthH, widthV, hspace, vspace, minWidth, minHeight, maxWidth, maxHeight)
boardSlot = GeometryCollection()
for s in self.substrates:
boardSlot = boardSlot.union(s.exterior())
Expand Down
11 changes: 6 additions & 5 deletions kikit/panelize_ui_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def buildFraming(preset, panel):
addFilletAndChamfer(framingPreset, panel)
return []
if type == "frame":
cuts = panel.makeFrame(framingPreset["width"],
cuts = panel.makeFrame(framingPreset["width"], framingPreset["width"],
framingPreset["hspace"], framingPreset["vspace"],
framingPreset["mintotalwidth"], framingPreset["mintotalheight"],
framingPreset["maxtotalwidth"], framingPreset["maxtotalheight"])
Expand All @@ -482,10 +482,11 @@ def buildFraming(preset, panel):
return cuts[1]
return []
if type == "tightframe":
panel.makeTightFrame(framingPreset["width"], framingPreset["slotwidth"],
framingPreset["hspace"], framingPreset["vspace"],
framingPreset["mintotalwidth"], framingPreset["mintotalheight"],
framingPreset["maxtotalwidth"], framingPreset["maxtotalheight"])
panel.makeTightFrame(framingPreset["width"], framingPreset["width"],
framingPreset["slotwidth"], framingPreset["hspace"],
framingPreset["vspace"], framingPreset["mintotalwidth"],
framingPreset["mintotalheight"], framingPreset["maxtotalwidth"],
framingPreset["maxtotalheight"])
panel.boardSubstrate.removeIslands()
addFilletAndChamfer(framingPreset, panel)
return []
Expand Down

0 comments on commit d4f1478

Please sign in to comment.