Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LibraryViewer/LibraryViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="OpenMcdf" Version="2.2.1.6" />
<PackageReference Include="OpenMcdf" Version="2.2.1.12" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.355802">
<PrivateAssets>all</PrivateAssets>
Expand Down
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,29 @@ Before using AltiumSharp, you will need to add the following NuGet references to
* [OpenMcdf](https://www.nuget.org/packages/OpenMcdf) by [ironfede](https://github.com/ironfede)
* [System.Text.Encoding.CodePages](https://www.nuget.org/packages/System.Text.Encoding.CodePages)

Once you have these references added, you can use the AltiumSharp library to read and write Altium library files and render components as images. Check out the examples in the readme for more information on how to use AltiumSharp in your projects.
Once you have these references added, you can use the AltiumSharp library to read and write Altium library files and render components as images. The LibraryViewer is an example application that implements the AltiumSharp library. You can build and run LibraryViewer to view PcbLib and SchLib files.

To run the viewer, open the cloned repository in Visual Studio 2022, build both projects, and use either Ctrl + F5 or the Green Start button to start an instance of LibraryViewer on your machine.

## Opening a PcbLib File
Here's an example of how you can use AltiumSharp to open a PcbLib file and iterate through its components:
```csharp
// Import the library to your project
using OriginalCircuit.AltiumSharp;

// Open a PcbLib file.
using (var reader = new PcbLibReader(fileName))
using (var reader = new PcbLibReader())
{
// Read the file.
reader.Read();
var data = reader.Read(filename);

// Iterate through each component in the library.
foreach (var component in reader.Components)
{
// Print information about the component.
Console.WriteLine($"Name: {component.Name}");
Console.WriteLine($"Number of Pads: {component.Pads}");
Console.WriteLine($"Number of Primitives: {component.Primitives.Count()}");
}

// Retrieve settings from the header.
_displayUnit = reader.Header.DisplayUnit;
_snapGridSize = reader.Header.SnapGridSize;
_components = reader.Components.Cast<IComponent>().ToList();
foreach (var component in data.Items)
{
Console.WriteLine(component.Pattern);
Console.WriteLine(component.Description);
Console.WriteLine(component.Height);
}
}
```

Expand Down