Friday, June 19, 2020

Why I Love OpenSCAD

I just made a knob and it struck me what a quick and easy job it was.

The central shape is a cylinder of height 20mm and diameter 50mm.

            cylinder(20, d=50);



Two smaller offset cylinders are the grips.

            cylinder(20, d=50);
            translate([50,0,0]) cylinder(10, d=30);
            translate([-50,0,0]) cylinder(10, d=30);



We wrap the pieces into a completed shape with hull().

        hull() {
            cylinder(20, d=50);
            translate([50,0,0]) cylinder(10, d=30);
            translate([-50,0,0]) cylinder(10, d=30);
        }



And add a screw-hole with difference().

    difference() {
        hull() {
            cylinder(20, d=50);
            translate([50,0,0]) cylinder(10, d=30);
            translate([-50,0,0]) cylinder(10, d=30);
        }
        cylinder(20, d=8);
    }