#usage "snap pins in symbol to grid

" "Eaxample: run snap-pin-in-lbr [100]" "Author: librarian@cadsoft.de" string cmd; real Grid = 100; // default 100 Mil string s; real xoff, yoff; if (argv[1]) Grid = strtod(argv[1]); real snap(int n) { // returns next grid point return round(u2mil(n) / Grid) * Grid; } int move = 0; if (library) { if (symbol) symbol(S) { string name = S.name; S.pins(P) { // *** Pins auf Grid 50 Mil testen 4.02.2003 -alf xoff = snap(P.x) - u2mil(P.x); yoff = snap(P.y) - u2mil(P.y); if (xoff || yoff) { move = 1; sprintf( s, "MOVE (%.5f %.5f) (%.1f %.1f);\n", u2mil(P.x), u2mil(P.y), snap(P.x), snap(P.y)); cmd += s; } } if (move) { if (dlgMessageBox(cmd, "OK", "Cancel") != 0) exit (-1);; exit("GRID MIL FINEST;\n" + cmd + "GRID MIL 100 1 ON;"); } else dlgMessageBox("PINs in " + name + ".SYM on Grid", "OK"); } else dlgMessageBox("Start this ULP in a Symbol-Editor", "OK"); } else dlgMessageBox("Start this ULP in Library (Symbol)", "OK");