public class RawDXF extends PGraphics
Use something like a keyPressed() in PApplet to trigger it, to avoid writing a bazillion .dxf files.
Usually, the file will be saved to the sketch's folder. Use Sketch → Show Sketch Folder to see it from the PDE.
A simple example of how to use:
import processing.dxf.*; boolean record; 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) { beginRaw(DXF, "output.dxf"); } // do all your drawing here if (record) { endRaw(); record = false; } }or to use it and be able to control the current layer:
import processing.dxf.*; boolean record; RawDXF dxf; 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) { dxf = (RawDXF) createGraphics(width, height, DXF, "output.dxf"); beginRaw(dxf); } // do all your drawing here, and to set the layer, call: // if (record) { // dxf.setLayer(num); // } // where 'num' is an integer. // the default is zero, or you can set it to whatever. if (record) { endRaw(); record = false; dxf = null; } }Note that even though this class is a subclass of PGraphics, it only implements the parts of the API that are necessary for beginRaw/endRaw.
Based on the original DXF writer from Simon Greenwold, February 2004. Updated for Processing 0070 by Ben Fry in September 2004, and again for Processing beta in April 2005. Rewritten to support beginRaw/endRaw by Ben Fry in February 2006. Updated again for inclusion as a core library in March 2006. Constructor modifications in September 2008 as we approach 1.0.
A, AB, AG, ambientB, ambientColor, ambientG, ambientR, AR, B, backgroundColor, BEEN_LIT, bezierDetail, colorMode, colorModeA, colorModeX, colorModeY, colorModeZ, curveDetail, curveTightness, DA, DB, DEFAULT_VERTICES, DG, DR, EB, edge, EDGE, EG, ellipseMode, emissiveB, emissiveColor, emissiveG, emissiveR, ER, fill, fillColor, G, HAS_NORMAL, image, imageMode, normalX, normalY, normalZ, NX, NY, NZ, pixelCount, R, rectMode, SA, SB, setAmbient, SG, shapeMode, SHINE, shininess, smooth, SPB, specularB, specularColor, specularG, specularR, SPG, sphereDetailU, sphereDetailV, SPR, SR, stroke, strokeCap, strokeColor, strokeJoin, strokeWeight, SW, textAlign, textAlignY, textFont, textLeading, textMode, textSize, textureImage, textureMode, textureU, textureV, tint, tintColor, TX, TY, TZ, U, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZ
ALPHA_MASK, BLUE_MASK, format, GREEN_MASK, height, loaded, parent, pixelDensity, pixelHeight, pixels, pixelWidth, RED_MASK, width
ADD, ALPHA, ALT, AMBIENT, ARC, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BEZIER_VERTEX, BLEND, BLUR, BOTTOM, BOX, BREAK, BURN, CENTER, CHATTER, CHORD, CLAMP, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CURVE_VERTEX, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ASYNC_SAVEFRAME, DISABLE_BUFFER_READING, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_KEY_REPEAT, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERRORS, DISABLE_OPTIMIZED_STROKE, DISABLE_STROKE_PERSPECTIVE, DISABLE_STROKE_PURE, DISABLE_TEXTURE_MIPMAPS, DODGE, DOWN, DXF, ELLIPSE, ENABLE_ASYNC_SAVEFRAME, ENABLE_BUFFER_READING, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_KEY_REPEAT, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_ERRORS, ENABLE_OPTIMIZED_STROKE, ENABLE_STROKE_PERSPECTIVE, ENABLE_STROKE_PURE, ENABLE_TEXTURE_MIPMAPS, ENTER, EPSILON, ERODE, ESC, EXCLUSION, FX2D, GIF, GRAY, GROUP, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LANDSCAPE, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, PIE, platformNames, POINT, POINTS, POLYGON, PORTRAIT, POSTERIZE, PROBLEM, PROJECT, PROJECTION, QUAD, QUAD_BEZIER_VERTEX, QUAD_STRIP, QUADRATIC_VERTEX, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RECT, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPAN, SPHERE, SPOT, SQUARE, SUBTRACT, SVG, TAB, TARGA, TAU, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, VERTEX, WAIT, WHITESPACE, WINDOWS, X, Y, Z
Constructor and Description |
---|
RawDXF() |
Modifier and Type | Method and Description |
---|---|
void |
beginDraw() |
void |
beginShape(int kind) |
boolean |
displayable() |
void |
dispose() |
void |
endDraw() |
void |
endShape(int mode) |
boolean |
is2D() |
boolean |
is3D() |
void |
println(String what)
Write a line to the dxf file.
|
void |
setLayer(int layer)
Set the current layer being used in the DXF file.
|
void |
setPath(String path) |
void |
vertex(float x,
float y) |
void |
vertex(float x,
float y,
float z) |
void |
write(String cmd,
float val)
Write a command on one line (as a String), then start a new line
and write out a formatted float.
|
alpha, ambient, ambient, ambient, ambientLight, ambientLight, applyMatrix, applyMatrix, applyMatrix, applyMatrix, applyMatrix, arc, arc, attrib, attrib, attrib, attribColor, attribNormal, attribPosition, background, background, background, background, background, background, background, beginCamera, beginContour, beginPGL, beginRaw, beginShape, bezier, bezier, bezierDetail, bezierPoint, bezierTangent, bezierVertex, bezierVertex, blendMode, blue, box, box, brightness, camera, camera, circle, clear, clip, color, color, color, color, color, color, color, color, color, colorMode, colorMode, colorMode, colorMode, createShape, createShape, createShape, createSurface, curve, curve, curveDetail, curvePoint, curveTangent, curveTightness, curveVertex, curveVertex, directionalLight, edge, ellipse, ellipseMode, emissive, emissive, emissive, endCamera, endContour, endPGL, endRaw, endShape, fill, fill, fill, fill, fill, fill, filter, flush, frustum, getCache, getMatrix, getMatrix, getMatrix, getRaw, getStyle, getStyle, green, haveRaw, hint, hue, image, image, image, imageMode, is2X, isGL, lerpColor, lerpColor, lightFalloff, lights, lightSpecular, line, line, loadShader, loadShader, loadShape, loadShape, modelX, modelY, modelZ, noClip, noFill, noLights, normal, noSmooth, noStroke, noTexture, noTint, ortho, ortho, ortho, perspective, perspective, point, point, pointLight, pop, popMatrix, popStyle, printCamera, printMatrix, printProjection, push, pushMatrix, pushStyle, quad, quadraticVertex, quadraticVertex, rect, rect, rect, rectMode, red, removeCache, resetMatrix, resetShader, resetShader, rotate, rotate, rotateX, rotateY, rotateZ, saturation, save, scale, scale, scale, screenX, screenX, screenY, screenY, screenZ, setCache, setMatrix, setMatrix, setMatrix, setParent, setPrimary, setSize, shader, shader, shape, shape, shape, shapeMode, shearX, shearY, shininess, showDepthWarning, showDepthWarningXYZ, showException, showMethodWarning, showMissingWarning, showVariationWarning, showWarning, showWarning, smooth, smooth, specular, specular, specular, sphere, sphereDetail, sphereDetail, spotLight, square, stroke, stroke, stroke, stroke, stroke, stroke, strokeCap, strokeJoin, strokeWeight, style, text, text, text, text, text, text, text, text, text, text, text, textAlign, textAlign, textAscent, textDescent, textFont, textFont, textLeading, textMode, textSize, texture, textureMode, textureWrap, textWidth, textWidth, textWidth, tint, tint, tint, tint, tint, tint, translate, translate, triangle, vertex, vertex, vertex
blend, blend, blendColor, clone, copy, copy, copy, filter, filter, get, get, get, getImage, getModifiedX1, getModifiedX2, getModifiedY1, getModifiedY2, getNative, init, init, isLoaded, isModified, loadPixels, mask, mask, resize, set, set, setLoaded, setLoaded, setModified, setModified, updatePixels, updatePixels
public boolean displayable()
displayable
in class PGraphics
public void setLayer(int layer)
public void write(String cmd, float val)
public void println(String what)
public void beginShape(int kind)
beginShape
in class PGraphics