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

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

Structs

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

Enums

Type Aliases

  • The main result type used by this crate