vibe-openscad

tier-2-offset-handle-mug / gpt-5-mini-2025-08-07

7 run / 累計 756.7s / 累計 $0.1034

openai gpt 5 mini 2025-08-07 bare

bare (provider default effort)

run detail →
render
no render
render_error 148.0s · 273/9491t · $0.0191
openscad stl render failed (exit 1): ERROR: Parser error: syntax error in file ../../../../../tmp/render-o5lJCl/input.scad, line 43
Can't parse file '/tmp/render-o5lJCl/input.scad'!

SCAD (70 lines)
// OpenSCAD: マグカップ (指定寸法) + D字取手(+X 側のみ)
// 単位: mm

$fn = 120; // 円を滑らかに

// -------- パラメータ --------
mug_outer_r = 40;    // 外半径 (外径 80)
mug_inner_r = 35;    // 内半径 (内径 70)
mug_h = 90;          // 高さ
bottom_thickness = 6;

handle_overlap = 1;          // 本体へめり込み量(接合確実化)
flat_face_x = mug_outer_r - handle_overlap; // 取手の本体接触面の X 座標 (本体側直線)
inner_open_w = 25;          // 取手内側空間の幅 (radial direction)
inner_open_h = 30;          // 取手内側空間の高さ (vertical direction)
handle_wall = 8;            // 取手の外側と内側の間の厚み(適度に確保)
R_out = inner_open_w + handle_wall; // 外側半円の半径(平面投影)
handle_extrude_h = 40;      // 取手全体の垂直厚み(内空間高さより大きく取る)
mug_center_z = mug_h/2;

// 取手配置用座標
outer_center_x = flat_face_x + R_out; // 外側半円の中心 x
inner_void_left_x = mug_outer_r;      // 内側空間の左端をマグ本体外周(=40)に合わせる(本体への穴の侵入を防ぐ)
inner_void_right_x = inner_void_left_x + inner_open_w;

// Z 配置
handle_z_bottom = mug_center_z - handle_extrude_h/2; // 取手外形の下端 (global Z)
inner_void_z = mug_center_z - inner_open_h/2;        // 内空間の下端 (global Z)

// -------- モジュール --------
module mug() {
    // 外殻 - 中空底付きの円筒
    difference() {
        // 外側
        translate([0,0,0]) cylinder(h=mug_h, r=mug_outer_r);
        // 内側の空間(底厚を残す)
        translate([0,0,bottom_thickness]) cylinder(h=mug_h - bottom_thickness, r=mug_inner_r);
    }
}

module handle_piece() {
    // 2D 外側半円形 (flat_face_x を直径の線とする半円)
    outer2d = intersection() {
        translate([outer_center_x, 0]) circle(r=R_out);
        // 半平面 x >= flat_face_x をつくる大きな矩形
        translate([flat_face_x, - (R_out + 10)]) square([ (outer_center_x+R_out) - flat_face_x + 10, 2*(R_out + 10) ]);
    }

    // 取手の外形を押し出してグローバル空間に配置
    outer_extruded = translate([0,0,handle_z_bottom]) linear_extrude(height = handle_extrude_h, center = false, convexity = 10) outer2d;

    // 取手内側の指を入れる空間(長方形で簡潔に)
    inner_void = translate([inner_void_left_x, -inner_open_h/2, inner_void_z]) cube([inner_open_w, inner_open_h, inner_open_h], center = false);

    // 内空間を差し引いて取手本体を得る
    difference() {
        outer_extruded;
        inner_void;
    }
}

// -------- 組み立て --------
union() {
    // 本体
    mug();

    // 取手(+X 側のみ)
    // 差し引きを済ませた取手本体をそのまま union する(flat_face_x による少しのめり込みで確実に接続)
    handle_piece();
}

prompt

OpenSCAD で、向きが指定されたマグカップを作ってください。

本体:
- 外径 80mm、内径 70mm(肉厚 5mm)、高さ 90mm の円筒形マグ
- 底面の厚みは 6mm
- 内側は飲み物を入れられるよう中空

取手(handle):
- マグの **+X 軸方向の側面のみ** に付ける(他の方向には付けない)
- 取手は D 字形状(外側が半円、本体側が直線)で、本体外周にしっかり接続する
- 取手の内側の空間は高さ 30mm × 幅 25mm(指 3 本ぐらい入る)
- 取手はマグの高さ方向の中央付近に付ける
- 本体と取手は確実に union され、マニフォールド(隙間や宙吊りなし)を保つ

完成したコード全体を ```openscad ... ``` のフェンスで囲んで出力してください。コードのみで、追加の説明は不要です。

variant: effort

low success
low
53.7s · 273/3314t · $0.0067
SCAD (124 lines)
// OpenSCAD: マグカップ(指定向きの D 字ハンドル:+X 側のみ)
// 本体: 外径 80mm、内径 70mm、肉厚 5mm、高さ 90mm、底厚 6mm
// 取手: +X 側のみ、D 字形状、内側の開口高さ 30mm × 幅 25mm、マグ高さ中央付近に配置
// 本体と取手は確実に union(オーバーラップを持たせて接続)

