Adding an inset using minkowski

Cubes with one applying minkowski

OpenSCAD is a scripting CAD tool every developer could like.

The following script is an effort to test inset/subtraction shape (hole_cube) not loosing its shape dimensions.

/*
 * Test for making a hole with a snugger fit.
 *
 * This can be used for more complex shaped
 */

// Size of cube
outer_size = 3;
shim = 0.1;
hole_size = 2;

module cube_with_hole() {
    difference() {
        cube(outer_size, center=true);
        cube(hole_size, center=true);
    }
}

difference() {
    cube_with_hole();
    // chop of top half
    translate([0,0,1.1 * outer_size/2])
        cube(1.1*outer_size, center=true);
}


translate([outer_size + 1,0,0])
// Adding an inset to the hole.
difference() {
    // Adding an outset.
    minkowski() {
        $fn=50;
        cube_with_hole();
        sphere(r=shim);
    }
    // chop of top half
    translate([0,0,(outer_size + 2*shim)/2])
        cube(outer_size + 2.1*shim, center=true);
}