-
Notifications
You must be signed in to change notification settings - Fork 29
WIP: [kicad-parser] write a KicadBoard #201
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
base: main
Are you sure you want to change the base?
Conversation
@bschwind The current data model seems to assume that the |
Yep, let's keep these as separate types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking pretty good so far! A few questions:
- What's the scope for this PR, or when do we consider it "done"? When we can write out a fully-functioning
*.kicad_pcb
file? - It would make sense to have a
write_to_file<P: AsRef<Path>>(file: P)
convenience function - Pretty printing of the S-expressions would be nice, maybe the
sexp
crate doesn't support that though - Just for fun I tried exporting a
kicad_pcb
file by reading thesample.kicad_pcb
file and immediately serializing it again. When trying to read it into KiCAD, I got:

|
||
pub fn write_board<W: std::io::Write>( | ||
writer: &mut W, | ||
board: &KicadBoard, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this instead be KicadPcb
? I think my original plan was for KicadBoard
to hold the actual board data like copper, footprints, silkscreens, etc, while KicadPcb
would hold a KicadBoard
, as well as extra data like the version and other metadata.
fn circle_to_sexp(circle: &GraphicCircle) -> Sexp { | ||
let items = vec![ | ||
atom_s("gr_circle"), | ||
cons_s("start", point_to_sexp(circle.center_point)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cons_s("start", point_to_sexp(circle.center_point)), | |
cons_s("center", point_to_sexp(circle.center_point)), |
atom_s(layer_str) | ||
} | ||
|
||
fn position_to_sexp(location: (f64, f64), rotation_degrees: f64) -> Sexp { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might call this orientation_to_sexp
or transform_to_sexp
, as I expected position
to just mean an XY coordinate.
No description provided.