$fn = 96; // なめらかさ

// 基本パラメータ
outer_diam = 80;
inner_diam = 70;
thickness = (outer_diam - inner_diam) / 2; // 5 mm
cup_height = 90;
bottom_thickness = 6;

cup_outer_r = outer_diam / 2;
cup_inner_r = inner_diam / 2;
cup_inner_height = cup_height - bottom_thickness; // 飲み物を入れられる高さ

// 取手パラメータ
handle_open_h = 30; // 取手の内側の高さ (Z方向)
handle_open_w = 25; // 取手の内側の幅 (Y方向, マグ本体側から外向きの距離)
handle_center_z = cup_height / 2; // 高さ方向中央付近
// 取手の外形(半円+直線の D 字)。平面 (Y,Z) で作り、X方向に押し出す。
handle_penetration = 6; // マグ本体へめり込ませる量(確実に接続させる)
handle_extrude_neg = -8; // 押し出しの負側(マグ中心方向へめり込む)
handle_extrude_pos = 20; // 押し出しのプラス側(外側への厚み)
handle_outer_radius = 24; // 取手外側の半円半径(見た目と強度用)

// 取手の平面配置(Y方向)
handle_flat_y = cup_outer_r - handle_penetration; // 平らな内側がこの y に来る(本体に近接)
handle_circle_center_y = handle_flat_y + handle_outer_radius; // 半円の中心位置(Y)

// 取手の垂直方向(Z)境界(外側の形状の余裕を持たせる)
handle_extra_h = 8; // 上下に余裕を持たせる(面取り用)
handle_outer_z1 = handle_center_z - (handle_open_h/2) - handle_extra_h;
handle_outer_z2 = handle_center_z + (handle_open_h/2) + handle_extra_h;

// 取手内側切り欠き(指を入れる空間)の矩形(Y,Z)
handle_cut_y1 = handle_flat_y;
handle_cut_y2 = handle_flat_y + handle_open_w;
handle_cut_z1 = handle_center_z - (handle_open_h/2);
handle_cut_z2 = handle_center_z + (handle_open_h/2);

// メイン
module mug_body() {
    // 外殻
    difference() {
        // 外側筒(底付き)
        union() {
            // 外筒
            translate([0,0,0])
                cylinder(h = cup_height, r = cup_outer_r);
            // 底板(底の厚みを明示的に付け足す必要は無いが確実化)
            translate([0,0,0])
                cylinder(h = bottom_thickness, r = cup_outer_r);
        }
        // 内側くり抜き(中空)
        translate([0,0,bottom_thickness])
            cylinder(h = cup_inner_height, r = cup_inner_r);
    }
}

module handle_solid() {
    // 2D プロファイルを作って X 方向に線形押し出し
    // Y-Z 平面で作業する(ここでは 2D を作るために translate で平面調整)
    translate([0,0,0]) {
        linear_extrude(height = handle_extrude_pos - handle_extrude_neg, center = false, convexity = 10)
            translate([0,0]) // no-op, keep coords clear
                difference() {
                    // 外形: 半円 (右側) と矩形(左側の平ら部分を含む)
                    union() {
                        // 半円(円の上半分+下半分を合わせるが、矩形と和を取ることで D 字になる)
                        translate([handle_circle_center_y, handle_center_z])
                            circle(r = handle_outer_radius);
                        // 平らな左側を埋める矩形(半円の左端から左側へ伸ばす)
                        translate([handle_flat_y, handle_outer_z1])
                            square([ (handle_circle_center_y + handle_outer_radius) - handle_flat_y, (handle_outer_z2 - handle_outer_z1) ], center = false);
                    }
                    // 指を入れるための切り欠き(矩形で切る)
                    translate([handle_cut_y1, handle_cut_z1])
                        square([ handle_cut_y2 - handle_cut_y1, handle_cut_z2 - handle_cut_z1 ], center = false);
                    // また縦方向の角を少し丸めたい場合はここで更に小さな丸を差し引く等できる(今回は矩形切り抜きで要件満たす)
                }
            ;
    }
}

// 全体配置
module mug_with_handle() {
    // 本体
    mug_body();
    // 取手(押し出しは X 方向なので、2D プロファイルの原点を X=handle_extrude_neg に合わせる)
    // linear_extrude のデフォルトは Z 方向押し出しなので、上で Z を使ったがここは X に押し出すため rotate する
}

// 実体化:座標系を合わせて union (確実に接続するために取手を少しめり込ませてある)
union() {
    // マグ本体(Z 方向が高さ)
    translate([0,0,0])
        mug_body();

