// THIS PROGRAM IS PROVIDED AS IS AND WITHOUT WARRANTY OF ANY KIND, // EXPRESSED OR IMPLIED. /* * This EAGLE User Language Program produces a script * file that can be used to snap the symbols of the * current shematic to default grid (0.1 Inch). * * Dieses EAGLE ULP generiert ein Script um die Symbole * im aktuellen Schaltplan auf das Default-Grid zu setzen. * Das Default-Grid ist 0,1 Inch. * * Author: A. Zaffran 16.09.1999 alf@cadsoft.de */ real Grid = 100; // in 100 Mil real snap(int n) // returns next grid point { return round(u2mil(n) / Grid) * Grid; } void setgridmil (void) { printf("GRID mil;\n"); printf("GRID 0.01;\n"); } void setgridmic (void) { printf("GRID mic;\n"); printf("GRID 0.1;\n"); } schematic(S) { output("snapsch.scr") { S.sheets(SH) { printf("EDIT .S%d;\n", SH.number); SH.parts(PA) { PA.instances(S) { // *** Symbol auf Grid 100 MIL testen real xoff = ((u2mil(S.x)/Grid) - round(u2mil(S.x)/Grid)) * Grid; real yoff = ((u2mil(S.y)/Grid) - round(u2mil(S.y)/Grid)) * Grid; if (xoff || yoff) { setgridmic (); // *** switch grid to 0.1 micron for *** printf("MOVE (%.1f %.1f)\n", u2mic(S.x), u2mic(S.y)); setgridmil (); // *** move with out offset *** printf("(%.1f %.1f);\n", snap(S.x), snap(S.y)); } } } } printf("GRID INCH;\n"); printf("GRID 0.1;\n"); } }