/* * $Id: //DukePro/eagle/ulp/fixdrills.ulp#4 $ * $DateTime: 2012/06/16 19:03:18 $ * * This will round via sizes to the nearest mil. */ #usage "Fixes metric vias to mil vias." string file; board(B) { // We're going to execute a script upon exit from this ulp. // This is the script to which commands should be written. file = filedir(B.name) + "fixdrills.scr"; output(file, "wtD") { real mils; int fixedMils; int um; // Switch the grid to mils. printf("GRID mil;\n"); // Spin through the board's signals B.signals(SIG) { // Spin through each via on this signal. SIG.vias(VIA) { // Convert to mils mils = u2mil(VIA.drill); // Round the via drill size to the nearest mil fixedMils = round(mils); // Different rounding methods: // // Round up to the next largest mil // fixedMils = round(mils + 0.5); // // Round up the next largest multiple of 5 mils. // fixedMils = round(mils/5.0 + 0.5) * 5.0; // Emit some eagle script to effect this change. Note that // the x and y coordinates are also maintained in .1um. Since // our grid is in mil, the coords need to be expressed in mils. printf("CHANGE DRILL %d (%f %f);\n", fixedMils, u2mil(VIA.x), u2mil(VIA.y)); } // end of signal.vias() } // end of board.signals() // Restore the previous grid settings. printf("GRID LAST;\n"); } // end of output() } // end of board() // By here, the script has been written. // Exit this ulp and execute the newly created script. exit("SCRIPT '" + file + "';"); /* vim:set ts=4 sw=4 et ai: */