In order to convert a 3D graphical object on the screen to a file in which a 3D printer can print, you will first need to import the library OBJExport. The link to the library can be found here.
The sample program is below. The OBJ file is written in the folder Processing3->libraries->OBJExport->Examples folder unless you specify otherwise.
You may have to “fix” your object in Meshmixer, a free Adobe program, to fill in any holes in the object.
Example Program
import nervoussystem.obj.*;
boolean record;
void setup() {
fullScreen(P3D);
smooth();
}
void draw() {
background(0);
if (record) {
beginRecord(“nervoussystem.obj.OBJExport”, “test.obj”);
}
fill(255);
translate(width/2, height/2);
box(100,100,100);
if (record) {
endRecord();
record = false;
}
}
void keyPressed()
{
if (key == ‘r’) {
record = true;
}
}