Changes between Version 6 and Version 7 of EagleCraftRobo


Ignore:
Timestamp:
Nov 21, 2010 10:27:09 PM (13 years ago)
Author:
sgk
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • EagleCraftRobo

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