    // 取手:先に作った 2D を X 押し出しにするため rotate と translate を適用
    // ここでは作りやすさのため、上で定義した linear_extrude は Z 押し出しなので rotate して X 方向へ
    translate([handle_extrude_neg, 0, 0]) // 押し出しの負側をマイナス X へオフセット
        rotate([0, -90, 0]) // Z 押し出しを X 押し出しに変換
            translate([0, -handle_circle_center_y, -handle_center_z]) // 2D プロファイルの中心位置調整
                handle_solid();
}

// 内部空洞(飲み物領域)を最後に差し引いて完成(取手は本体とユニオン済みのため問題なし)
difference() {
    // これまでの union(本体+取手)はすでに描かれているため再描画
    // To ensure correct boolean ordering, recreate base solids then subtract interior
    union() {
        mug_body();
        translate([handle_extrude_neg, 0, 0])
            rotate([0, -90, 0])
                translate([0, -handle_circle_center_y, -handle_center_z])
                    handle_solid();
    }
    // 内側くり抜き(飲み物領域)
    translate([0,0,bottom_thickness])
        cylinder(h = cup_inner_height, r = cup_inner_r);
}
medium (default) render_error render
render_error
148.0s · 273/9491t · $0.0191
openscad stl render failed (exit 1): ERROR: Parser error: syntax error in file ../../../../../tmp/render-o5lJCl/input.scad, line 43
Can't parse file '/tmp/render-o5lJCl/input.scad'!

SCAD (70 lines)
// OpenSCAD: マグカップ (指定寸法) + D字取手(+X 側のみ)
// 単位: mm

$fn = 120; // 円を滑らかに

// -------- パラメータ --------
mug_outer_r = 40;    // 外半径 (外径 80)
mug_inner_r = 35;    // 内半径 (内径 70)
mug_h = 90;          // 高さ
bottom_thickness = 6;

handle_overlap = 1;          // 本体へめり込み量(接合確実化)
flat_face_x = mug_outer_r - handle_overlap; // 取手の本体接触面の X 座標 (本体側直線)
inner_open_w = 25;          // 取手内側空間の幅 (radial direction)
inner_open_h = 30;          // 取手内側空間の高さ (vertical direction)
handle_wall = 8;            // 取手の外側と内側の間の厚み(適度に確保)
R_out = inner_open_w + handle_wall; // 外側半円の半径(平面投影)
handle_extrude_h = 40;      // 取手全体の垂直厚み(内空間高さより大きく取る)
mug_center_z = mug_h/2;

// 取手配置用座標
outer_center_x = flat_face_x + R_out; // 外側半円の中心 x
inner_void_left_x = mug_outer_r;      // 内側空間の左端をマグ本体外周(=40)に合わせる(本体への穴の侵入を防ぐ)
inner_void_right_x = inner_void_left_x + inner_open_w;

// Z 配置
handle_z_bottom = mug_center_z - handle_extrude_h/2; // 取手外形の下端 (global Z)
inner_void_z = mug_center_z - inner_open_h/2;        // 内空間の下端 (global Z)

// -------- モジュール --------
module mug() {
    // 外殻 - 中空底付きの円筒
    difference() {
        // 外側
        translate([0,0,0]) cylinder(h=mug_h, r=mug_outer_r);
        // 内側の空間(底厚を残す)
        translate([0,0,bottom_thickness]) cylinder(h=mug_h - bottom_thickness, r=mug_inner_r);
    }
}

module handle_piece() {
    // 2D 外側半円形 (flat_face_x を直径の線とする半円)
    outer2d = intersection() {
        translate([outer_center_x, 0]) circle(r=R_out);
        // 半平面 x >= flat_face_x をつくる大きな矩形
        translate([flat_face_x, - (R_out + 10)]) square([ (outer_center_x+R_out) - flat_face_x + 10, 2*(R_out + 10) ]);
    }

    // 取手の外形を押し出してグローバル空間に配置
    outer_extruded = translate([0,0,handle_z_bottom]) linear_extrude(height = handle_extrude_h, center = false, convexity = 10) outer2d;

    // 取手内側の指を入れる空間(長方形で簡潔に)
    inner_void = translate([inner_void_left_x, -inner_open_h/2, inner_void_z]) cube([inner_open_w, inner_open_h, inner_open_h], center = false);

    // 内空間を差し引いて取手本体を得る
    difference() {
        outer_extruded;
        inner_void;
    }
}

// -------- 組み立て --------
union() {
    // 本体
    mug();

    // 取手(+X 側のみ)
    // 差し引きを済ませた取手本体をそのまま union する(flat_face_x による少しのめり込みで確実に接続)
    handle_piece();
}
high success
high
280.7s · 273/19840t · $0.0397
SCAD (57 lines)
// OpenSCAD: D-shaped mug with handle on +X side
$fn = 120;

// --- Parameters ---
outer_d = 80;            // 外径
inner_d = 70;            // 内径
r_out = outer_d/2;
r_in  = inner_d/2;
height = 90;             // 高さ
bottom_thickness = 6;    // 底面の厚み

