diff vs bare: +32/-50
// マグ本体パラメータ
mug_outer_diameter = 80; // mm
mug_inner_diameter = 70; // mm
mug_height = 90; // mm
mug_wall_thickness = 5; // mm
mug_bottom_thickness = 6; // mm
// 取手パラメータ
handle_inner_height = 30; // mm
handle_inner_width = 25; // mm
handle_thickness = 12; // mm (グリップの厚み)
- handle_clearance = 3; // mm (マグと取手のすき間:0でぴったり)
+ handle_clearance = 0; // mm (マグと取手のすき間:0でぴったり)
// 共通計算
mug_radius = mug_outer_diameter / 2;
mug_inner_radius = mug_inner_diameter / 2;
handle_top = (mug_height + handle_inner_height) / 2;
handle_bottom = (mug_height - handle_inner_height) / 2;
handle_center_y = 0;
handle_center_z = mug_height / 2;
// マグのメインモジュール
module mug_body() {
difference() {
// 外側
cylinder(h = mug_height, r = mug_radius, $fn = 128);
// 内部空間(底厚分上げる)
translate([0, 0, mug_bottom_thickness])
cylinder(h = mug_height - mug_bottom_thickness, r = mug_inner_radius, $fn = 128);
}
}
// D字ハンドル
module mug_handle() {
- // D字の中心半径: (内幅+厚み)/2
+ // D字グリップの円弧半径
handle_outer_radius = (handle_inner_width + handle_thickness) / 2;
- handle_inner_radius = handle_inner_width / 2;
+ handle_inner_radius = handle_outer_radius - handle_thickness;
- // 上下の位置
- z_pos = mug_height / 2 - handle_inner_height / 2;
+ // ハンドル中心の x 方向座標(マグ外縁+取っ手外半径、隙間なし)
+ handle_center_x = mug_radius + handle_outer_radius;
- // ハンドル中心(x 座標: 本体外半径 + handle_thickness/2)
- translate([mug_radius + handle_thickness / 2 - handle_clearance, 0, handle_bottom]) {
- // D字全体
+ // ハンドルの中心高さ
+ handle_center_z = mug_height / 2;
+
+ // D字部分(半円部分+上下の直線バー)
+ translate([handle_center_x, 0, handle_center_z]) {
difference() {
- // 外側D
+ // 外側(D字: 半円弧+直線)
union() {
- // 半円部分
- rotate([90,0,0])
- translate([0, 0, handle_inner_height/2])
- cylinder(h = handle_thickness, r = handle_outer_radius, center=true, $fn=64, segment1=true);
- // 直線部分(上下のバー)
+ // 半円弧
+ rotate([0,90,0])
+ rotate([0,0,90])
+ linear_extrude(height=handle_thickness, center=true)
+ offset(0)
+ arc_points(handle_outer_radius, 180);
+ // 上下の直線バー
for (sign=[-1,1])
- translate([0, sign*(handle_inner_height/2), 0])
+ translate([0, sign*handle_inner_height/2, 0])
cube([handle_outer_radius, handle_thickness, handle_thickness], center = true);
}
// 内側カット
union() {
- // 半円部分
- rotate([90,0,0])
- translate([0, 0, handle_inner_height/2])
- cylinder(h = handle_thickness+0.1, r = handle_inner_radius, center=true, $fn=64, segment1=true);
- // 直線部分
+ // 半円弧
+ rotate([0,90,0])
+ rotate([0,0,90])
+ linear_extrude(height=handle_thickness+0.2, center=true)
+ offset(0)
+ arc_points(handle_inner_radius, 180);
+ // 上下の直線バー
for (sign=[-1,1])
- translate([0, sign*(handle_inner_height/2), 0])
- cube([handle_inner_radius+0.1, handle_thickness+0.1, handle_thickness+0.1], center = true);
+ translate([0, sign*handle_inner_height/2, 0])
+ cube([handle_inner_radius+0.2, handle_thickness+0.2, handle_thickness+0.2], center = true);
}
}
}
}
+ // 2D半円弧のポリゴン(中心始点+極座標)
+ function arc_points(r, deg=180, steps=64) =
+ concat([[0,0]], [for (a = [0 : deg/(steps-1) : deg]) [r*cos(a), r*sin(a)]]);
+
// マグとハンドルの合成
union() {
mug_body();
mug_handle();
- }
-
- // 円柱の半円(セグメント)を描画するための segment1=true 拡張
- // OpenSCADの標準 cylinder では使えません。互換目的のヘルパー:
- module cylinder(h, r, segment1=false, $fn=64, center=false) {
- if (!segment1)
- builtin_cylinder(h=h, r=r, $fn=$fn, center=center);
- else
- rotate([0,0,90])
- linear_extrude(height=h, center=center)
- offset(0)
- arc(r, 180);
- }
- module builtin_cylinder(h, r, $fn=64, center=false) {
- // シンプルな円
- if (!center)
- cylinder(h=h, r=r, $fn=$fn);
- else
- translate([0,0,-h/2]) cylinder(h=h, r=r, $fn=$fn);
- }
- module arc(r, angle) {
- polygon(
- concat(
- [[0,0]],
- [ for (a = [0:angle/($fn-1):angle]) [ r*cos(a), r*sin(a) ] ],
- [[0,0]]
- )
- );
}
SCAD (86 lines)
// マグ本体パラメータ
mug_outer_diameter = 80; // mm
mug_inner_diameter = 70; // mm
mug_height = 90; // mm
mug_wall_thickness = 5; // mm
mug_bottom_thickness = 6; // mm
// 取手パラメータ
handle_inner_height = 30; // mm
handle_inner_width = 25; // mm
handle_thickness = 12; // mm (グリップの厚み)
handle_clearance = 0; // mm (マグと取手のすき間:0でぴったり)
// 共通計算
mug_radius = mug_outer_diameter / 2;
mug_inner_radius = mug_inner_diameter / 2;
handle_top = (mug_height + handle_inner_height) / 2;
handle_bottom = (mug_height - handle_inner_height) / 2;
handle_center_y = 0;
handle_center_z = mug_height / 2;
// マグのメインモジュール
module mug_body() {
difference() {
// 外側
cylinder(h = mug_height, r = mug_radius, $fn = 128);
// 内部空間(底厚分上げる)
translate([0, 0, mug_bottom_thickness])
cylinder(h = mug_height - mug_bottom_thickness, r = mug_inner_radius, $fn = 128);
}
}
// D字ハンドル
module mug_handle() {
// D字グリップの円弧半径
handle_outer_radius = (handle_inner_width + handle_thickness) / 2;
handle_inner_radius = handle_outer_radius - handle_thickness;
// ハンドル中心の x 方向座標(マグ外縁+取っ手外半径、隙間なし)
handle_center_x = mug_radius + handle_outer_radius;
// ハンドルの中心高さ
handle_center_z = mug_height / 2;
// D字部分(半円部分+上下の直線バー)
translate([handle_center_x, 0, handle_center_z]) {
difference() {
// 外側(D字: 半円弧+直線)
union() {
// 半円弧
rotate([0,90,0])
rotate([0,0,90])
linear_extrude(height=handle_thickness, center=true)
offset(0)
arc_points(handle_outer_radius, 180);
// 上下の直線バー
for (sign=[-1,1])
translate([0, sign*handle_inner_height/2, 0])
cube([handle_outer_radius, handle_thickness, handle_thickness], center = true);
}
// 内側カット
union() {
// 半円弧
rotate([0,90,0])
rotate([0,0,90])
linear_extrude(height=handle_thickness+0.2, center=true)
offset(0)
arc_points(handle_inner_radius, 180);
// 上下の直線バー
for (sign=[-1,1])
translate([0, sign*handle_inner_height/2, 0])
cube([handle_inner_radius+0.2, handle_thickness+0.2, handle_thickness+0.2], center = true);
}
}
}
}
// 2D半円弧のポリゴン(中心始点+極座標)
function arc_points(r, deg=180, steps=64) =
concat([[0,0]], [for (a = [0 : deg/(steps-1) : deg]) [r*cos(a), r*sin(a)]]);
// マグとハンドルの合成
union() {
mug_body();
mug_handle();
}