leomcelroy / svg-pcb

Design PCBs in the Browser
https://www.leomcelroy.com/svg-pcb-website
GNU General Public License v3.0
64 stars 9 forks source link

KiCad export: handling other layers #56

Open ducky64 opened 1 year ago

ducky64 commented 1 year ago

It seems like currently for KiCad export, only F.Cu and B.Cu layers are exported. But other layers are also important, for example board edge (Edge.Cuts) and silkscreen (F.SilkS or S.Silkscreen depending on convention).

Can these non-copper layers be exported as graphical lines, with the layer name being passed through?

kr15h commented 1 year ago

Yes, the Edge.Cuts layers will appear as soon as there is an actual shape to export. We are still working on silkscreen layers though. Would you need other layers?

ducky64 commented 1 year ago

I'd imagine Edge.Cuts and the silkscreen layers would be the most common ones (and probably a good enough start - at least good enough for my current application), though I can see more specialized flows having annotations on the other layers.

I don't know your current software architecture so this might not be helpful, but the way I'd think of implementing this is just to "convert" SVG-PCB graphical primitives to KiCad graphical primitives and pass through the layer name (relying on the user properly naming the layers). Maybe do some optional validation of names and generate a soft warning if the layer name isn't known?

For KiCad, both Edge.Cuts and silkscreen use the same underlying graphical primitives (e.g., graphical line segments, formatted slightly differently than copper trace line segments), so implementing one probably mostly solves the other. The board file is valid even if Edge.Cuts is not a closed shape (though the 3d preview and board house will probably be less happy).

kr15h commented 1 year ago

Yeah, the Edge.Cuts are there, given that there are actual lines in the layer. Just tested with the current live editor and Edge.Cuts are there. the *.Silkscreen layers show up in KiCad as well, they are just not being populated yet as we have to solve a few things before. Take a look at the screenshot below.

image

ducky64 commented 1 year ago

Oh I see, it has to be done with board.addShape("interior", ...) and isn't just propagating through lines on Edge.Cuts. Works now!