// 取手パラメータ
handle_inner_height = 30;   // 取手内側の高さ (Z)
handle_vert_margin = 5;     // 上下の余裕(取手の上下の接続部)
handle_height = handle_inner_height + 2*handle_vert_margin;
z_center = height/2;
handle_z_bottom = z_center - handle_height/2;

handle_flat_x = r_out - 2;  // 直線側の平面 X (マグに重なるように2mmオーバーラップ)
handle_cx = handle_flat_x;  // 半円の中心 X
R_handle_outer = 32;        // 半円の半径(外側)

// 取手内側の空間(指定どおり 高さ 30mm × 幅 25mm)
cavity_height = handle_inner_height;   // Z: 30
cavity_width_y = 25;                   // Y: 25
cavity_depth_x = 25;                   // X方向の深さ(マグ外周からの距離)←幅の解釈に合わせて設定
cavity_x_left = r_out;                 // 左端をマグ外周に合わせる(x = 40)
cavity_y_len = cavity_width_y;
cavity_z_bottom = z_center - cavity_height/2;

// --- 出力 ---
union() {
  // 本体(外筒 - 内筒)
  difference() {
    // 外筒
    cylinder(h = height, r = r_out, center = false);
    // 内筒(底厚を残すために z = bottom_thickness から高さを短くする)
    translate([0,0,bottom_thickness])
      cylinder(h = height - bottom_thickness, r = r_in, center = false);
  }

  // 取手(外形は半円(D字外側)、本体と確実に重なるように平面側を内側に少しオーバーラップ)
  difference() {
    // 半円を2Dで作って押し出す(右向きの半円:平面は x = handle_cx)
    translate([0,0,handle_z_bottom])
      linear_extrude(height = handle_height, center = false, convexity = 10)
        intersection() {
          translate([handle_cx, 0]) circle(R_handle_outer);
          // 半平面 (x >= handle_cx) を作るための大きな四角形
          translate([handle_cx, -1000]) square([10000, 2000]);
        }

    // 取手内側の空間(矩形スロット)を差し引く(高さは正確に 30mm、幅 25mm)
    translate([cavity_x_left, -cavity_y_len/2, cavity_z_bottom])
      cube([cavity_depth_x, cavity_y_len, cavity_height], center = false);
  }
}
maxnot run
xhighnot run

iteration: iter-png

i1 success
iter 1
35.3s · 1295/2094t · $0.0045
diff vs bare: +17/-22
  // OpenSCAD: マグカップ (指定寸法) + D字取手(+X 側のみ)
  // 単位: mm
  
  $fn = 120; // 円を滑らかに
  
  // -------- パラメータ --------
  mug_outer_r = 40;    // 外半径 (外径 80)
  mug_inner_r = 35;    // 内半径 (内径 70)
  mug_h = 90;          // 高さ
  bottom_thickness = 6;
  
  handle_overlap = 1;          // 本体へめり込み量(接合確実化)
  flat_face_x = mug_outer_r - handle_overlap; // 取手の本体接触面の X 座標 (本体側直線)
  inner_open_w = 25;          // 取手内側空間の幅 (radial direction)
  inner_open_h = 30;          // 取手内側空間の高さ (vertical direction)
- handle_wall = 8;            // 取手の外側と内側の間の厚み(適度に確保)
+ handle_wall = 8;            // 取手の外側と内側の間の厚み
  R_out = inner_open_w + handle_wall; // 外側半円の半径(平面投影)
- handle_extrude_h = 40;      // 取手全体の垂直厚み(内空間高さより大きく取る)
+ handle_extrude_h = 40;      // 取手の垂直厚み(内空間高さより大きく取る)
  mug_center_z = mug_h/2;
  
  // 取手配置用座標
  outer_center_x = flat_face_x + R_out; // 外側半円の中心 x
