# Cannot Export DXF from PWindow?

**URL:** https://discourse.processing.org/t/cannot-export-dxf-from-pwindow/36767
**Category:** Coding Questions
**Created:** [May 8, 2022, 12:03pm UTC](https://discourse.processing.org/t/cannot-export-dxf-from-pwindow/36767 "2022-05-08T12:03:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![dimpapadop](https://avatars.discourse-cdn.com/v4/letter/d/ba9def/32.png) [@dimpapadop](https://discourse.processing.org/u/dimpapadop)
#### Post date: [May 8, 2022, 12:03pm UTC](https://discourse.processing.org/t/cannot-export-dxf-from-pwindow/36767/1 "2022-05-08T12:03:06Z")

</div>

Hallo.

I have the following problem.  
In a second window of my sketch that i use for previewing in 3d, i have a set of pshapes drawn in 3d space, but i cannot get them to be exported as dxf. Actually, nothing is exported, no file is made. What am i missing? (the main window is P2D but the export commands are in this PWindow with p3d renderer)  
And Secondly will i be able to use it in cad software? e.g. fusion 360?

```auto
import processing.dxf.*;
boolean record = false;
PWindow win;
import peasy.PeasyCam;
PeasyCam cam;

class PWindow extends PApplet {
  PWindow() {
    super();
    PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
  }

  void settings() {
    size(600,600, P3D);
  }

  void setup() {
    background(150);
    cam = new PeasyCam(this, 1400); //400 == zoom
  }

PShape feta;
  void draw() {
    background(100); 
    lights();

    if (record == true) {
      println("started dxf");
      beginRaw(DXF, "output.dxf"); // Start recording to the file
    }

    for (int i=0; i<shapesPreview.size(); i++) {
      feta = createShape();
      feta.beginShape();
      for (int j=0; j<shapesPreview.get(i).size(); j++) {
        if (withCurves) {
          feta.curveVertex(shapesPreview.get(i).get(j).x, shapesPreview.get(i).get(j).y);
        } else {
          feta.vertex(shapesPreview.get(i).get(j).x, shapesPreview.get(i).get(j).y);
        }
        if (j== shapesPreview.get(i).size()-1) {
          feta.vertex(shapesPreview.get(i).get(j).x, (i+1)*tileH);
          feta.vertex(0, (i+1)*tileH );
          feta.vertex(shapesPreview.get(i).get(0).x, shapesPreview.get(i).get(0).y );
        }
      }
      feta.endShape(CLOSE);

      pushMatrix();
      translate(0, -i*tileH, i*tileH); 
      shape(feta, 0, 0);
      popMatrix();
    }
   
    if (record == true) {
      println("ended dxf");
      endRaw();
      record = false; // Stop recording to the file
    }

  }

  void keyPressed() {
    if (key=='1') record=true;
    if (key=='3') {
      shapesPreview = new ArrayList<ArrayList<PVector>>();
      shapesPreview = shapes;
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [May 8, 2022, 12:31pm UTC](https://discourse.processing.org/t/cannot-export-dxf-from-pwindow/36767/2 "2022-05-08T12:31:40Z")

</div>

> [@dimpapadop](#):
>
> Actually, nothing is exported, no file is made. What am I missing?

Check out these 2 examples about using [**runSketch()**](http://processing.github.io/processing-javadocs/core/processing/core/PApplet.html#runSketch-java.lang.String:A-processing.core.PApplet-) + [ARGS\_SKETCH\_FOLDER](http://processing.github.io/processing-javadocs/core/processing/core/PApplet.html#ARGS_SKETCH_FOLDER) + [**sketchPath()**](http://processing.github.io/processing-javadocs/core/processing/core/PApplet.html#sketchPath--):

- [Size method for intial window not working when more windows are are added. - Processing 2.x and 3.x Forum](http://forum.Processing.org/two/discussion/16457/size-method-for-intial-window-not-working-when-more-windows-are-are-added#Item_1)

> [@Problems when trying to draw to a P3D PGraphics when called from a thread?](https://discourse.processing.org/t/problems-when-trying-to-draw-to-a-p3d-pgraphics-when-called-from-a-thread/6301/4):
>
> Although it’s pretty much a hack, here’s the workaround I’ve come up w/: crazy_face /\*\* \* Threaded PGraphics II (v1.0.1) \* GoToLoop (2018/Dec/07) \* \* https://Discourse.Processing.org/t/ \* problems-when-trying-to-draw-to-a-p3d-pgraphics- \* when-called-from-a-thread/6301/4 \* \* https://Forum.Processing.org/two/discussion/25799/ \* how-to-draw-a-rect-in-a-thread#Item\_2 \*/ static final int W = 250, H = 200, FPS = 10; Layer layer; void settings() { size(W, H, JAVA2D); smooth(3); } v…

---

<div class="post-metadata">

### Author: ![dimpapadop](https://avatars.discourse-cdn.com/v4/letter/d/ba9def/32.png) [@dimpapadop](https://discourse.processing.org/u/dimpapadop)
#### Post date: [May 8, 2022, 12:41pm UTC](https://discourse.processing.org/t/cannot-export-dxf-from-pwindow/36767/3 "2022-05-08T12:41:02Z")

</div>

Thank you!!!  
so it was actually exported but somewhere else. I did test it by “C:/output.dxf” and did worked but the same file exported to svg takes about 37KB and on .dxf 7.5MB is normal?

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [May 8, 2022, 12:43pm UTC](https://discourse.processing.org/t/cannot-export-dxf-from-pwindow/36767/4 "2022-05-08T12:43:53Z")

</div>

> [@dimpapadop](#):
>
> … but the same file exported to svg takes about 37KB and on .dxf 7.5MB is normal?

Dunno anything about .dxf. .svg is just a human readable file w/ coordinates.
