Skip to content

Instantly share code, notes, and snippets.

@psd psd/bom-json.ulp
Created Jul 25, 2011

What would you like to do?
Eagle CAD save a Bill of Materials as JSON
#require 4.1105
#usage "en: <b>Export a Bill Of Materials as JSON</b>\n"
" Saves a project's <i>Bill Of Material</i> as a <i>project</i>.json"
" suitable for uploading to"
" <author>Author:</author>"
if (!schematic) {
dlgMessageBox(usage + "<hr><b>ERROR: No schematic!</b><p>\nThis program can only work in the schematic editor.");
schematic(SCH) {
string FileName;
string json;
string sep = "";
FileName = filesetext("bom", ".json");
output(FileName, "wt") {
printf("\t\"items\": [\n"); {
if (P.device.package) {
json = sep + "\t\t{\n"
+ "\t\t\t\"designator\": \"" + + "\",\n"
+ "\t\t\t\"value\": \"" + P.value + "\",\n"
+ "\t\t\t\"description\": \"" + P.device.headline + "\"\n"
+ "\t\t}";
sep = ",\n";
printf("%s", json);

This comment has been minimized.

Copy link
Owner Author

psd commented Jul 25, 2011

Open a .sch file in Eagle, and run this script. Generates a .json file without any prompting meaning it runs from the command line, e.g.:

$ eagle -C'RUN bom-json.ulp; QUIT;' foo.sch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.