My Dxf file it is not saved on the sketch folder

edited December 2017 in Questions about Code

Hi everyone, I'm confused with saving my file as dxf. The code works but when I go to the sketch folder it is not saved there. What should I do?

//First file class Circle { float x; float y; float r; boolean grow = true;

Circle(float x_, float y_){ x = x_; y = y_; r = 1; }

void grow() { if (grow){ r = r + 1; } }

boolean edges(){ return (x + r > width-5 || x - r < 1 || y + r > height-1 || y - r < 10); }

void show() { strokeWeight (2); stroke(0);

noFill();
ellipse(x, y, r*2, r*2);
//arc(x, y, r*2, r*2, random(0, TWO_PI), random(HALF_PI, TWO_PI));

} }

//Second file

Circle c; import processing.dxf.*; ArrayList circles; ArrayList spots; PImage img;

boolean record;

void setup() { size(660, 650, P3D);

spots = new ArrayList(); img = loadImage("circle3.jpg"); img.loadPixels();

for (int x = 5; x < img.width; x++) { for (int y = 5; y < img.height; y++) { int index = x + y * img.width; color c = img.pixels[index]; float b = brightness(c); if (b > 1) { spots.add(new PVector(x,y)); } } } println(spots.size()); circles = new ArrayList();

}

void draw() {

if (record) { beginRaw(DXF, "plan.dxf"); }

background(255); strokeWeight(10); arc(320, 335, 630, 650, radians(185), radians(420)); arc(320, 340, 620, 620, radians(110), radians(165)); arc(230, 547, 170, 170, radians(290), radians(470)); arc(310, 340, 330, 335, radians(255), radians(452));

int total = 10; int count = 0; int attempts = 0;

while (count < total){

Circle newC = newCircle();

if (newC != null) { circles.add(newC); count ++; } attempts++; if ( attempts > 15){ noLoop(); break; } }

for (Circle c : circles) { //circles not touching not overlaping if (c.grow) { if (c.edges()) { c.grow = false; }else { for (Circle other : circles) { if (c != other) { float d = dist(c.x, c.y, other.x, other.y); if (d - 5 < c.r + other.r) { c.grow = false; break; } } } } } // c.change -= 10; c.show(); c.grow(); }

}

Circle newCircle(){

int r = int(random(0,spots.size())); PVector spot = spots.get(r); float x = spot.x; float y = spot.y;

boolean valid = true; //No circles inside other circles for (Circle c : circles) { float d = dist(x,y,c.x,c.y); if (d < c.r){ valid = false; break; } } if (valid) { return new Circle (x,y); } else { return null; } } {

if (record) {

endRaw(); record = false;} } void keyReleased() { if (key == 'r' || key == 'R') { record = true; println("dxf Exported"); } }

Tagged:

Answers

  • edit post, highlight code, press ctrl-o to format.

    it's unreadable as it is.

Sign In or Register to comment.