3d Random Walker export-as-dxf

Hello I am trying to write a 3d random Walker P3D
But I do not achieve to export all the boxes as .dxf
my goal is to be able to open the file in Rhino and export it as .stl and send it to a 3d Printing
I will appreciate any help or orientation to learn how to fix this code.
Thanks

// Random Walker3d part2
import processing.dxf.*;
boolean record; //set boolean for recording the dxf file
// Create a Walker Object 
Walker3d W3d; 

//Gloabal Variables
void setup() {
  size(600, 600, P3D);
  background(255);
  frameRate(60); //The default rate is 60 frames per second.

  W3d = new Walker3d(60); // Initialize the new Object
  // Function to export 3d to dxf
  
}

void draw() {
 
  
if (keyPressed == true) {
    if (key == 's' || key == 'S') {
      beginRaw(DXF, "walker3d_box.dxf");
    }
  }
  
   // Call Class Methods
  W3d.step();
  W3d.display();
  
  endRaw();
}



// Class

class Walker3d {

  // fields
  int x;
  int y;
  int z;
  float size;

  // Constructor
  Walker3d(float _size) {
    x = width/2;
    y = height/2;
    z = 0;
    size = _size;
  }

  // Methods
  void step() {
    int stepX = int (random(3))-1; //Yields -1.0,1
    int stepY = int (random(3))-1;
    int stepZ = int (random(3))-1;
    x += stepX ;
    y += stepY ;
    z += stepZ ;
  }

  void display() {
    noFill();
    stroke(0);
    translate(x, y, 0);
    // box(size);
    box(size);
    // box(w, h, d);
  }
}
1 Like

You can btw put your preformat you code so it will be easier to help you

// Random Walker3d part2
import processing.dxf.*;
boolean record; //set boolean for recording the dxf file
// Create a Walker Object
Walker3d W3d;

I don’t have the solution, but hov about storing all the values in an array for each draw loop?
Then at the exist, or after some frame outputting that array to .dxf