// ************************************************************************* // // Silkscreen modification ULP version 1.1 13-09-2003 // // Modified by Seiichi Inoue // Author : Jesper Hansen 15-06-2000 // Based on a version by Richard Hammerl 26-05-1998 // // // Some board manufacturers want to have at least 10 mil width // for silk screen lines in order to guarantee legible results. // EAGLE libraries use 5 mil width for silk screen as default. // // This ULP changes all silk screen elements to a given minimum with. // All elements in the requested layer(s) are written into new layer(s) // or you can also let the script update the existing layer(s) by setting // the LayerOffset to 0 (see below). // // Texts are changed as well. The new ratio is is variable and should // be set to a value which will give a text line width >= 10 mils. // The default EAGLE ratio is 8%. F.i. texts with a size of 50 mil // should have a ratio of 20% to get a wire width of 10 mil. // // After running the ULP run the script file called SILKWIDTH.SCR. // The new layers (if requested) will be defined and the new silk screen // will be generated. // If you are generating new layers, please be aware that when generating // GERBER data, you have to activate the NEW layers instead of the ORIGINAL // layers. // // NOTE. All VALUE and NAME texts will be made visible. So if you have // smashed the package and deleted either VALUE or NAME text from the // silkscreen, they will again be visible with the new width. // You will have to manually delete them again. // // Modification note by Seiichi Inoue // Change the wire style parameter of "wire_style" to "wire_bend". // // // ************************************************************************* // The new linewidth in mils real LineWidth = 10.0; // The new TextRatio in percent int TextRatio = 20; // The layers to process. REMEMBER to terminate the list with a 0 (zero). int InputLayers[] = { 21, 22, 25, 26, 27, 28, 0 }; // The corresponding text directions for the layers above string Direction[] = { "R" ,"MR","R" ,"MR","R" ,"MR" }; // Set this to 0 to redraw the new data in the old layers or // set it to 100 to create new data in new layers numbered // 100 above the old layers int LayerOffset = 100; // name of output script file string ScriptName = "silkwidth.scr"; // ************************************************************************* // // no user servicable parts below this line ;-) // // ************************************************************************* // // setup any new layers as well as default wire style and grid base // void createlayers(void) { int i,j; // if new layers are requested if (LayerOffset != 0) { // for each new layer for (i=0; ( j = InputLayers[i] ); i++ ) { j += LayerOffset; // create new layer name printf("layer %d _layer%d;\n", j, j); // set new layer color printf("set color_layer %d yellow;\n\n", j); } } // set wire style printf("set wire_bend 2;\n\n"); // set grid units printf("grid mil;\n\n"); } // // handle a text object // void textsub( UL_TEXT T, // text object string Orientation, // text orientation in this layer int SourceLayer, // layer to read from int NewLayer) // layer for new/modified data { // handle only given layer if (T.layer == SourceLayer) { // write layer and size data printf("Layer %d;\n", NewLayer); printf("Change Size %5.3f;\n", u2mil(T.size)); // modify ratio if below our threshold if (T.ratio < TextRatio) printf("Change Ratio %d;\n", TextRatio); // print the text printf("TEXT '%s' %s%1.0f (%5.3f %5.3f);\n", T.value, Orientation, T.angle, u2mil(T.x), u2mil(T.y)); } } // // handles all parts of a board element // void changeelements( UL_ELEMENT E, // current element object string Orientation, // text orientation in this layer int SourceLayer, // layer to read from int NewLayer) // layer for new/modified data { real width; // stores current/new width // go through all wires on the board E.package.wires(W) { // only work on the requested layer if (W.layer == SourceLayer) { // setup variable with at least the requested width width = u2mil(W.width); if ( width < LineWidth ) width = LineWidth; // write data for layer and the new wire printf("Layer %d;\n", NewLayer); printf("WIRE %5.3f (%5.3f %5.3f) (%5.3f %5.3f);\n", width, u2mil(W.x1), u2mil(W.y1), u2mil(W.x2), u2mil(W.y2)); } } // do the circles E.package.circles(C) { if (C.layer == SourceLayer) { // setup variable with at least the requested width width = u2mil(C.width); if ( width < LineWidth ) width = LineWidth; // write data for layer and the new circle printf("Layer %d;\n", NewLayer); printf("CIRCLE %5.3f (%5.3f %5.3f) (%5.3f %5.3f);\n", width, u2mil(C.x), u2mil(C.y), u2mil(C.x + C.radius), u2mil(C.y)); } } // and the arcs E.package.arcs(A) { // only work on the requested layer if (A.layer == SourceLayer) { // setup variable with at least the requested width width = u2mil(A.width); if ( width < LineWidth ) width = LineWidth; // write data for layer and the new arc printf("Layer %d;\n", NewLayer); printf("ARC %5.3f ccw (%5.3f %5.3f) (%5.3f %5.3f) (%5.3f %5.3f);\n", width, u2mil(A.x1), u2mil(A.y1), u2mil(2*(A.xc)-A.x1), u2mil(2*(A.yc) - A.y1), u2mil(A.x2), u2mil(A.y2)); } } // do rectangles E.package.rectangles(R) { // only work on the requested layer if (R.layer == SourceLayer) { // rectangles have no line width, just reproduce them // this is not really needed if we're using an offset of 0, // but what the hey printf("Layer %d;\n", NewLayer); printf("RECT (%5.3f %5.3f) (%5.3f %5.3f);\n", u2mil(R.x1), u2mil(R.y1), u2mil(R.x2), u2mil(R.y2)); } } // handle the polygons E.package.polygons(P) { // only work on the requested layer if (P.layer == SourceLayer) { // setup variable with at least the requested width width = u2mil(P.width); if ( width < LineWidth ) width = LineWidth; // write data for layer printf("Layer %d;\n", NewLayer); // draw first edge P.wires(WP) { printf("POLYGON %5.3f (%5.3f %5.3f)\n ", width, u2mil(WP.x1), u2mil(WP.y1)); break; } // draw other edges P.wires(WP) printf(" (%5.3f %5.3f)", u2mil(WP.x2), u2mil(WP.y2)); // close polygon printf(";\n"); } } // finally handle element texts E.package.texts(T) textsub(T, Orientation, SourceLayer, NewLayer); // this is also element texts E.texts(T) textsub(T, Orientation, SourceLayer, NewLayer); } // // change free texts in the given source layer // void changetext( UL_BOARD B, string Orientation, // text orientation in this layer int SourceLayer, // layer to read from int NewLayer) // layer for new/modified data { B.texts(T) textsub(T, Orientation, SourceLayer, NewLayer); } // // main entry point // if (board) board(B) { int i,j; // loop vars // redirect printf output to the script file output(ScriptName) { // write initial layer data createlayers(); // for each requested layer for (i=0; ( j = InputLayers[i] ); i++ ) { // handle elements B.elements(E) changeelements(E, Direction[i], j, j+LayerOffset); // handle free texts changetext(B, Direction[i], j, j + LayerOffset); } } }