Changes between Version 5 and Version 6 of EagleCraftRobo


Ignore:
Timestamp:
Nov 18, 2010 9:13:47 PM (13 years ago)
Author:
sgk
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • EagleCraftRobo

    v5 v6  
    3434EAGLE provides "dxf.ulp", but this will not produce a correct DXF file for cream layers.
    3535
    36 '''cream-dxf.ulp''':
    37  {{{
    38 #!c
    39 //
    40 // Export the cream layers to DXF for the Craft-ROBO cutting machine.
    41 //
    42 // Copyright (c) 2010 Switch Science, Inc.
    43 //
     36== The code ==
    4437
    45 string HEADER =
    46 "  0\n"
    47 "SECTION\n"
    48 "  2\n"
    49 "HEADER\n"
    50 "  9\n"
    51 "$ACADVER\n"
    52 "  1\n"
    53 "AC1014\n"
    54 "  9\n"
    55 "$HANDSEED\n"
    56 "  5\n"
    57 "FFFF\n"
    58 "  9\n"
    59 "$MEASUREMENT\n"
    60 " 70\n"
    61 "     1\n"                              // unit: mm
    62 "  0\n"
    63 "ENDSEC\n"
    64 "  0\n"
    65 "SECTION\n"
    66 "  2\n"
    67 "ENTITIES\n";
    68 
    69 string POLYLINE =
    70 "  0\n"
    71 "LWPOLYLINE\n"
    72 "  5\n"
    73 "%d\n"                                  // id
    74 "100\n"
    75 "AcDbEntity\n"
    76 "  8\n"
    77 "0\n"
    78 " 62\n"
    79 "7\n"
    80 "100\n"
    81 "AcDbPolyline\n"
    82 " 90\n"
    83 "%d\n"                                  // number of points
    84 " 70\n"
    85 "0\n";
    86 
    87 string POINT =
    88 " 10\n"
    89 "%f\n"
    90 " 20\n"
    91 "%f\n"
    92 " 30\n"
    93 "0.0\n";
    94 
    95 string TRAILER =
    96 "  0\n"
    97 "ENDSEC\n"
    98 "  0\n"
    99 "EOF\n";
    100 
    101 void processLayer(UL_BOARD B, int layer) {
    102   int cream = (layer == LAYER_TOP ? LAYER_TCREAM : LAYER_BCREAM);
    103   int id = 100;
    104   printf("%s", HEADER);
    105   B.elements(E) {
    106     E.package.contacts(C) {
    107       if (C.smd && C.smd.layer == layer) {
    108         real x = C.smd.x / 10000.0;
    109         real y = C.smd.y / 10000.0;
    110         real w = C.smd.dx[cream] / 10000.0 / 2;
    111         real h = C.smd.dy[cream] / 10000.0 / 2;
    112         real a = C.smd.angle / 180 * PI;
    113         real wc = w * cos(a);
    114         real hs = h * sin(a);
    115         real ws = w * sin(a);
    116         real hc = h * cos(a);
    117         printf(POLYLINE, id++, 5);      // 5 points
    118         printf(POINT, x + wc - hs, y + ws + hc);
    119         printf(POINT, x - wc - hs, y - ws + hc);
    120         printf(POINT, x - wc + hs, y - ws - hc);
    121         printf(POINT, x + wc + hs, y + ws - hc);
    122         printf(POINT, x + wc - hs, y + ws + hc);
    123       }
    124     }
    125   }
    126   printf("%s", TRAILER);
    127 }
    128 
    129 board(B) {
    130   output(filesetext(B.name, "-tcream.dxf")) processLayer(B, LAYER_TOP);
    131   output(filesetext(B.name, "-bcream.dxf")) processLayer(B, LAYER_BOTTOM);
    132 }
    133 }}}
     38The code moved to <https://gist.github.com/703363>.
    13439
    13540'''(2010/11/11 - sgk)'''