OpenSCAD User Manual/STL Export

STL Export

On the "File" menu select the "Export" item to open the file type selector and tap "Export as STL..."

A file dialog box will open to place the exported file into. The ".stl" extension must be explicitly added.

Trouble shooting

After compile and render CGAL (F6), you may see that your design is simple: no.

When you try to export this to .STL, this message appears:

Object isn't a valid 2-manifold! Modify your design..
// Parameters
main_diameter = 70;
main_thickness = 30;
hole_diameter = 5;
num_holes = 3;
hole_radius = main_diameter / 2 - 5; // Inset from edge

difference() {
    // Main cylinder
    cylinder(d=main_diameter, h=main_thickness, $fn=100);

    // Holes
    for (i = [0 : 360 / num_holes : 359]) {
        angle = i;
        x = hole_radius * cos(angle);
        y = hole_radius * sin(angle);
        translate([x, y, 0])
             // Add height to ensure full cut
            cylinder(d=hole_diameter, h=main_thickness + 1, $fn=60);
    }
}


"Manifold" means that it is "water tight" and that there are no holes in the geometry. In a valid 2-manifold each edge must connect exactly two facets. That means that the program must be able to connect a face with an object. E.g. if you use a cube of height 10 to carve out something from a wider cube of height 10, it is not clear to which cube the top or the bottom belongs. So make the small extracting cube a bit "longer" (or "shorter"):

difference() {
	// original
	cube (size = [2,2,2]);
	// object that carves out
	# translate ([0.5,0.5,-0.5]) {
	    cube (size = [1,1,3]);	
	}
}
Correct use of difference

Here is a more tricky little example taken from the OpenSCAD Forum (retrieved 15:13, 22 March 2010 (UTC)):

module example1() {
		cube([20, 20, 20]);
		translate([-20, -20, 0]) cube([20, 20, 20]);
		cube([50, 50, 5], center = true);
	}
module example2() {
		cube([20.1, 20.1, 20]);
		translate([-20, -20, 0]) cube([20.1, 20.1, 20]);
		cube([50, 50, 5], center = true);
	}

Example1 would render like this:

A not valid 2-manifold cube (simple = no)

The example1 module is not a valid 2-manifold because both cubes are sharing one edge. They touch each other but do not intersect.

Example2 is a valid 2-manifold because there is an intersection. Now the construct meets the 2-manifold constraint stipulating that each edge must connect exactly two facets.

Pieces you are subtracting must extend past the original part. (OpenSCAD Tip: Manifold Space and Time, retrieved 18:40, 22 March 2010 (UTC)).

For reference, another situation that causes the design to be non-exportable is when two faces that are each the result of a subtraction touch. Then the error message comes up.

difference () {
   cube ([20,10,10]);
   translate ([10,0,0]) cube (10);
}
difference () {
   cube ([20,10,10]);
   cube (10);
}

simply touching surfaces is correctly handled.

translate ([10,0,0]) cube (10);
cube (10);
Category:Book:OpenSCAD User Manual#Export/STL%20Export%20