/* * This EAGLE User Language Program prints a board's * Partlist including the position and orientation * of each part. */ string orientation(real Angle, int Mirror) { string s; sprintf(s, "%.1f", Angle); for (int i = 0; s[i]; i++) if (s[i] == '.') { if (s[i + 1] == '0') s[i] = 0; break; } if (Mirror) s = "M" + s; return s; } if (board) board(B) { output(filesetext(B.name, ".CAD")) { printf("%s %s\n", "*", EAGLE_SIGNATURE); printf("*Partlist exported from %s at %s\n", filename(B.name), t2string(time())); printf("%-*s %-*s %-18s %s\n", ELEMENT_NAME_LENGTH, "*Part", PACKAGE_NAME_LENGTH, "Package", "Position (mm)", "Orientation"); printf("%s\n", "*"); B.elements(E) { if ( E.mirror == 0) { printf("%s_%-*s %-*s %7.0f %7.0f %-8s %s %s %s\n", E.name, ELEMENT_VALUE_LENGTH, E.value, PACKAGE_NAME_LENGTH, E.package.name, u2mm(E.x)*100, u2mm(E.y)*100, orientation(E.angle, E.mirror), "0.0", "1", "0"); } } printf("*\n"); printf("*\n"); printf("*\n"); printf("*\n"); printf("*\n"); printf("*\n"); printf("*\n"); /* * This EAGLE User Language Program produces a list * of all the drills and holes of a board. */ int n = 1; B.holes(H) { printf("X%03d T%03.0f %7.0f %7.0f %s %s %s %s\n", n, u2mm(H.drill)*100, u2mm(H.x)*100, u2mm(H.y)*100, "0", "0.00", "1", "0"); n=n+1;} B.elements(E) { if ( E.mirror == 1) { printf("*%s\n", E.name); } E.package.contacts(C) { if ( C.pad ) { printf("X%03d T%03.0f %7.0f %7.0f %s %s %s %s\n",n ,u2mm(C.pad.drill)*100, u2mm(C.pad.x)*100, u2mm(C.pad.y)*100, "0", "0.00", "1", "0"); n=n+1;} } E.package.holes(H) { printf("X%03d T%03.0f %7.0f %7.0f %s %s %s %s\n", n, u2mm(H.drill)*100, u2mm(H.x)*100, u2mm(H.y)*100, "0", "0.00", "1", "0"); n=n+1; } } } }