diff vs bare: +48/-31
// マグカップ
// 外径: 80mm, 高さ: 100mm, 肉厚: 4mm, 底厚: 6mm
$fn = 128;
// パラメータ
- outer_radius = 40; // 外径80mm → 半径40mm
- cup_height = 100; // 高さ
- wall = 4; // 肉厚
- bottom = 6; // 底面の厚み
+ outer_radius = 40; // 外径80mm → 半径40mm
+ cup_height = 100; // 高さ
+ wall = 4; // 肉厚
+ bottom = 6; // 底面の厚み
inner_radius = outer_radius - wall; // 内径半径 = 36mm
// 取手パラメータ
- handle_tube_radius = 6; // 取手チューブの断面半径
- handle_ring_radius = 18; // 取手リングの中心半径(リング中心までの距離)
- handle_height = cup_height / 2; // カップ中心高さ
- handle_offset = outer_radius + handle_ring_radius; // リング中心のX座標
+ handle_tube_r = 6; // 取手チューブ断面の半径
+ handle_ring_r = 18; // 取手リング中心半径(リング中心軌跡の半径)
+ handle_z = cup_height / 2; // 取手中心高さ(カップ中央)
+ // リング中心のX座標:カップ外周 + リング半径
+ handle_cx = outer_radius + handle_ring_r;
- difference() {
- union() {
- // カップ本体(外側シリンダー)
+ module cup_body() {
+ difference() {
+ // カップ外側
cylinder(h = cup_height, r = outer_radius);
+ // 内側をくり抜く
+ translate([0, 0, bottom])
+ cylinder(h = cup_height - bottom + 1, r = inner_radius);
+ }
+ }
- // 取手:トーラス状リング(側面に接続)
- translate([handle_offset, 0, handle_height])
+ module handle() {
+ // トーラス状取手(中空)
+ difference() {
+ // 取手外形トーラス
+ translate([handle_cx, 0, handle_z])
rotate([90, 0, 0])
- rotate_extrude(angle = 360, $fn = 128)
- translate([handle_ring_radius, 0, 0])
- circle(r = handle_tube_radius, $fn = 64);
+ rotate_extrude($fn = 128)
+ translate([handle_ring_r, 0, 0])
+ circle(r = handle_tube_r, $fn = 64);
+
+ // 取手内部を中空にする
+ translate([handle_cx, 0, handle_z])
+ rotate([90, 0, 0])
+ rotate_extrude($fn = 128)
+ translate([handle_ring_r, 0, 0])
+ circle(r = handle_tube_r - wall, $fn = 64);
}
+ }
- // 内側をくり抜く(底面を残す)
- translate([0, 0, bottom])
- cylinder(h = cup_height - bottom + 1, r = inner_radius);
+ // カップ本体と取手を結合し、取手付け根をカップ外周に埋め込む
+ union() {
+ cup_body();
- // 取手の内部をくり抜く(中空チューブにする)
- translate([handle_offset, 0, handle_height])
- rotate([90, 0, 0])
- rotate_extrude(angle = 360, $fn = 128)
- translate([handle_ring_radius, 0, 0])
- circle(r = handle_tube_radius - wall, $fn = 64);
+ // 取手本体(トーラス)をカップ外周にオーバーラップさせて配置
+ // カップ外周側はカップ本体に埋まり、外側に突き出る
+ translate([outer_radius - handle_ring_r + handle_ring_r, 0, 0])
+ handle();
- // 取手とカップ本体の接合部の穴を開けて指が通るようにする
- // (カップ内部のくり抜きがリング中心空洞と干渉しないよう、
- // 取手内部の穴がカップ外壁を貫通する部分のみ除去)
- // 取手内部空洞(カップ壁を通り抜ける穴)
- translate([outer_radius - wall - 0.5, 0, handle_height])
+ // 取手付け根:カップ外壁に接続する短いシリンダーパッド(上下)
+ // 上側接続
+ translate([outer_radius - handle_tube_r/2, 0, handle_z + handle_ring_r - handle_tube_r])
rotate([0, 90, 0])
- cylinder(h = wall * 2 + 1, r = handle_tube_radius - wall, $fn = 64);
+ cylinder(h = handle_tube_r * 2, r = handle_tube_r, $fn = 64);
+ // 下側接続
+ translate([outer_radius - handle_tube_r/2, 0, handle_z - handle_ring_r + handle_tube_r - handle_tube_r*2])
+ rotate([0, 90, 0])
+ cylinder(h = handle_tube_r * 2, r = handle_tube_r, $fn = 64);
}
SCAD (67 lines)
// マグカップ
// 外径: 80mm, 高さ: 100mm, 肉厚: 4mm, 底厚: 6mm
$fn = 128;
// パラメータ
outer_radius = 40; // 外径80mm → 半径40mm
cup_height = 100; // 高さ
wall = 4; // 肉厚
bottom = 6; // 底面の厚み
inner_radius = outer_radius - wall; // 内径半径 = 36mm
// 取手パラメータ
handle_tube_r = 6; // 取手チューブ断面の半径
handle_ring_r = 18; // 取手リング中心半径(リング中心軌跡の半径)
handle_z = cup_height / 2; // 取手中心高さ(カップ中央)
// リング中心のX座標:カップ外周 + リング半径
handle_cx = outer_radius + handle_ring_r;
module cup_body() {
difference() {
// カップ外側
cylinder(h = cup_height, r = outer_radius);
// 内側をくり抜く
translate([0, 0, bottom])
cylinder(h = cup_height - bottom + 1, r = inner_radius);
}
}
module handle() {
// トーラス状取手(中空)
difference() {
// 取手外形トーラス
translate([handle_cx, 0, handle_z])
rotate([90, 0, 0])
rotate_extrude($fn = 128)
translate([handle_ring_r, 0, 0])
circle(r = handle_tube_r, $fn = 64);
// 取手内部を中空にする
translate([handle_cx, 0, handle_z])
rotate([90, 0, 0])
rotate_extrude($fn = 128)
translate([handle_ring_r, 0, 0])
circle(r = handle_tube_r - wall, $fn = 64);
}
}
// カップ本体と取手を結合し、取手付け根をカップ外周に埋め込む
union() {
cup_body();
// 取手本体(トーラス)をカップ外周にオーバーラップさせて配置
// カップ外周側はカップ本体に埋まり、外側に突き出る
translate([outer_radius - handle_ring_r + handle_ring_r, 0, 0])
handle();
// 取手付け根:カップ外壁に接続する短いシリンダーパッド(上下)
// 上側接続
translate([outer_radius - handle_tube_r/2, 0, handle_z + handle_ring_r - handle_tube_r])
rotate([0, 90, 0])
cylinder(h = handle_tube_r * 2, r = handle_tube_r, $fn = 64);
// 下側接続
translate([outer_radius - handle_tube_r/2, 0, handle_z - handle_ring_r + handle_tube_r - handle_tube_r*2])
rotate([0, 90, 0])
cylinder(h = handle_tube_r * 2, r = handle_tube_r, $fn = 64);
}