openscad/openscad — pull request #171 by felipesanches (2012-08-06 02:33:50+00:00)
Title: Add export_curves module. It is usefull for exporting selected subtrees ...

...to DXF files. Only 2D content can be exported with this module.

This branch adds an export_curves command for exporting a sub-tree composed of only 2d primitives.

For instance, one can have something like:

module cuts_for_acrylic_sheet(radius){
//algoritmically define placing of screw holes, and all other necessary cuts
difference(){
square([50, 50]);
translate([10,15]) circle(r=radius);
translate([40,15]) circle(r=radius);
translate([10,35]) circle(r=radius);
translate([40,35]) circle(r=radius);
}

//then you can preview the sheet of 2mm laser-cut acrylic like this:
color([0.4, 0.4, 0.4, 0.7])
linear_extrude(height=2)
cuts_for_acrylic_sheet(radius = m3_diameter/2);

//And you can export the vector curves for sending to the laser cutter this way:
export_curves("cuts_for_acrylic_sheet_using_M3.dxf")
cuts_for_acrylic_sheet(radius = m3_diameter/2);

export_curves("cuts_for_acrylic_sheet_using_M4.dxf")
cuts_for_acrylic_sheet(radius = m4_diameter/2);

The nice thing about being able to export subtrees is that you can i.e. design several parts of a machine made of laser-cut parts and export each vector file from the appropriate portions of the SCAD code.