/****************************************************************************** * ROB.ULP - please send any comments to hv@itec-audio.com * * This EAGLE User Language Program prints a board's * Partlist and its "Bill Of Material" * * V1.0 16.07.99 Helmut Vaupotitsch - hv@itec-audio.com * SkipPartsNoValue = Yes: Donīt count parts with no value in summary. * * Output-script in {filename}.BOM * Errorlevel -1: Drawing is not a board * *****************************************************************************/ enum {Yes, No}; int SkipPartsNoValue = No; enum { OK=0, NotABoard=-1 }; int ExitCode; string orientation(real Angle, int Mirror) { string s; sprintf(s, "%05.1f", Angle); if (Mirror) s = "M" + s; return s; } void PartLine(string Pos, string Value, string Position, string Orient, string res1, string Name, string res2) { printf("%s,%-*s,%s,%s,%s,%-*s,%s\n", Pos, ELEMENT_VALUE_LENGTH, Value, Position, Orient, res1, ELEMENT_NAME_LENGTH, Name, res2); } /********************/ /* --- HP --- */ /********************/ ExitCode = NotABoard; if (board) board(B) { ExitCode = OK; output(filesetext(B.name, ".ROB")) { printf("%s at %s\n", B.name, t2string(time())); printf("Last modified: %s\n",t2string(filetime(B.name))); string YesNo[] = {"Yes", "No"}; printf("Settings: Units=mm, SkipPartsNoValue=%s\n", YesNo[SkipPartsNoValue]); numeric string ename[], evalue[], pname[], lname[], PInch[], PMM[], Orient[]; int cnt = 0, index[]; string Pos; B.elements(E) { ename[cnt] = E.name; evalue[cnt] = E.value; pname[cnt] = E.package.name; lname[cnt] = E.package.library; sprintf(PInch[cnt], "%06.3f,%06.3f", u2inch(E.x), u2inch(E.y)); sprintf(PMM[cnt], "%06.2f,%06.2f", u2mm(E.x), u2mm(E.y)); Orient[cnt] = orientation(E.angle, E.mirror); cnt++; } sort(cnt, index, ename); sprintf(Pos, "%04d", cnt); PartLine(Pos, "0", "0", "0,0", "0", "0", "0"); //PartLine(Pos, "Value", "Position[mm]", "Rot", "", "Name", " 1"); for (int i = 0; i < cnt; i++) { sprintf(Pos, "%04d", i+1); PartLine(Pos, evalue[index[i]], PMM[index[i]], Orient[index[i]], "", ename[index[i]], " 1"); // ename[index[i]], evalue[index[i]], // pname[index[i]], lname[index[i]], // PInch[index[i]], PMM[index[i]], Orient[index[i]] ); } printf(""); } // Output } exit(ExitCode);