Loading...
Logo
Processing Forum
Hi there,

I´m trying to export a dxf from a 2D drawing which contains arcs or elippses. Both ends with a huge dxf file with circles built from many many lines...
Is there a way to export ellipses or arcs as real cirlce objects to dxf?

thanks,
Stefan

Replies(1)

Hello kaindlst, I had the same problem a while ago, best solution i found was making my own dxf file, DXF is actually not that hard a file format and you can build it up yourself. You have to start with a header which also contains dxf layers, then make all the circle entities and then a part which end the file. I am using an array called expDxf to store the strings. This is the code I used:

Copy code
  1. void dxfHeader() {
      //expDxf = new String [47];
      expDxf = new String [] {
        "0", "SECTION", "2", "TABLES", "0", "TABLE", "2", "LAYER", "70", "6",
        "0", "LAYER", "2", "layer 1", "70", "64", "62", "2", "6", "CONTINUOUS",
        "0", "LAYER", "2", "layer 2", "70", "64", "62", "4", "6", "CONTINUOUS",
        "0", "LAYER", "2", "layer 3", "70", "64", "62", "5", "6", "CONTINUOUS",
        "0", "LAYER", "2", "layer 4", "70", "64", "62", "3", "6", "CONTINUOUS",
        "0", "ENDTAB", "0", "TABLE", "2", "STYLE", "70", "0", "0", "ENDTAB", "0", "ENDSEC", "0", "SECTION", "2", "ENTITIES", "0"
      };
    }
Copy code
  1. void dxfEnd() {
      expDxf = expand(expDxf, expDxf.length+3 );
      expDxf[expDxf.length-3] = "ENDSEC";
      expDxf[expDxf.length-2] = "0";
      expDxf[expDxf.length-1] = "EOF" ;
      saveStrings("expChair.dxf", expDxf);
    }
Copy code
  1. void dxfCircle(int x, int y, float xco1, float yco1, float scaleRad, String layer) {
      int oldLen = expDxf.length;
      int newLen = (expDxf.length+12);
      expDxf = expand(expDxf, newLen );
      expDxf [oldLen] = "CIRCLE";
      expDxf [oldLen+1] = "8";
      expDxf [oldLen+2] = layer;
      expDxf [oldLen+3] = "10";
      expDxf [oldLen+4] = str(scaleFac*(xco1+x));
      expDxf [oldLen+5] = "20";
      expDxf [oldLen+6] = str(scaleFac*(yco1+y));
      expDxf [oldLen+7] = "30";
      expDxf [oldLen+8] = "0.0";
      expDxf [oldLen+9] = "40";
      expDxf [oldLen+10] = str(scaleFac * scaleRad);
      expDxf [oldLen+11] = "0";
    }

Hope ths helps you, youll have to write the arcs yourself, never needed those. Script generates a really small and clean file with circles.