- inner_void_left_x = mug_outer_r;      // 内側空間の左端をマグ本体外周(=40)に合わせる(本体への穴の侵入を防ぐ)
- inner_void_right_x = inner_void_left_x + inner_open_w;
- 
+ inner_void_left_x = mug_outer_r;      // 内側空間の左端をマグ本体外周に合わせる
  // Z 配置
  handle_z_bottom = mug_center_z - handle_extrude_h/2; // 取手外形の下端 (global Z)
  inner_void_z = mug_center_z - inner_open_h/2;        // 内空間の下端 (global Z)
  
  // -------- モジュール --------
  module mug() {
      // 外殻 - 中空底付きの円筒
      difference() {
          // 外側
          translate([0,0,0]) cylinder(h=mug_h, r=mug_outer_r);
          // 内側の空間(底厚を残す)
          translate([0,0,bottom_thickness]) cylinder(h=mug_h - bottom_thickness, r=mug_inner_r);
      }
  }
  
  module handle_piece() {
-     // 2D 外側半円形 (flat_face_x を直径の線とする半円)
-     outer2d = intersection() {
-         translate([outer_center_x, 0]) circle(r=R_out);
-         // 半平面 x >= flat_face_x をつくる大きな矩形
-         translate([flat_face_x, - (R_out + 10)]) square([ (outer_center_x+R_out) - flat_face_x + 10, 2*(R_out + 10) ]);
-     }
- 
-     // 取手の外形を押し出してグローバル空間に配置
-     outer_extruded = translate([0,0,handle_z_bottom]) linear_extrude(height = handle_extrude_h, center = false, convexity = 10) outer2d;
- 
-     // 取手内側の指を入れる空間(長方形で簡潔に)
-     inner_void = translate([inner_void_left_x, -inner_open_h/2, inner_void_z]) cube([inner_open_w, inner_open_h, inner_open_h], center = false);
- 
-     // 内空間を差し引いて取手本体を得る
+     // 取手外形(2D 半円を押し出す)から内側の指空間を差し引く
      difference() {
-         outer_extruded;
-         inner_void;
+         // 外形の押し出し(2D: 半円)
+         translate([0,0,handle_z_bottom])
+             linear_extrude(height = handle_extrude_h, center = false, convexity = 10)
+                 intersection() {
+                     translate([outer_center_x, 0]) circle(r=R_out);
+                     // 半分に切るための大きな矩形(少し余裕を持たせる)
+                     translate([flat_face_x - 10, -(R_out + 10)])
+                         square([ (outer_center_x + R_out) - (flat_face_x - 10) + 20, 2*(R_out + 10) ]);
+                 }
+ 
+         // 取手内側の空間を差し引く(十分に大きな Y 範囲で貫通させる)
+         translate([inner_void_left_x, -(R_out + 10), inner_void_z])
+             cube([inner_open_w, 2*(R_out + 10), inner_open_h]);
      }
  }
  
  // -------- 組み立て --------
  union() {
      // 本体
      mug();
  
      // 取手(+X 側のみ)
-     // 差し引きを済ませた取手本体をそのまま union する(flat_face_x による少しのめり込みで確実に接続)
      handle_piece();
  }
SCAD (65 lines)
// OpenSCAD: マグカップ (指定寸法) + D字取手(+X 側のみ)
// 単位: mm

$fn = 120; // 円を滑らかに

// -------- パラメータ --------
mug_outer_r = 40;    // 外半径 (外径 80)
mug_inner_r = 35;    // 内半径 (内径 70)
mug_h = 90;          // 高さ
bottom_thickness = 6;

handle_overlap = 1;          // 本体へめり込み量(接合確実化)
flat_face_x = mug_outer_r - handle_overlap; // 取手の本体接触面の X 座標 (本体側直線)
inner_open_w = 25;          // 取手内側空間の幅 (radial direction)
inner_open_h = 30;          // 取手内側空間の高さ (vertical direction)
handle_wall = 8;            // 取手の外側と内側の間の厚み
R_out = inner_open_w + handle_wall; // 外側半円の半径(平面投影)
handle_extrude_h = 40;      // 取手の垂直厚み(内空間高さより大きく取る)
mug_center_z = mug_h/2;

// 取手配置用座標
outer_center_x = flat_face_x + R_out; // 外側半円の中心 x
inner_void_left_x = mug_outer_r;      // 内側空間の左端をマグ本体外周に合わせる
// Z 配置
handle_z_bottom = mug_center_z - handle_extrude_h/2; // 取手外形の下端 (global Z)
inner_void_z = mug_center_z - inner_open_h/2;        // 内空間の下端 (global Z)

// -------- モジュール --------
module mug() {
    // 外殻 - 中空底付きの円筒
    difference() {
        // 外側
        translate([0,0,0]) cylinder(h=mug_h, r=mug_outer_r);
        // 内側の空間(底厚を残す)
        translate([0,0,bottom_thickness]) cylinder(h=mug_h - bottom_thickness, r=mug_inner_r);
    }
}

module handle_piece() {
    // 取手外形(2D 半円を押し出す)から内側の指空間を差し引く
    difference() {
        // 外形の押し出し(2D: 半円)
        translate([0,0,handle_z_bottom])
            linear_extrude(height = handle_extrude_h, center = false, convexity = 10)
                intersection() {
                    translate([outer_center_x, 0]) circle(r=R_out);
                    // 半分に切るための大きな矩形(少し余裕を持たせる)
                    translate([flat_face_x - 10, -(R_out + 10)])
                        square([ (outer_center_x + R_out) - (flat_face_x - 10) + 20, 2*(R_out + 10) ]);
                }

        // 取手内側の空間を差し引く(十分に大きな Y 範囲で貫通させる)
        translate([inner_void_left_x, -(R_out + 10), inner_void_z])
            cube([inner_open_w, 2*(R_out + 10), inner_open_h]);
    }
}

// -------- 組み立て --------
union() {
    // 本体
    mug();

