-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add the beginning of a very simplistic kicad board file parser #94
Conversation
I see now this is very similar to what kicad-rs is doing. I think it's a good approach to just extract a subset of data we want from the file, but maybe not too maintainable if we wanted to parse the entire file. |
I checked this out and it does seem like a nice simple option - since we only need the Have you thought about the next step? I had a quick look at .DXF format and dxf crate since it looks like there is a lot cross-over in 2d shapes: https://docs.rs/dxf/latest/dxf/entities/index.html. But perhaps it is just as simple a
|
@bschwind had chance to play with this a bit today. I've implemented the I think that the The result is a .stl file output...well very simple shape one (the sample.kicad_pcb does not work). Basically I can use Kicad as a simple sketching tool 😄; rectangles, circles and lines . What isn't working is Some quick testing, it seems like them being out of order causes issue - but there is no guarantee they will be in order in the file. Not 100% this is the issue but here is an example: WorksNot closed properly |
@bschwind ah, I just read https://dev.opencascade.org/doc/refman/html/class_b_rep_builder_a_p_i___make_wire.html#a8a6bc22ee4601968fe013021875f06b9
That explains it then. So I guess we need to sort the lines and edges so this is obeyed. |
Came back to this a slightly dirty fix. It turns out that Not sure whether |
@tuna-f1sh I'm on my phone so I'll link better references later, but I'm pretty sure OCC has the ability to take in a set of wires and connect them properly. I think CadQuery was using that functionality under the name "AssembleEdges" or something like that. It was likely this function: |
87b540b
to
42b3ed8
Compare
… out of a BoardLayer
42b3ed8
to
0c65c39
Compare
f608b5f
to
0dbee57
Compare
This has enough functionality to be able to import the edge cuts on a board now, including footprints which have edge cuts. I'll go ahead and merge it and refine it more later. |
Relates to #59
This is a very naively written parser, which is quite specific and targeted to just extracting the info we want from the boards. It's much more manual work. I wouldn't view this as a permanent solution, but more of a short-term thing to get the data we want.
Currently just graphic lines (
gr_line
) are extracted, but the code is structured in a way that it's fairly easy to add more extractors.Ideally, the kicad parser would integrate with
serde
or work with streaming data for larger files (probably not necessary for now).This PR is mostly just for discussion and to see if we'd want to go this direction for short-term file parsing.