app
Board to Molecule
Public Made by Adomby adom
Turn any KiCad, Fusion/EAGLE, or Altium board into an Adom molecule: wings plus MP1-MP4 machine pins, written back in the board's own format.
main
Colby Knox
board-to-molecule 1.0.0: Rust source, six before/after examples (KiCad, Fusion, Altium), Adom 3D viewer readme
eb9ea91
4d ago
//! Altium .PcbDoc lane (OLE2 compound file).
//!
//! Reading follows KiCad's Altium importer field by field. Writing copies the
//! source compound file and rewrites only the streams the molecule changes, so
//! every other stream stays byte-identical.
mod read;
mod rec;
mod write;
use crate::model::Board;
use crate::plan::{BBox, Plan};
use anyhow::Result;
use serde_json::Value;
use std::path::Path;
/// Board outline bbox in mm, Y up, in Altium's own absolute frame.
pub fn outline_bbox(path: &Path) -> Result<BBox> {
let mut cf = read::open(path)?;
let p = read::board6_props(&mut cf)?;
let shapes = read::outline_shapes(&read::board_vertices(&p), 0.0);
let b = crate::model::bbox_of_shapes(&shapes);
if b.is_empty() {
anyhow::bail!("no board outline found in Board6");
}
Ok(b)
}
/// Preview model of the board.
pub fn read(path: &Path) -> Result<Board> {
read::read(path)
}
/// Write a molecule .PcbDoc: outline replaced by plan.new, MP1..MP4 added.
pub fn write_molecule(src: &Path, plan: &Plan, out: &Path) -> Result<Value> {
write::write_molecule(src, plan, out)
}