    // 取手(+X 側のみ)
    handle_piece();
}
i2 success
iter 2
44.4s · 1763/2974t · $0.0064
diff vs i1: +24/-26
- // OpenSCAD: マグカップ (指定寸法) + D字取手(+X 側のみ)
+ // OpenSCAD: マグカップ(修正版)
  // 単位: mm
  
  $fn = 120; // 円を滑らかに
  
  // -------- パラメータ --------
  mug_outer_r = 40;    // 外半径 (外径 80)
  mug_inner_r = 35;    // 内半径 (内径 70)
  mug_h = 90;          // 高さ
  bottom_thickness = 6;
  
- handle_overlap = 1;          // 本体へめり込み量(接合確実化)
- flat_face_x = mug_outer_r - handle_overlap; // 取手の本体接触面の X 座標 (本体側直線)
- inner_open_w = 25;          // 取手内側空間の幅 (radial direction)
- inner_open_h = 30;          // 取手内側空間の高さ (vertical direction)
- handle_wall = 8;            // 取手の外側と内側の間の厚み
- R_out = inner_open_w + handle_wall; // 外側半円の半径(平面投影)
- handle_extrude_h = 40;      // 取手の垂直厚み(内空間高さより大きく取る)
+ handle_wall = 8;            // 取手の厚み(外側と内側の差)
+ inner_open_w = 25;          // 取手内側空間の幅 (指 3 本ぐらい)
+ inner_open_h = 30;          // 取手内側空間の高さ
+ R_out = inner_open_w + handle_wall; // 取手外側半円の半径
+ handle_extrude_h = inner_open_h + 10; // 取手の垂直厚み(内空間よりやや大)
  mug_center_z = mug_h/2;
  
- // 取手配置用座標
- outer_center_x = flat_face_x + R_out; // 外側半円の中心 x
- inner_void_left_x = mug_outer_r;      // 内側空間の左端をマグ本体外周に合わせる
- // Z 配置
- handle_z_bottom = mug_center_z - handle_extrude_h/2; // 取手外形の下端 (global Z)
- inner_void_z = mug_center_z - inner_open_h/2;        // 内空間の下端 (global Z)
+ // 取手の平面(フラット面)の X 座標(本体外周に合わせる)
+ flat_face_x = mug_outer_r; // フラット面をちょうど本体外周に合わせる
+ outer_center_x = flat_face_x + R_out; // 半円中心の X
  
+ // 取手内空間の位置(Z と X)
+ inner_void_left_x = flat_face_x; // 内側空間は本体外周に開口するようにする
+ inner_void_z = mug_center_z - inner_open_h/2;
+ handle_z_bottom = mug_center_z - handle_extrude_h/2;
+ 
  // -------- モジュール --------
  module mug() {
-     // 外殻 - 中空底付きの円筒
      difference() {
-         // 外側
+         // 外側の円筒
          translate([0,0,0]) cylinder(h=mug_h, r=mug_outer_r);
-         // 内側の空間(底厚を残す)
+         // 内側の空洞(底面の厚みを残す)
          translate([0,0,bottom_thickness]) cylinder(h=mug_h - bottom_thickness, r=mug_inner_r);
      }
  }
  
  module handle_piece() {
-     // 取手外形(2D 半円を押し出す)から内側の指空間を差し引く
+     // 取手外形(半円+フラット面)を押し出し、内側の指空間を差し引く
      difference() {
-         // 外形の押し出し(2D: 半円)
+         // 外形: 半円を矩形で切り取ってフラットにする
          translate([0,0,handle_z_bottom])
              linear_extrude(height = handle_extrude_h, center = false, convexity = 10)
                  intersection() {
+                     // 半径 R_out の円(半分を残す)
                      translate([outer_center_x, 0]) circle(r=R_out);
-                     // 半分に切るための大きな矩形(少し余裕を持たせる)
-                     translate([flat_face_x - 10, -(R_out + 10)])
-                         square([ (outer_center_x + R_out) - (flat_face_x - 10) + 20, 2*(R_out + 10) ]);
+                     // フラット面で切る矩形(左端を flat_face_x にする)
+                     // 少し余裕を持たせて縦方向は大きく取る
+                     translate([flat_face_x - 1, -(R_out + 10)])
+                         square([ (outer_center_x + R_out) - (flat_face_x - 1) + 20, 2*(R_out + 10) ]);
                  }
  
-         // 取手内側の空間を差し引く(十分に大きな Y 範囲で貫通させる)
+         // 内側の指空間を差し引く(外側に開口するよう左端を flat_face_x に合わせる)
          translate([inner_void_left_x, -(R_out + 10), inner_void_z])
              cube([inner_open_w, 2*(R_out + 10), inner_open_h]);
      }
  }
  
  // -------- 組み立て --------
  union() {
-     // 本体
      mug();
- 
-     // 取手(+X 側のみ)
      handle_piece();
  }
