diff vs bare: +33/-31
$fn = 128;
// Mug dimensions
- outer_d = 80;
- inner_d = 70;
- mug_h = 90;
- bottom_t = 6;
+ outer_d = 80;
+ inner_d = 70;
+ mug_h = 90;
+ bottom_t = 6;
- // Handle opening dimensions
- handle_open_w = 25; // radial width of finger opening
- handle_open_h = 30; // vertical height of finger opening
+ // Handle inner opening dimensions
+ handle_open_w = 25; // width in radial (X) direction
+ handle_open_h = 30; // height in Z direction
- // Handle thickness around opening
+ // Handle thickness
handle_wall = 5;
- // Derived
+ // Derived mug radii
outer_r = outer_d / 2;
inner_r = inner_d / 2;
- // Handle placement and size
- handle_center_z = mug_h / 2;
+ // Handle dimensions
+ handle_outer_w = handle_open_w + handle_wall; // D-shape total width (straight side to farthest point)
handle_outer_h = handle_open_h + 2 * handle_wall;
- handle_r = handle_outer_h / 2; // radius for rounded top/bottom in YZ profile
- handle_straight_h = handle_open_h; // straight section height in YZ profile
- // Radial extents in X
- handle_inner_x = outer_r - 1.0; // slight overlap into mug for manifold union
- handle_outer_x = outer_r + handle_open_w + 2 * handle_wall;
+ handle_inner_r = handle_open_h / 2;
+ handle_outer_r = handle_outer_h / 2;
- // 2D D-shape in XZ plane, then extruded along Y
- module d_shape_2d(x0, x1, zc, open_h) {
- r = open_h / 2;
+ handle_center_z = mug_h / 2;
+
+ // Slight overlap into mug body to guarantee manifold union
+ attach_overlap = 1.0;
+
+ // 2D D-shape in XZ plane:
+ // left side is the straight attachment side, right side is the semicircular outer side
+ module d2d(x_left, z_center, total_w, total_h) {
+ r = total_h / 2;
union() {
- translate([x0, zc - r]) square([x1 - x0 - r, open_h], center = false);
- translate([x1 - r, zc]) circle(r = r);
+ square_w = total_w - r;
+ translate([x_left, z_center - r])
+ square([square_w, total_h], center = false);
+ translate([x_left + square_w, z_center])
+ circle(r = r);
}
}
module mug_body() {
difference() {
cylinder(h = mug_h, r = outer_r);
translate([0, 0, bottom_t])
cylinder(h = mug_h - bottom_t + 0.01, r = inner_r);
}
}
module handle() {
difference() {
- // Outer D-shape
- translate([0, -handle_r, 0])
- rotate([-90, 0, 0])
- linear_extrude(height = 2 * handle_r)
- d_shape_2d(handle_inner_x, handle_outer_x, handle_center_z, handle_outer_h);
+ // Outer handle body
+ linear_extrude(height = handle_outer_h, center = true)
+ d2d(outer_r - attach_overlap, handle_center_z, handle_outer_w + attach_overlap, handle_outer_h);
- // Inner opening D-shape
- translate([0, -handle_open_h/2, 0])
- rotate([-90, 0, 0])
- linear_extrude(height = handle_open_h)
- d_shape_2d(outer_r + handle_wall, outer_r + handle_wall + handle_open_w, handle_center_z, handle_open_h);
+ // Inner finger opening
+ linear_extrude(height = handle_open_h, center = true)
+ d2d(outer_r + handle_wall, handle_center_z, handle_open_w, handle_open_h);
}
}
union() {
mug_body();
handle();
}
SCAD (68 lines)
$fn = 128;
// Mug dimensions
outer_d = 80;
inner_d = 70;
mug_h = 90;
bottom_t = 6;
// Handle inner opening dimensions
handle_open_w = 25; // width in radial (X) direction
handle_open_h = 30; // height in Z direction
// Handle thickness
handle_wall = 5;
// Derived mug radii
outer_r = outer_d / 2;
inner_r = inner_d / 2;
// Handle dimensions
handle_outer_w = handle_open_w + handle_wall; // D-shape total width (straight side to farthest point)
handle_outer_h = handle_open_h + 2 * handle_wall;
handle_inner_r = handle_open_h / 2;
handle_outer_r = handle_outer_h / 2;
handle_center_z = mug_h / 2;
// Slight overlap into mug body to guarantee manifold union
attach_overlap = 1.0;
// 2D D-shape in XZ plane:
// left side is the straight attachment side, right side is the semicircular outer side
module d2d(x_left, z_center, total_w, total_h) {
r = total_h / 2;
union() {
square_w = total_w - r;
translate([x_left, z_center - r])
square([square_w, total_h], center = false);
translate([x_left + square_w, z_center])
circle(r = r);
}
}
module mug_body() {
difference() {
cylinder(h = mug_h, r = outer_r);
translate([0, 0, bottom_t])
cylinder(h = mug_h - bottom_t + 0.01, r = inner_r);
}
}
module handle() {
difference() {
// Outer handle body
linear_extrude(height = handle_outer_h, center = true)
d2d(outer_r - attach_overlap, handle_center_z, handle_outer_w + attach_overlap, handle_outer_h);
// Inner finger opening
linear_extrude(height = handle_open_h, center = true)
d2d(outer_r + handle_wall, handle_center_z, handle_open_w, handle_open_h);
}
}
union() {
mug_body();
handle();
}