Crate altium

Source
Expand description

§Altium file format library for Rust

A tool to process Altium file types. Currently this tool is in alpha and only has minimal components fully functioning (so please expect breaking changes!).

This is intended as a replacement for my original tool PyAltium

§Project Progress

The goal of this project is to support most file types used by Altium. Reading is a priority, writing will be implemented for some types. The status of various file types is listed below:

ExtensionList ItemsDisplayWriteDocumentation
Binary Schematic Library.SchLibPoorlyGood
Binary PCB Library.PcbLib
Binary Schematic Doc.SchDoc
Binary PCB Doc.PcbDoc
Draftsman Doc.PcbDwf
PCB Project.PrjPcb
Material Library.xmlN/A
Any templatesNot Planned

§Examples

See altium/examples for some sample usage. Example reading components in a schematic library:

use altium::SchLib;

fn main() {
    let lib = SchLib::open("tests/samples/schlib/simple.SchLib").unwrap();

    // List all librefs stored in this schematic library
    for meta in lib.component_meta() {
        println!(
            "libref: {}, description: {}",
            meta.libref(),
            meta.description()
        );
    }

    // Get a single component by libref
    let mycomp = lib.get_component("Resistor - Standard").unwrap();

    // Write that image to a SVG file. Note that output is pretty buggy still.
    mycomp.save_svg("resistor.svg").unwrap();
}

§License

Currently, this is licensed under Apache 2.0. Tools for to reading and writing files produced by Altium Designer.

It is very early in development, so please expect surprises if you are using it!

§Units

Unless otherwise stated, we try to use the following conventions:

  • For integer values, 1 = 1.0 nm
  • For floating point values, 1.0 = 1.0 m

1nm precision is pretty excessive for what we need. However, it allows us to represent anything from surface coating up to a 2.2 x 2.2 m PCB in an i32, which is more than sufficient for the vast majority of use cases.

Modules§

draw
Tools related to drawing objects
dwf
Draftsman parsing
error
Error types used throughout this crate
font
Objects related to font as Altium sees it.
pcb
Everything related to PCB documents (.PcbDoc) and schematic libraries (.PcbLib)
prj
.PrjPcb configuration
sch
Everything related to schematic documents (.SchDoc) and schematic libraries (.SchLib)

Structs§

Error
Our main error type is an error (ErrorKind) plus some context for what caused it, a quasi-backtrace.
Location
Common coordinate type
PcbDoc
A PCB Document
PcbLib
A PCB Library
PrjPcb
Representation of a PCB Project file (.PrjPcb)
Rgb
RGB color
SchDoc
Representation of a schematic file
SchLib
This is our top-level representation of a schematic library.

Enums§

ErrorKind
A raw error without context. See Error for more information.
Rotation90
Rotation when only 4 values are allowed
UniqueId
A unique ID that is assigned by Altium to each element in a design.
Visibility

Type Aliases§

Result
The main result type used by this crate