### DXF Export

The DXF library writes all triangle-based graphics (polygons, boxes, spheres, etc.) to a DXF file. It works with the beginRaw() and endRaw() functions. These functions will grab and save the shape data just before it is rendered to the screen. At this stage, your entire scene is nothing but a long list of lines and triangles. This means that a shape created with the sphere() function will be made up of hundreds of triangles, rather than a single object. The source code is available on the Processing GitHub repository. Please report bugs here.

Use an event function like a keyPressed() to trigger it, to avoid writing a file each time through draw(). By default, the file will be saved to the sketch's folder. Use Sketch > Show Sketch Folder to see it from the Processing Environment.

This simple example shows how to use the library:

    import processing.dxf.*;

    boolean record;

    void setup() {
      size(500, 500, P3D);
    }

    void draw() {
      if (record) {
        beginRaw(DXF, "output.dxf");
      }

      // Do all your drawing here
      if (record) {
        endRaw();
        record = false;
      }
    }

    void keyPressed() {
      // Use a key press so that it doesn't make a million files
      if (key == 'r') {
      	record = true;
      }
    }