07 November 2022

OpenSCAD for 3D printing

If you are a software programmer/developer of some sort in any high-level language and you need to design an object for 3D printing, I think that OpenSCAD is for you.

I am designing a case around a PCB I have ordered. It's a cylinder with a diagonal cut, three supports for the PCB and two holes for the buttons. In OpenSCAD the final object is described as sum/difference of basic shapes (cylinder, cube, ...) in a simple programming language.

The GUI provides both auto-completion and 3D preview.

The following code makes an empty cylinder with a diagonal.Try reading it through:

module cylcut()
{
    difference()
    {
        difference()
        {
            cylinder(h=80, r=39);
            translate([0,0,-1]){
                cylinder(h=82, r=37);
            }
        }
        
        translate([-40,-40,80]){
            rotate([-20,0,0]){
            cube([100,100,40]);
            }
        }
    }
}

cylcut();

There is a long way to go and learn before I get to the STL file for the printer, but I like it!