/* base */ base_w = 10; roundness = 0.5; /* should match offset constraint in sovlespace */ wall_thickness = 1.0; side_dxf = "knob_side.dxf"; /* stem */ stem_wall_thickness = 1.5; stem_w = 2.4; stem_h = 6.8; cut_corners_w = 1.6; cut_corners_h = 2.0; /* don't touch */ lots = 1000; eps = 0.01; module offset_shell(offx) { intersection() { translate([-lots/2, 0, 0]) square([lots, lots]); offset(r=-offx) union() { children(); mirror([0, 1, 0]) children(); } } } module dxf_shell(file, w, d, r) { intersection() { translate([0, 0, lots/2]) cube([lots, lots, lots], center=true); difference() { minkowski(){ sphere(r=r, $fn=32); rotate([90, 0, 0]) linear_extrude(height=w - 2*r, center=true) offset_shell(r) import(file, $fn=128); } translate([0, 0, -eps]) rotate([90, 0, 0]) linear_extrude(height=w-2*d, center=true) offset_shell(d) import(file, $fn=128); } } } module stem() { difference() { cube([stem_h + 2*stem_wall_thickness, stem_w + 2*stem_wall_thickness, lots], center=true); cube([stem_h, stem_w, lots], center=true); translate([0, 0, -lots/2]) cube([lots, lots, lots], center=true); translate([-(stem_h+stem_wall_thickness)/2-eps, -(stem_w+stem_wall_thickness)/2-eps, 0]) cube([cut_corners_h, cut_corners_w, lots], center=true); translate([(stem_h+stem_wall_thickness)/2+eps, -(stem_w+stem_wall_thickness)/2-eps, 0]) cube([cut_corners_h, cut_corners_w, lots], center=true); translate([-(stem_h+stem_wall_thickness)/2-eps, (stem_w+stem_wall_thickness)/2+eps, 0]) cube([cut_corners_h, cut_corners_w, lots], center=true); translate([(stem_h+stem_wall_thickness)/2+eps, (stem_w+stem_wall_thickness)/2+eps, 0]) cube([cut_corners_h, cut_corners_w, lots], center=true); } } ridge_w = 0.8; ridge_f = 0.3; ridge_h = 3.7; difference() { union () { dxf_shell(side_dxf, base_w, wall_thickness, roundness); intersection() { stem(); rotate([90, 0, 0]) linear_extrude(height=base_w, center=true) import(side_dxf, $fn=128); } } translate([0, -base_w/2 - ridge_w*ridge_f, -eps]) cylinder(d=ridge_w, h=lots, $fn=32); translate([0, base_w/2 + ridge_w*ridge_f, -eps]) cylinder(d=ridge_w, h=lots, $fn=32); translate([0, 0, ridge_h]) rotate([90, 0, 0]) cylinder(d=ridge_w, h=lots, center=true, $fn=32); }