Skip to content

vehar/AltiumSharp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AltiumSharp

Reads and writes Altium library files, rendering them with C#. Many thanks to Tiago Trinidad (@Kronal on Discord) for his huge efforts on this library.

Usage

Opening a PcbLib File

// open a PcbLib file.
using (var reader = new PcbLibReader(fileName))
{
    // read the file
    reader.Read();

    // iterate through each component in the library
    foreach (var component in reader.Components)
    {
        Console.WriteLine($"{component.Name}, {component.Pads}, {component.Primitives.Count()}");
    }

    // Settings in the header.
    _displayUnit = reader.Header.DisplayUnit;
    _snapGridSize = reader.Header.SnapGridSize;
    _components = reader.Components.Cast<IComponent>().ToList();
}

Open a SchLib File

// open a SchLib file.
using (var reader = new SchLibReader(fileName))
{
    reader.Read();

    // iterate through each component in the library
    foreach (var component in reader.Components)
    {
        Console.WriteLine($"{component.Name}, {component.Description}");
    }

    // settings in header.
    _displayUnit = reader.Header.DisplayUnit;
    _snapGridSize = reader.Header.SnapGridSize;
    _components = reader.Components.Cast<IComponent>().ToList();
}

Rendering a Component

_renderer = new PcbLibRenderer();

if (_renderer != null)
{
    _renderer.Component = _activeComponent;
    
    if (_pictureBoxImage == null) _pictureBoxImage = new Bitmap(pictureBox.Width, pictureBox.Height);
    using (var g = Graphics.FromImage(_pictureBoxImage))
    {
        _renderer.Render(g, pictureBox.Width, pictureBox.Height, _autoZoom, fastRendering);
    }
    _autoZoom = false;
}

About

C# .NET Standard library to read Altium library files and render them

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%