SCAD (63 lines)
// OpenSCAD: マグカップ(修正版)
// 単位: mm

$fn = 120; // 円を滑らかに

// -------- パラメータ --------
mug_outer_r = 40;    // 外半径 (外径 80)
mug_inner_r = 35;    // 内半径 (内径 70)
mug_h = 90;          // 高さ
bottom_thickness = 6;

handle_wall = 8;            // 取手の厚み(外側と内側の差)
inner_open_w = 25;          // 取手内側空間の幅 (指 3 本ぐらい)
inner_open_h = 30;          // 取手内側空間の高さ
R_out = inner_open_w + handle_wall; // 取手外側半円の半径
handle_extrude_h = inner_open_h + 10; // 取手の垂直厚み(内空間よりやや大)
mug_center_z = mug_h/2;

// 取手の平面(フラット面)の X 座標(本体外周に合わせる)
flat_face_x = mug_outer_r; // フラット面をちょうど本体外周に合わせる
outer_center_x = flat_face_x + R_out; // 半円中心の X

// 取手内空間の位置(Z と X)
inner_void_left_x = flat_face_x; // 内側空間は本体外周に開口するようにする
inner_void_z = mug_center_z - inner_open_h/2;
handle_z_bottom = mug_center_z - handle_extrude_h/2;

// -------- モジュール --------
module mug() {
    difference() {
        // 外側の円筒
        translate([0,0,0]) cylinder(h=mug_h, r=mug_outer_r);
        // 内側の空洞(底面の厚みを残す)
        translate([0,0,bottom_thickness]) cylinder(h=mug_h - bottom_thickness, r=mug_inner_r);
    }
}

module handle_piece() {
    // 取手外形(半円+フラット面)を押し出し、内側の指空間を差し引く
    difference() {
        // 外形: 半円を矩形で切り取ってフラットにする
        translate([0,0,handle_z_bottom])
            linear_extrude(height = handle_extrude_h, center = false, convexity = 10)
                intersection() {
                    // 半径 R_out の円(半分を残す)
                    translate([outer_center_x, 0]) circle(r=R_out);
                    // フラット面で切る矩形(左端を flat_face_x にする)
                    // 少し余裕を持たせて縦方向は大きく取る
                    translate([flat_face_x - 1, -(R_out + 10)])
                        square([ (outer_center_x + R_out) - (flat_face_x - 1) + 20, 2*(R_out + 10) ]);
                }

        // 内側の指空間を差し引く(外側に開口するよう左端を flat_face_x に合わせる)
        translate([inner_void_left_x, -(R_out + 10), inner_void_z])
            cube([inner_open_w, 2*(R_out + 10), inner_open_h]);
    }
}

// -------- 組み立て --------
union() {
    mug();
    handle_piece();
}
i3 success
iter 3
46.6s · 1729/3774t · $0.0080
diff vs i2: +18/-14
  // OpenSCAD: マグカップ(修正版)
  // 単位: mm
  
  $fn = 120; // 円を滑らかに
  
  // -------- パラメータ --------
  mug_outer_r = 40;    // 外半径 (外径 80)
  mug_inner_r = 35;    // 内半径 (内径 70)
  mug_h = 90;          // 高さ
  bottom_thickness = 6;
  
  handle_wall = 8;            // 取手の厚み(外側と内側の差)
  inner_open_w = 25;          // 取手内側空間の幅 (指 3 本ぐらい)
  inner_open_h = 30;          // 取手内側空間の高さ
- R_out = inner_open_w + handle_wall; // 取手外側半円の半径
- handle_extrude_h = inner_open_h + 10; // 取手の垂直厚み(内空間よりやや大)
- mug_center_z = mug_h/2;
  
- // 取手の平面(フラット面)の X 座標(本体外周に合わせる)
- flat_face_x = mug_outer_r; // フラット面をちょうど本体外周に合わせる
+ // 小さく重なりを持たせて本体に確実に接続する(面接触を避ける)
+ overlap = 1;
+ 
+ // 取手外側の半円半径(内側幅の半分 + 壁厚)
+ R_out = inner_open_w/2 + handle_wall; // = 12.5 + handle_wall
+ 
+ // 取手の平面(フラット面)の X 座標(本体外周に少し食い込ませる)
+ flat_face_x = mug_outer_r - overlap; // フラット面を本体外周より overlap mm 内側にする
  outer_center_x = flat_face_x + R_out; // 半円中心の X
  
- // 取手内空間の位置(Z と X)
- inner_void_left_x = flat_face_x; // 内側空間は本体外周に開口するようにする
- inner_void_z = mug_center_z - inner_open_h/2;
+ // 取手の垂直サイズ
+ handle_extrude_h = inner_open_h + 2*handle_wall; // 内空間より上下に壁分を確保
+ mug_center_z = mug_h/2;
  handle_z_bottom = mug_center_z - handle_extrude_h/2;
