{{{ #!html Test to make a solder stencil using the "Craft ROBO" cutting plotter (also sold as "Silhouette"). The paper is just for testing. }}} == EAGLEで作った基板のハンダマスクをCraft ROBOで作る == 表面実装用の、ハンダマスクっていうか、Solder Stencilっていうか。 Craft ROBOでお手軽に作っちゃおうという魂胆です。 Craft ROBOの専用ソフトROBO Masterには、DXFを読み込む機能があります。 じゃ、EAGLEからDXFを吐き出せばOKじゃん!って思いましたが、うまくいきません。 EAGLEに付属のdxf.ulpで出力したDXFファイルをROBO Masterに読み込ませると、「有効なデータがありません」とか怒られます。 いろいろ悩んで設定を試してみましたが、どうしてもうまくいかないので、スクリプトを自分で作ることにしました。 DXFのフォーマットは変態だし、ULPをいじったのは初めてだしで、ちょっと悩みましたが、とりあえず動いています。 近々、実際にカットしてみます。うまくいくといいんですが。 サポートしているのは、tCream/bCreamレイヤに有るパッドのうち、四角の物だけです。 パッドの角を丸めてあっても、四角として扱います。 その他の図形は、存在しても出力しません。 パネライズが必要な場合は、事前にEAGLEの上で手作業で行うといいでしょう。 基板の外形やトンボなどは、全く出力しません。 目で基板と合わせてください。 ROBO MasterでDXFを読み込んだだけでは、原点=左下角近くに配置されています。 クリームはんだの印刷の都合を考えると、シートの真ん中辺りに配置して有る方がいいと思います。 読み込んだあとに、手作業で移動させてください。 == Make a solder stencil using the "Craft ROBO" cutting plotter == Here is an EAGLE ulp script to produce DXF files for tCream and bCream layers. Just copy and paste to a file named "cream-dxf.ulp", and drop in the EAGLE ulp directory. In the board window, type "run cream-dxf" and enter key. "''board''-tcream.dxf" and "''board''-bcream.dxf" will appear in the directory whre "''board''.brd" is. You can import these DXF files in the "Craft ROBO" support software ("ROBO Master"). Limitation: Only rectangle SMD pads are supported. "Roundness" parameter is just ignored. EAGLE provides "dxf.ulp", but this will not produce a correct DXF file for cream layers. == The code == 最新のコードは、[https://gist.github.com/703363 Github]にあります。 The latest code is on [https://gist.github.com/703363 Github]. {{{ #!c // // Export the EAGLE cream layers to DXF for the Craft-ROBO cutting plotter. // // Copyright (c) 2010 Switch Science, Inc. // // Type "run cream-dxf" in the board editor window. // Options: // -o Add one more line segment for pads to make sure the cut. // -c Cut off corners of pads. The resulting pads are octagons. // // Configuration real SHRINK_WIDTH = 0.15; // unit: mm real MIN_CORNERRADIUS = 0.05; // unit: mm // Flags int CORNERCUT = 0; // boolean int OVERCUT = 0; // boolean string HEADER = " 0\n" "SECTION\n" " 2\n" "HEADER\n" " 9\n" "$ACADVER\n" " 1\n" "AC1013\n" " 9\n" "$MEASUREMENT\n" " 70\n" " 1\n" // unit: mm " 0\n" "ENDSEC\n" " 0\n" "SECTION\n" " 2\n" "ENTITIES\n"; string POLYLINE = " 0\n" "LWPOLYLINE\n" " 8\n" "0\n" // layer " 62\n" "7\n" // color " 90\n" "%d\n" // number of points " 70\n" "%d\n"; // 0=open 1=close string POLYLINE_POINT = " 10\n" "%f\n" " 20\n" "%f\n"; string LINE = " 0\n" "LINE\n" " 8\n" "0\n" // layer " 10\n" "%f\n" // start x " 20\n" "%f\n" // start y " 11\n" "%f\n" // end x " 21\n" "%f\n"; // end y string ARC = " 0\n" "ARC\n" " 8\n" "0\n" // layer " 10\n" "%f\n" // center x " 20\n" "%f\n" // center y " 40\n" "%f\n" // radius " 50\n" "%f\n" // start angle " 51" "%f\n"; // end angle string CIRCLE = " 0\n" "CIRCLE\n" " 8\n" "0\n" // layer " 10\n" "%f\n" // center x " 20\n" "%f\n" // center y " 40\n" "%f\n"; // radius string TRAILER = " 0\n" "ENDSEC\n" " 0\n" "EOF\n"; int processLayer(UL_BOARD B, int layer) { int count = 0; int cream = (layer == LAYER_TOP ? LAYER_TCREAM : LAYER_BCREAM); printf("%s", HEADER); B.elements(E) { E.package.contacts(C) { if (C.smd && C.smd.layer == layer) { real x = C.smd.x / 10000.0; real y = C.smd.y / 10000.0; real w = C.smd.dx[cream] / 10000.0 / 2 - SHRINK_WIDTH; real h = C.smd.dy[cream] / 10000.0 / 2 - SHRINK_WIDTH; real a = C.smd.angle / 180 * PI; real wc = w * cos(a); real hs = h * sin(a); real ws = w * sin(a); real hc = h * cos(a); real r = max(min(w, h) * C.smd.roundness / 100, MIN_CORNERRADIUS); if (CORNERCUT && h > r && w > r) { real rc = r * cos(a); real rs = r * sin(a); if (OVERCUT) { printf(POLYLINE, 10, 0); // 10 points, open polyline printf(POLYLINE_POINT, x + wc, y + ws); // (w, 0) printf(POLYLINE_POINT, x + wc - hs + rs, y + ws + hc - rc); // (w, h-r) printf(POLYLINE_POINT, x + wc - rc - hs, y + ws - rs + hc); // (w-r, h) printf(POLYLINE_POINT, x - wc + rc - hs, y - ws + rs + hc); // (-w+r, h) printf(POLYLINE_POINT, x - wc - hs + rs, y - ws + hc - rc); // (-w, h-r) printf(POLYLINE_POINT, x - wc + hs - rs, y - ws - hc + rc); // (-w, -h+r) printf(POLYLINE_POINT, x - wc + rc + hs, y - ws + rs - hc); // (-w+r, -h) printf(POLYLINE_POINT, x + wc - rc + hs, y + ws - rs - hc); // (w-r, -h) printf(POLYLINE_POINT, x + wc + hs - rs, y + ws - hc + rc); // (w, -h+r) printf(POLYLINE_POINT, x + wc - hs + rs, y + ws + hc - rc); // (w, h-r) } else { printf(POLYLINE, 9, 1); // 9 points, close polyline printf(POLYLINE_POINT, x + wc, y + ws); // (w, 0) printf(POLYLINE_POINT, x + wc - hs + rs, y + ws + hc - rc); // (w, h-r) printf(POLYLINE_POINT, x + wc - rc - hs, y + ws - rs + hc); // (w-r, h) printf(POLYLINE_POINT, x - wc + rc - hs, y - ws + rs + hc); // (-w+r, h) printf(POLYLINE_POINT, x - wc - hs + rs, y - ws + hc - rc); // (-w, h-r) printf(POLYLINE_POINT, x - wc + hs - rs, y - ws - hc + rc); // (-w, -h+r) printf(POLYLINE_POINT, x - wc + rc + hs, y - ws + rs - hc); // (-w+r, -h) printf(POLYLINE_POINT, x + wc - rc + hs, y + ws - rs - hc); // (w-r, -h) printf(POLYLINE_POINT, x + wc + hs - rs, y + ws - hc + rc); // (w, -h+r) } } else { if (OVERCUT) { printf(POLYLINE, 6, 0); // 6 points, open polyline printf(POLYLINE_POINT, x + wc, y + ws); // ( w, 0) printf(POLYLINE_POINT, x + wc - hs, y + ws + hc); // ( w, h) printf(POLYLINE_POINT, x - wc - hs, y - ws + hc); // (-w, h) printf(POLYLINE_POINT, x - wc + hs, y - ws - hc); // (-w, -h) printf(POLYLINE_POINT, x + wc + hs, y + ws - hc); // ( w, -h) printf(POLYLINE_POINT, x + wc - hs, y + ws + hc); // ( w, h) } else { printf(POLYLINE, 5, 1); // 5 points, close polyline printf(POLYLINE_POINT, x + wc, y + ws); // ( w, 0) printf(POLYLINE_POINT, x + wc - hs, y + ws + hc); // ( w, h) printf(POLYLINE_POINT, x - wc - hs, y - ws + hc); // (-w, h) printf(POLYLINE_POINT, x - wc + hs, y - ws - hc); // (-w, -h) printf(POLYLINE_POINT, x + wc + hs, y + ws - hc); // ( w, -h) } } count++; } } } printf("%s", TRAILER); return count; } for (int i = 1; i < argc; i++) { if (argv[i] == "-c") CORNERCUT = 1; else if (argv[i] == "-o") OVERCUT = 1; } board(B) { int t, b; output(filesetext(B.name, "-tcream.dxf")) t = processLayer(B, LAYER_TOP); output(filesetext(B.name, "-bcream.dxf")) b = processLayer(B, LAYER_BOTTOM); string message; sprintf(message, ";DXF files generated with %d+%d objects", t, b); dlgMessageBox(message); } }}} '''(2010/11/11 - sgk)'''