# OpenSCAD User Manual/Commented Example Projects

Jump to: navigation, search

## Dodecahedron

 //create a dodecahedron by intersecting 6 boxes module dodecahedron(height) { scale([height,height,height]) //scale by height parameter { intersection(){ //make a cube cube([2,2,1], center = true); intersection_for(i=[0:4]) //loop i from 0 to 4, and intersect results { //make a cube, rotate it 116.565 degrees around the X axis, //then 72*i around the Z axis rotate([0,0,72*i]) rotate([116.565,0,0]) cube([2,2,1], center = true); } } } } //create 3 stacked dodecahedra //call the module with a height of 1 and move up 2 translate([0,0,2])dodecahedron(1); //call the module with a height of 2 dodecahedron(2); //call the module with a height of 4 and move down 4 translate([0,0,-4])dodecahedron(4); The Dodecahedron as rendered from the example.

## Bounding Box

 // Rather kludgy module for determining bounding box from intersecting projections module BoundingBox() { intersection() { translate([0,0,0]) linear_extrude(height = 1000, center = true, convexity = 10, twist = 0) projection(cut=false) intersection() { rotate([0,90,0]) linear_extrude(height = 1000, center = true, convexity = 10, twist = 0) projection(cut=false) rotate([0,-90,0]) children(0); rotate([90,0,0]) linear_extrude(height = 1000, center = true, convexity = 10, twist = 0) projection(cut=false) rotate([-90,0,0]) children(0); } rotate([90,0,0]) linear_extrude(height = 1000, center = true, convexity = 10, twist = 0) projection(cut=false) rotate([-90,0,0]) intersection() { rotate([0,90,0]) linear_extrude(height = 1000, center = true, convexity = 10, twist = 0) projection(cut=false) rotate([0,-90,0]) children(0); rotate([0,0,0]) linear_extrude(height = 1000, center = true, convexity = 10, twist = 0) projection(cut=false) rotate([0,0,0]) children(0); } } } // Test module on ellipsoid translate([0,0,40]) scale([1,2,3]) sphere(r=5); BoundingBox() scale([1,2,3]) sphere(r=5); Bounding Box applied to an Ellipsoid