/****************************************************************************** * REPLACE.ULP - please send any comments to hv@itec-audio.com * * This EAGLE User Language Program generates a script file * which replaces packages of the current board. * * V1.0 30.06.99 Helmut Vaupotitsch - hv@itec-audio.com * * Details in file {Details} * (which elements were replaced?) * * Errorlevel -1: Drawing is not a board * Errorlevel -2: No elements with "OldPackage" found * *****************************************************************************/ enum { FALSE=0, TRUE=1 }; int RunScript = TRUE; // if true, run the script after generation, // then delete it string OldPackage = "E3,5-8"; // this package should be replaced //string OldPackage = "CT3216"; // this package should be replaced string NewPackage = "E3,5-8"; // The new package //string NewPackage = "CT3528"; // The new package //string NewPackage = "0805"; // The new package //string NewPackage = "C0603"; // The new package string NewLibrary = "itec.lbr"; // lib-file of the new package int SameName = FALSE; // if TRUE, overrides "OldPackage" with // "NewPackage"!!! string ScrFileName = "Replace.scr"; string Details = "Replace.Det"; enum { OK=0, NotABoard=-1, NoneFound=-2 }; int ExitCode; /********************/ /* --- HP --- */ /********************/ ExitCode = NotABoard; if (board) board(B) { ExitCode = OK; if (SameName == TRUE) OldPackage=NewPackage; int anz=0; output(Details) { printf("Detailed info on running REPLACE.ULP for board\n%s, modified on %s\n\n",B.name,t2string(filetime(B.name))); printf("Search for package %s\nand replace it with package %s from library '%s'\n\n", OldPackage,NewPackage,NewLibrary); printf("Part Value Position inch Position mm\n\n"); } output(ScrFileName) { printf("GRID MIL;\n"); printf("USE %s;\n", NewLibrary); printf("SET REPLACE_SAME NAMES;\n"); printf("REPLACE %s\n", NewPackage); B.elements(E) { UL_PACKAGE pac = E.package; if (pac.name == OldPackage) { // replace the old package printf("(%f %f)\n", u2mil(E.x),u2mil(E.y)); output(Details,"at") { printf("%-*s %-*s (%6.3f %6.3f) (%6.2f %6.2f)\n", ELEMENT_NAME_LENGTH, E.name, ELEMENT_VALUE_LENGTH, E.value, u2inch(E.x), u2inch(E.y), u2mm(E.x), u2mm(E.y)); } anz++; } } printf("\nGRID LAST;\n"); output(Details,"at") printf("\n%d packages will be replaced.\n", anz); } // Output if (anz==0) ExitCode = NoneFound; else if (RunScript==TRUE) { // SCRIPT ScrFileName; } } exit(ExitCode);