#usage "

\n" "

Parts v1.1

\n" "This EAGLE User Language Program shows all devices,\n" "packages and libraries separately for board and schematic \n" "and allows to write a file for copying to Excel.
\n" "For the schematic only devices with packages are shown.

\n" "Author: Walter Mücke (c)2002

" string version = "Parts v1.1"; numeric string alf_brd[], alf_sch[]; string p_namet; string InputFileName; string OutputFileName; int alf_brd_nr, alf_sch_nr, l, sp, answ; //+++++++++++++ void file_output(void) { int result = dlgDialog("Partliste speichern") { dlgSpacing(10); dlgLabel("For " + InputFileName + " a partlist will be generated."); dlgSpacing(10); dlgHBoxLayout { dlgLabel("File&name"); dlgStringEdit(OutputFileName); dlgPushButton("Bro&wse") { string FileName = dlgFileSave("Save as Parts File", OutputFileName, "Text files (*.txt)"); if (FileName) OutputFileName = FileName; } } dlgSpacing(30); dlgStretch(1); dlgHBoxLayout { dlgSpacing(100); dlgStretch(1); dlgPushButton("+&Ok") { string a[]; if (!fileglob(a, OutputFileName) || dlgMessageBox("The file '" + OutputFileName + "' exist.\n\nOverwrite?", "+&Yes", "-&No") == 0) dlgAccept(); } dlgPushButton("&Info") dlgMessageBox(usage + "
"); dlgPushButton("-&Cancel") dlgReject(10); answ = 1; dlgStretch(1); dlgSpacing(100); } }; if (result != 10) { output(OutputFileName) { int t = time(); printf("%s\n", EAGLE_SIGNATURE); printf("Schematic partlist for devices with packages for %s at %02d.%02d.%02d %02d:%02d:%02d.\n", InputFileName, t2day(t), t2month(t) + 1, t2year(t), t2hour(t), t2minute(t), t2second(t)); printf("The list is generated with '" + version + "' and formatted for copying to Microsoft Excel.\n\n"); printf("Part\tDevice\tValue\tPackage\tLibrary\n\n"); for(l = 0; l < alf_sch_nr; l++) printf("%s\n", alf_sch[l]); } } } //++++++++++++ void GenerateSection(void) { if (project.board && project.schematic) { project.board(B) { B.elements(E) { string e_name = E.name + " "; string e_value = E.value + " "; string e_pname = E.package.name + " "; string e_plib = E.package.library + " "; string e_layer; if (E.mirror == 0) e_layer = "1"; else e_layer = "16"; alf_brd[alf_brd_nr] = e_name + "\t" + e_value + "\t" + e_pname + "\t" + e_plib + "\t" + e_layer; alf_brd_nr++; } } project.schematic(S) { S.sheets(SH){ SH.parts(P) P.instances(I) { if(P.device.package){ string p_name = P.name + " "; string p_nam = P.name; string p_dname = P.device.name + " "; string p_value = P.value + " "; string p_dpname = P.device.package.name + " "; string p_dplib = P.device.package.library; if (p_namet != p_nam){ alf_sch[alf_sch_nr] = p_name + "\t" + p_dname + "\t" + p_value + "\t" + p_dpname + "\t" + p_dplib; alf_sch_nr++; } p_namet = p_nam; } } } } } } //++++++++++++++ // Main program: //++++++++++++++ if (project.board && project.schematic) { if (board) { board(B) OutputFileName = B.name; } else if (schematic) { schematic(S) OutputFileName = S.name; } } else { dlgMessageBox(usage + "

\n" "ERROR: \n" "
No proper project !

\n" "

This program can work only with a consistent project.
"); exit(1); } InputFileName = filesetext(OutputFileName, ".sch"); OutputFileName = filesetext(OutputFileName, "_parts.txt"); GenerateSection(); dlgDialog(version) { dlgVBoxLayout { dlgHBoxLayout { dlgVBoxLayout dlgSpacing(680); dlgVBoxLayout { dlgSpacing(10); dlgLabel("Parts in the Board"); l = -1; dlgListView("Part\tValue\tPackage\tLibrary\tLayer", alf_brd, l); } dlgVBoxLayout { dlgSpacing(10); dlgLabel("Parts in the Schematic"); l = -1; dlgListView("Part\tDevice\tValue\tPackage\tLibrary", alf_sch, l); } } dlgHBoxLayout { dlgStretch(1); dlgPushButton("&File") file_output(); dlgPushButton("&Info") dlgMessageBox(usage + "
.                                  .
"); dlgPushButton("+E&xit") dlgAccept(); dlgStretch(1); } } };