+ inner_void_z = mug_center_z - inner_open_h/2;
  
  // -------- モジュール --------
  module mug() {
      difference() {
          // 外側の円筒
          translate([0,0,0]) cylinder(h=mug_h, r=mug_outer_r);
          // 内側の空洞(底面の厚みを残す)
          translate([0,0,bottom_thickness]) cylinder(h=mug_h - bottom_thickness, r=mug_inner_r);
      }
  }
  
  module handle_piece() {
      // 取手外形(半円+フラット面)を押し出し、内側の指空間を差し引く
      difference() {
-         // 外形: 半円を矩形で切り取ってフラットにする
+         // 外形: 半円(外側が半円、内側がフラット)
          translate([0,0,handle_z_bottom])
              linear_extrude(height = handle_extrude_h, center = false, convexity = 10)
                  intersection() {
-                     // 半径 R_out の円(半分を残す)
+                     // 半径 R_out の円(右側半分を残す)
                      translate([outer_center_x, 0]) circle(r=R_out);
-                     // フラット面で切る矩形(左端を flat_face_x にする)
-                     // 少し余裕を持たせて縦方向は大きく取る
+                     // フラット面で切る矩形(左端を flat_face_x - 1 にして確実に切断)
                      translate([flat_face_x - 1, -(R_out + 10)])
                          square([ (outer_center_x + R_out) - (flat_face_x - 1) + 20, 2*(R_out + 10) ]);
                  }
  
-         // 内側の指空間を差し引く(外側に開口するよう左端を flat_face_x に合わせる)
-         translate([inner_void_left_x, -(R_out + 10), inner_void_z])
+         // 取手内側の空間(指を入れる部分)を差し引く
+         // 左端を flat_face_x に合わせ、幅 inner_open_w、高さ inner_open_h、中央位置は inner_void_z
+         translate([flat_face_x, -(R_out + 10), inner_void_z])
              cube([inner_open_w, 2*(R_out + 10), inner_open_h]);
      }
  }
  
  // -------- 組み立て --------
  union() {
      mug();
      handle_piece();
  }
SCAD (67 lines)
// OpenSCAD: マグカップ(修正版)
// 単位: mm

$fn = 120; // 円を滑らかに

// -------- パラメータ --------
mug_outer_r = 40;    // 外半径 (外径 80)
mug_inner_r = 35;    // 内半径 (内径 70)
mug_h = 90;          // 高さ
bottom_thickness = 6;

handle_wall = 8;            // 取手の厚み(外側と内側の差)
inner_open_w = 25;          // 取手内側空間の幅 (指 3 本ぐらい)
inner_open_h = 30;          // 取手内側空間の高さ

// 小さく重なりを持たせて本体に確実に接続する(面接触を避ける)
overlap = 1;

// 取手外側の半円半径(内側幅の半分 + 壁厚)
R_out = inner_open_w/2 + handle_wall; // = 12.5 + handle_wall

// 取手の平面(フラット面)の X 座標(本体外周に少し食い込ませる)
flat_face_x = mug_outer_r - overlap; // フラット面を本体外周より overlap mm 内側にする
outer_center_x = flat_face_x + R_out; // 半円中心の X

// 取手の垂直サイズ
handle_extrude_h = inner_open_h + 2*handle_wall; // 内空間より上下に壁分を確保
mug_center_z = mug_h/2;
handle_z_bottom = mug_center_z - handle_extrude_h/2;
inner_void_z = mug_center_z - inner_open_h/2;

// -------- モジュール --------
module mug() {
    difference() {
        // 外側の円筒
        translate([0,0,0]) cylinder(h=mug_h, r=mug_outer_r);
        // 内側の空洞(底面の厚みを残す)
        translate([0,0,bottom_thickness]) cylinder(h=mug_h - bottom_thickness, r=mug_inner_r);
    }
}

module handle_piece() {
    // 取手外形(半円+フラット面)を押し出し、内側の指空間を差し引く
    difference() {
        // 外形: 半円(外側が半円、内側がフラット)
        translate([0,0,handle_z_bottom])
            linear_extrude(height = handle_extrude_h, center = false, convexity = 10)
                intersection() {
                    // 半径 R_out の円(右側半分を残す)
                    translate([outer_center_x, 0]) circle(r=R_out);
                    // フラット面で切る矩形(左端を flat_face_x - 1 にして確実に切断)
                    translate([flat_face_x - 1, -(R_out + 10)])
                        square([ (outer_center_x + R_out) - (flat_face_x - 1) + 20, 2*(R_out + 10) ]);
                }

        // 取手内側の空間(指を入れる部分)を差し引く
        // 左端を flat_face_x に合わせ、幅 inner_open_w、高さ inner_open_h、中央位置は inner_void_z
        translate([flat_face_x, -(R_out + 10), inner_void_z])
            cube([inner_open_w, 2*(R_out + 10), inner_open_h]);
    }
}

// -------- 組み立て --------
union() {
    mug();
    handle_piece();
}