From d4f14787f45d406a3f6cd9fafb2e9b192e654a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Mr=C3=A1zek?= Date: Wed, 29 Jan 2025 15:19:16 +0100 Subject: [PATCH] Separate vertial and horizontal frame width --- kikit/panelize.py | 23 +++++++++++++---------- kikit/panelize_ui_impl.py | 11 ++++++----- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/kikit/panelize.py b/kikit/panelize.py index 3d30fdff..6dcc3f80 100644 --- a/kikit/panelize.py +++ b/kikit/panelize.py @@ -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]]: """ @@ -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 @@ -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: @@ -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 @@ -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()) diff --git a/kikit/panelize_ui_impl.py b/kikit/panelize_ui_impl.py index 490d72b4..ca270f3c 100644 --- a/kikit/panelize_ui_impl.py +++ b/kikit/panelize_ui_impl.py @@ -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"]) @@ -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 []