We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
dxf setlayer (Read 522 times)
dxf setlayer
Oct 2nd, 2006, 10:18pm
 
Hi all, i'm brand new to processing, and have been learning via cannibalising one of j. tarbell's sketches, and writing various cubes in 3d. I'm recording these(one frame at a time), and assembling them back together in rhino as one huge file.

my problem: i'm trying to get each frame to write as a different layer using
dxf.setLayer(layernum); as outlined in the rawDXF library.
i'm getting a "nullpointer exception" when I try to run this, even if i'm just pasting the rawDXF code to a new sketch.
ideally, because i'm writing 1000+ individual .dxf files, i'd  like to connect the variable 'layernum' to 'millis' in order to get an ascending heirarchy of layers.

import processing.dxf.*;
boolean record;
RawDXF dxf;
int layernum = 1;

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

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

void draw() {
 if (record) {
   float m = millis();
   dxf = (RawDXF) createGraphics("processing.dxf.RawDXF", "output" + m + ".dxf");
   beginRaw(dxf);
   
 }
  // do all your drawing here, and to set the layer, call:
  dxf.setLayer(layernum);
  // where 'num' is an integer.
  // the default is zero, or you can set it to whatever.

  if (record) {
    endRaw();
    record = false;
  }
}

anybody know what's wrong? i'd paste the whole sketch in here, but I get the same error with either one.

also, dealing with the OCD library and OPENGL, i'm able to get some 3d navigation to work while the sketch is running, but the screen accumulates frame by frame, and never clears the image. I've seen this issue brought up in searching the forums, but haven't come across anything that helps.

thanks in advance, processing is rediculously addicting!
Re: dxf setlayer
Reply #1 - Oct 3rd, 2006, 7:36pm
 
you're calling setLayer() even when record is false, meaning that the "dxf" variable will be null. i'll fix the example to make this clearer.
Re: dxf setlayer
Reply #2 - May 17th, 2007, 10:07am
 
I am having a similar problem with setLayer(), and following the examples doesn't seem to help.  I get the error "Perhaps you wanted the overloaded version "processing.core.PGraphics createGraphics(int $1, int $2, java.lang.String $3);" instead?" on the first line of draw(), when I try to run this code...

Code:

import processing.dxf.*;
RawDXF dxf;

int foot = 12;
int feet = 12;

void setup() {
size(1000, 2000, P3D);
}

void makePanel(){

pushMatrix();
translate(0,6*feet,0);
for(int i=0; i<3; i++) {
int materialDice = int(random(10) );
int insetDice = int( random(10) );
int directionDice = int( random(2) );
boolean moving = false;

translate(2*feet,0,0);
//fill(220);
dxf.setLayer(1);
if(materialDice>=6){dxf.setLayer(2); }

if(insetDice>=3){ moving = true; pushMatrix();}
if(moving && directionDice == 1){translate(0,0,-6);}
if(moving && directionDice == 0){translate(0,0,6);}

makeGlass();

if(moving){ popMatrix(); }

translate(2*feet,0,0);


}
popMatrix();
}


void makeGlass(){
box(4*feet,12*feet,-1);
}


void draw() {

dxf = (RawDXF) createGraphics(DXF, "Panels_RANDOM_06.dxf");
beginRaw(dxf);

fill(220);
noStroke();
println("I am begining.");

//beginRaw(DXF, "Panels_RANDOM_06.dxf");

for(int y=0; y<10; y++) {
for(int x=0; x<20; x++) {
pushMatrix();
translate(x*12*feet, y*12*feet);
makePanel();
popMatrix();
}
println("Making Row " + y + ".");
}
endRaw();
dxf = null;
println("I am finished.");
exit();
}
Re: dxf setlayer
Reply #3 - May 17th, 2007, 6:16pm
 
Pardon me, but after reflection I can see how the above properly belongs in the "Programs" part of this forum.  Nevertheless, if someone can point out the dxf layers syntax issue I'm overlooking I would greatly appreciate it.

Thank you.
Page Index Toggle Pages: 1