yaqwsx / KiKit

Automation tools for KiCAD
https://yaqwsx.github.io/KiKit
MIT License
1.53k stars 201 forks source link

Wrong rotation for stencil corners #642

Open AlexanderMandera opened 8 months ago

AlexanderMandera commented 8 months ago

Prerequisites

KiKit version

kikit, version 1.4.0+35.g6dc6666

KiCAD version

7.0.6

Operating system

Windows

Description

When generating a stencil, I see that the arcs in the corners are all rotated in the wrong direction.

image

I fixed this error temporarily by adding a variable "reverse" that uses the "end" location as the start point of the arc and not the "start".

def addRoundedCorner(board, center, start, end, thickness, reverse = False):
    corner = pcbnew.PCB_SHAPE()
    corner.SetShape(STROKE_T.S_ARC)
    corner.SetCenter(toKiCADPoint((center[0], center[1])))
    if not reverse:
        corner.SetStart(toKiCADPoint((start[0], start[1])))
    else:
        corner.SetStart(toKiCADPoint((end[0], end[1])))
   # ... rest of function

def addFrame(board, rect, bridgeWidth, bridgeSpacing, clearance):
   # [...]
    corners = [
        (tl(rect), toKiCADPoint((R, 0)), toKiCADPoint((0, R))), # TL
        (tr(rect), toKiCADPoint((0, R)), toKiCADPoint((-R, 0))), # TR
        (br(rect), toKiCADPoint((-R, 0)), toKiCADPoint((0, -R))), # BR
        (bl(rect), toKiCADPoint((0, -R)), toKiCADPoint((R, 0))) # BL
    ]
    for c, sOffset, eOffset in corners:
        addRoundedCorner(board, c + sOffset + eOffset, c + sOffset, c + eOffset, clearance, True) # <= Flag added here

The result looks like this:

image

I don't know if this is the right way of doing it, or if there is an underlying issue. That's why I haven't created a PR for it. I hope you can resolve the issue with my "fix".

Steps to Reproduce

kikit panelize ^
    --layout "grid; rows: 3; cols: 5; space: 6mm" ^
    --tabs "fixed; width: 5mm; vcount: 0" ^
    --cuts vcuts ^
    --framing "tightframe; width: 4mm; space: 3mm; " ^
    --post "millradius: 1mm" ^
    blank-pcb.kicad_pcb panelblank\panel.kicad_pcb

kikit stencil create --jigsize 125 125 panelblank\panel.kicad_pcb [Stencil-Folder]

Used PCB and Stencil files (correct / wrong versions) Stencil-Bug.zip