Open sjgallagher2 opened 1 day ago
Hi, thanks for the suggestion.
In general PyGerber was designed with support for other PCB-realted file formats in mind and hence addiotion of IPC-2851 related modules is welcome. I have reached out to IPC-2581 consortium via contact form, we will see how they respond. I am not so keen on reverse enginieering the format as I am not interested in facing legal action for violation of intelectual property. Additionally I would like the implementation to be high quality rather than limited by what we could have guessed on our own.
Assuming positive response on their side, we could look into implementation of IPC-2851. I must admit that currently I don't have enough processing capacity to tackle it myself, so help would be welcome.
Since implementation will likely require additional dependencies I would prefer to have this feature as dedicated extras set to avoid limiting poratability of PyGerber and keep minimal set of dependencies required to use core functionalities of PyGerber (similarily to how language server and SVG rendering is done). Implementation details are yet to be discussed, but I would like to mention tools like CadQuery and lxml/BeautifulSoup4 which could be helpful in implementing IPC-2851.
I hope that Ucamco wont feel ofended by addition IPC-2851 but if they happen to be, we will probably resort to creating separate library for that.
This may be out of scope for this project, but I think
pygerber
has enough infrastructure to add support for IPC2581. That standard is supported by an increasing number of board houses and CAD packages, and parsing the files is fairly straightforward.A CAD packages produces a
.cvg
file, which is an XML file following the IPC2581 standard. Unfortunately, the standard is not freely available (unless you become a member, which is free). Even still, being a plain text XML file it's easy to understand the structure:IPC-2581
(root)Content
- Layer names, color dictionary, standard shapes with unitsLogisticHeader
- Owner and enterprise information, if applicableBom
- Collection ofBomItem
s, each having attributes relating to a component in the BOMEcad
- Layer stackup and materials, layer geometryMost interesting is the
Ecad
node. It is divided intoCadHeader
andCadData
. TheCadHeader
has layers inSpec
nodes which have optionalMATERIAL
properties, e.g.Solder Resist
. TheCadData
node contains layer information (each layer has a name, function, side, and polarity), stackup information under aStackup
node, and actual geometry (both traces and component geometry) under aStep
node.Here's a sort of tree view of the nodes:
This is not comprehensive, it's built up based on a random example file I had.
Examples
Parsing Layers and Nets
Parsing Line and Arc Elements
IPC2581 has information on geometry, stackup, BOM, components, vias, and pads. This means generating 3D geometry is possible without any additional information, and everything is in a single file which is convenient. I wrote myself a simple proof-of-concept program that uses Open CASCADE Technology (OCCT) as the geometry kernel, so you can generate .IGES and .STEP files. The only tools available for generating CAD data from Gerbers or IPC2581
.cvg
files seem to be paid tools (e.g. Zofsz, NETEX-G) so including basic export functionality for STEP or IGES could be a good addition. But that's just one reason why IPC2581 support would be beneficial.