vibe-openscad

tier-2-offset-handle-mug / gemini-3.1-flash-lite-preview

6 run / 累計 21.7s / 累計 $0.0020

gemini flash-lite 3.1 preview bare

bare (provider default effort)

run detail →
render
bare render of tier-2-offset-handle-mug
loading STL…
success 3.3s · 232/582t · $0.0003
SCAD (56 lines)
$fn = 100;

// マグ本体のパラメータ
outer_d = 80;
inner_d = 70;
height = 90;
bottom_thick = 6;

// 取手のパラメータ
handle_inner_h = 30;
handle_inner_w = 25;
handle_thick = 10;

// マグ本体の作成
module mug_body() {
    difference() {
        cylinder(d = outer_d, h = height);
        translate([0, 0, bottom_thick])
            cylinder(d = inner_d, h = height - bottom_thick + 0.1);
    }
}

// 取手の作成
module handle() {
    handle_outer_w = handle_inner_w + 2 * handle_thick;
    handle_total_h = handle_inner_h + 2 * handle_thick;
    
    translate([outer_d / 2 - 1, 0, height / 2]) {
        rotate([0, 90, 0]) {
            difference() {
                // 外側の形状 (D字の背にあたる半円と長方形)
                union() {
                    translate([0, 0, -handle_total_h / 2])
                        cylinder(d = handle_outer_w, h = handle_total_h);
                    translate([0, -handle_outer_w / 2, -handle_total_h / 2])
                        cube([handle_outer_w / 2, handle_outer_w, handle_total_h]);
                }
                // 内側の空間 (D字の穴)
                union() {
                    translate([0, 0, -handle_inner_h / 2])
                        cylinder(d = handle_inner_w, h = handle_inner_h);
                    translate([0, -handle_inner_w / 2, -handle_inner_h / 2])
                        cube([handle_inner_w / 2, handle_inner_w, handle_inner_h]);
                }
                // マグ本体との接続面をフラットにするための切り取り
                translate([-handle_outer_w, -handle_outer_w, -handle_total_h])
                    cube([handle_outer_w, handle_outer_w * 2, handle_total_h * 2]);
            }
        }
    }
}

union() {
    mug_body();
    handle();
}
パラメータ (7)
スライダを動かすと openscad-wasm で再レンダリング

prompt

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

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

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

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

variant: thinking

off success
off
3.2s · 232/496t · $0.0002
SCAD (52 lines)
// マグカップのパラメータ
outer_d = 80;
inner_d = 70;
height = 90;
wall = 5;
bottom = 6;

handle_h = 30;
handle_w = 25;
handle_thickness = 10;

// マグ本体の作成
module mug_body() {
    difference() {
        // 外形
        cylinder(d = outer_d, h = height, $fn = 100);
        // 内側のくり抜き
        translate([0, 0, bottom])
            cylinder(d = inner_d, h = height, $fn = 100);
    }
}

// 取手の作成
module handle() {
    translate([outer_d / 2 - 1, 0, height / 2]) {
        rotate([0, 90, 0]) {
            difference() {
                // 取手の外形 (D字型)
                union() {
                    cylinder(d = handle_h + handle_thickness * 2, h = handle_thickness, $fn = 50);
                    translate([0, -(handle_h + handle_thickness * 2) / 2, 0])
                        cube([ (handle_h + handle_thickness * 2) / 2, handle_h + handle_thickness * 2, handle_thickness]);
                }
                // 取手の内側の空洞
                translate([0, 0, -1])
                    linear_extrude(handle_thickness + 2)
                        hull() {
                            translate([0, handle_h / 2]) circle(d = handle_thickness);
                            translate([0, -handle_h / 2]) circle(d = handle_thickness);
                            translate([handle_w, handle_h / 2]) circle(d = handle_thickness);
                            translate([handle_w, -handle_h / 2]) circle(d = handle_thickness);
                        }
            }
        }
    }
}

// 本体と取手の結合
union() {
    mug_body();
    handle();
}
adaptivenot run
dynamic (default) success
dynamic
3.3s · 232/582t · $0.0003
SCAD (56 lines)
$fn = 100;

// マグ本体のパラメータ
outer_d = 80;
inner_d = 70;
height = 90;
bottom_thick = 6;

// 取手のパラメータ
handle_inner_h = 30;
handle_inner_w = 25;
handle_thick = 10;

// マグ本体の作成
module mug_body() {
    difference() {
        cylinder(d = outer_d, h = height);
        translate([0, 0, bottom_thick])
            cylinder(d = inner_d, h = height - bottom_thick + 0.1);
    }
}

// 取手の作成
module handle() {
    handle_outer_w = handle_inner_w + 2 * handle_thick;
    handle_total_h = handle_inner_h + 2 * handle_thick;
    
    translate([outer_d / 2 - 1, 0, height / 2]) {
        rotate([0, 90, 0]) {
            difference() {
                // 外側の形状 (D字の背にあたる半円と長方形)
                union() {
                    translate([0, 0, -handle_total_h / 2])
                        cylinder(d = handle_outer_w, h = handle_total_h);
                    translate([0, -handle_outer_w / 2, -handle_total_h / 2])
                        cube([handle_outer_w / 2, handle_outer_w, handle_total_h]);
                }
                // 内側の空間 (D字の穴)
                union() {
                    translate([0, 0, -handle_inner_h / 2])
                        cylinder(d = handle_inner_w, h = handle_inner_h);
                    translate([0, -handle_inner_w / 2, -handle_inner_h / 2])
                        cube([handle_inner_w / 2, handle_inner_w, handle_inner_h]);
                }
                // マグ本体との接続面をフラットにするための切り取り
                translate([-handle_outer_w, -handle_outer_w, -handle_total_h])
                    cube([handle_outer_w, handle_outer_w * 2, handle_total_h * 2]);
            }
        }
    }
}

union() {
    mug_body();
    handle();
}

iteration: iter-png

i1 success
iter 1
4.1s · 1946/525t · $0.0004
diff vs bare: +16/-19
  $fn = 100;
  
  // マグ本体のパラメータ
  outer_d = 80;
  inner_d = 70;
  height = 90;
  bottom_thick = 6;
  
  // 取手のパラメータ
  handle_inner_h = 30;
  handle_inner_w = 25;
  handle_thick = 10;
  
  // マグ本体の作成
  module mug_body() {
      difference() {
          cylinder(d = outer_d, h = height);
          translate([0, 0, bottom_thick])
              cylinder(d = inner_d, h = height - bottom_thick + 0.1);
      }
  }
  
  // 取手の作成
  module handle() {
-     handle_outer_w = handle_inner_w + 2 * handle_thick;
-     handle_total_h = handle_inner_h + 2 * handle_thick;
+     // D字形状をMinkowski等を使わず、円柱と直方体の組み合わせで滑らかに構築
+     // 取手の高さは inner_h + 上下厚み、幅は inner_w + 外側厚み
+     h_outer_d = handle_inner_h + 2 * handle_thick;
      
      translate([outer_d / 2 - 1, 0, height / 2]) {
          rotate([0, 90, 0]) {
-             difference() {
-                 // 外側の形状 (D字の背にあたる半円と長方形)
-                 union() {
-                     translate([0, 0, -handle_total_h / 2])
-                         cylinder(d = handle_outer_w, h = handle_total_h);
-                     translate([0, -handle_outer_w / 2, -handle_total_h / 2])
-                         cube([handle_outer_w / 2, handle_outer_w, handle_total_h]);
+             linear_extrude(height = handle_thick) {
+                 difference() {
+                     // 外形: 半円と長方形
+                     union() {
+                         translate([0, 0]) circle(d = h_outer_d);
+                         translate([-h_outer_d / 2, -h_outer_d / 2]) square([h_outer_d / 2, h_outer_d]);
+                     }
+                     // 内穴: 半円と長方形
+                     union() {
+                         translate([0, 0]) circle(d = handle_inner_h);
+                         translate([-handle_inner_h / 2 - 2, -handle_inner_h / 2]) square([handle_inner_h / 2 + 2, handle_inner_h]);
+                     }
                  }
-                 // 内側の空間 (D字の穴)
-                 union() {
-                     translate([0, 0, -handle_inner_h / 2])
-                         cylinder(d = handle_inner_w, h = handle_inner_h);
-                     translate([0, -handle_inner_w / 2, -handle_inner_h / 2])
-                         cube([handle_inner_w / 2, handle_inner_w, handle_inner_h]);
-                 }
-                 // マグ本体との接続面をフラットにするための切り取り
-                 translate([-handle_outer_w, -handle_outer_w, -handle_total_h])
-                     cube([handle_outer_w, handle_outer_w * 2, handle_total_h * 2]);
              }
          }
      }
  }
  
+ // 本体と取手の接合部を確実にするため、わずかにめり込ませてマニフォールドを維持
  union() {
      mug_body();
      handle();
  }
SCAD (53 lines)
$fn = 100;

// マグ本体のパラメータ
outer_d = 80;
inner_d = 70;
height = 90;
bottom_thick = 6;

// 取手のパラメータ
handle_inner_h = 30;
handle_inner_w = 25;
handle_thick = 10;

// マグ本体の作成
module mug_body() {
    difference() {
        cylinder(d = outer_d, h = height);
        translate([0, 0, bottom_thick])
            cylinder(d = inner_d, h = height - bottom_thick + 0.1);
    }
}

// 取手の作成
module handle() {
    // D字形状をMinkowski等を使わず、円柱と直方体の組み合わせで滑らかに構築
    // 取手の高さは inner_h + 上下厚み、幅は inner_w + 外側厚み
    h_outer_d = handle_inner_h + 2 * handle_thick;
    
    translate([outer_d / 2 - 1, 0, height / 2]) {
        rotate([0, 90, 0]) {
            linear_extrude(height = handle_thick) {
                difference() {
                    // 外形: 半円と長方形
                    union() {
                        translate([0, 0]) circle(d = h_outer_d);
                        translate([-h_outer_d / 2, -h_outer_d / 2]) square([h_outer_d / 2, h_outer_d]);
                    }
                    // 内穴: 半円と長方形
                    union() {
                        translate([0, 0]) circle(d = handle_inner_h);
                        translate([-handle_inner_h / 2 - 2, -handle_inner_h / 2]) square([handle_inner_h / 2 + 2, handle_inner_h]);
                    }
                }
            }
        }
    }
}

// 本体と取手の接合部を確実にするため、わずかにめり込ませてマニフォールドを維持
union() {
    mug_body();
    handle();
}
i2 success
iter 2
4.3s · 1889/571t · $0.0004
diff vs i1: +22/-19
  $fn = 100;
  
  // マグ本体のパラメータ
  outer_d = 80;
  inner_d = 70;
  height = 90;
  bottom_thick = 6;
  
  // 取手のパラメータ
- handle_inner_h = 30;
- handle_inner_w = 25;
- handle_thick = 10;
+ handle_inner_h = 30; // 縦の空間
+ handle_inner_w = 25; // 横の張り出し空間
+ handle_thick = 10;   // 取手自体の肉厚
+ handle_width = 15;   // 取手の奥行き(押し出し厚み)
  
- // マグ本体の作成
  module mug_body() {
      difference() {
          cylinder(d = outer_d, h = height);
          translate([0, 0, bottom_thick])
              cylinder(d = inner_d, h = height - bottom_thick + 0.1);
      }
  }
  
- // 取手の作成
  module handle() {
-     // D字形状をMinkowski等を使わず、円柱と直方体の組み合わせで滑らかに構築
-     // 取手の高さは inner_h + 上下厚み、幅は inner_w + 外側厚み
-     h_outer_d = handle_inner_h + 2 * handle_thick;
-     
-     translate([outer_d / 2 - 1, 0, height / 2]) {
-         rotate([0, 90, 0]) {
-             linear_extrude(height = handle_thick) {
+     // 取手の中心をマグの高さ中央に合わせる
+     // D字形状をプロファイルとして作成
+     translate([outer_d / 2 - 2, 0, height / 2]) {
+         rotate([90, 0, 90]) {
+             linear_extrude(height = handle_width) {
                  difference() {
-                     // 外形: 半円と長方形
+                     // 外形: 半円(幅は空間+肉厚*2)と直線部
                      union() {
-                         translate([0, 0]) circle(d = h_outer_d);
-                         translate([-h_outer_d / 2, -h_outer_d / 2]) square([h_outer_d / 2, h_outer_d]);
+                         translate([0, handle_inner_h/2]) circle(d = handle_inner_h + handle_thick * 2);
+                         translate([-(handle_inner_h/2 + handle_thick), -handle_inner_h/2]) 
+                             square([handle_inner_h/2 + handle_thick, handle_inner_h + handle_thick * 2]);
                      }
-                     // 内穴: 半円と長方形
+                     // 内穴: 半円
                      union() {
-                         translate([0, 0]) circle(d = handle_inner_h);
-                         translate([-handle_inner_h / 2 - 2, -handle_inner_h / 2]) square([handle_inner_h / 2 + 2, handle_inner_h]);
+                         translate([0, handle_inner_h/2]) circle(d = handle_inner_h);
+                         translate([-handle_inner_w, -handle_inner_h/2]) 
+                             square([handle_inner_w, handle_inner_h]);
                      }
                  }
              }
          }
      }
  }
  
- // 本体と取手の接合部を確実にするため、わずかにめり込ませてマニフォールドを維持
  union() {
      mug_body();
+     // 取手が本体と重なるように少しだけめり込ませてunion
+     intersection() {
+         handle();
+         translate([outer_d/2 - 5, -50, 0]) cube([50, 100, 200]);
+     }
      handle();
  }
SCAD (56 lines)
$fn = 100;

// マグ本体のパラメータ
outer_d = 80;
inner_d = 70;
height = 90;
bottom_thick = 6;

// 取手のパラメータ
handle_inner_h = 30; // 縦の空間
handle_inner_w = 25; // 横の張り出し空間
handle_thick = 10;   // 取手自体の肉厚
handle_width = 15;   // 取手の奥行き(押し出し厚み)

module mug_body() {
    difference() {
        cylinder(d = outer_d, h = height);
        translate([0, 0, bottom_thick])
            cylinder(d = inner_d, h = height - bottom_thick + 0.1);
    }
}

module handle() {
    // 取手の中心をマグの高さ中央に合わせる
    // D字形状をプロファイルとして作成
    translate([outer_d / 2 - 2, 0, height / 2]) {
        rotate([90, 0, 90]) {
            linear_extrude(height = handle_width) {
                difference() {
                    // 外形: 半円(幅は空間+肉厚*2)と直線部
                    union() {
                        translate([0, handle_inner_h/2]) circle(d = handle_inner_h + handle_thick * 2);
                        translate([-(handle_inner_h/2 + handle_thick), -handle_inner_h/2]) 
                            square([handle_inner_h/2 + handle_thick, handle_inner_h + handle_thick * 2]);
                    }
                    // 内穴: 半円
                    union() {
                        translate([0, handle_inner_h/2]) circle(d = handle_inner_h);
                        translate([-handle_inner_w, -handle_inner_h/2]) 
                            square([handle_inner_w, handle_inner_h]);
                    }
                }
            }
        }
    }
}

union() {
    mug_body();
    // 取手が本体と重なるように少しだけめり込ませてunion
    intersection() {
        handle();
        translate([outer_d/2 - 5, -50, 0]) cube([50, 100, 200]);
    }
    handle();
}
i3 success
iter 3
3.6s · 1935/527t · $0.0004
diff vs i2: +16/-20
  $fn = 100;
  
  // マグ本体のパラメータ
  outer_d = 80;
  inner_d = 70;
  height = 90;
  bottom_thick = 6;
  
  // 取手のパラメータ
- handle_inner_h = 30; // 縦の空間
- handle_inner_w = 25; // 横の張り出し空間
- handle_thick = 10;   // 取手自体の肉厚
- handle_width = 15;   // 取手の奥行き(押し出し厚み)
+ handle_h_space = 30; // 取手の空間の高さ
+ handle_w_space = 25; // 取手の空間の幅
+ handle_thick = 10;   // 取手の肉厚
+ handle_depth = 15;   // 取手の奥行き(本体からの突き出し方向)
  
  module mug_body() {
      difference() {
          cylinder(d = outer_d, h = height);
          translate([0, 0, bottom_thick])
              cylinder(d = inner_d, h = height - bottom_thick + 0.1);
      }
  }
  
  module handle() {
-     // 取手の中心をマグの高さ中央に合わせる
-     // D字形状をプロファイルとして作成
+     // マグの側面に接する平らな部分を作るため、D字型を構築
+     // 本体側は円弧に沿うように少し食い込ませる
      translate([outer_d / 2 - 2, 0, height / 2]) {
          rotate([90, 0, 90]) {
-             linear_extrude(height = handle_width) {
+             linear_extrude(height = handle_depth) {
                  difference() {
-                     // 外形: 半円(幅は空間+肉厚*2)と直線部
+                     // 取手の外形
                      union() {
-                         translate([0, handle_inner_h/2]) circle(d = handle_inner_h + handle_thick * 2);
-                         translate([-(handle_inner_h/2 + handle_thick), -handle_inner_h/2]) 
-                             square([handle_inner_h/2 + handle_thick, handle_inner_h + handle_thick * 2]);
+                         translate([0, handle_h_space / 2]) circle(d = handle_h_space + handle_thick * 2);
+                         translate([-(handle_h_space / 2 + handle_thick), -handle_h_space / 2]) 
+                             square([handle_h_space / 2 + handle_thick, handle_h_space + handle_thick * 2]);
                      }
-                     // 内穴: 半円
+                     // 取手の内側の空洞(指を通す部分)
                      union() {
-                         translate([0, handle_inner_h/2]) circle(d = handle_inner_h);
-                         translate([-handle_inner_w, -handle_inner_h/2]) 
-                             square([handle_inner_w, handle_inner_h]);
+                         translate([0, handle_h_space / 2]) circle(d = handle_h_space);
+                         translate([-handle_w_space, -handle_h_space / 2]) 
+                             square([handle_w_space, handle_h_space]);
                      }
                  }
              }
          }
      }
  }
  
+ // 本体と取手を結合
  union() {
      mug_body();
-     // 取手が本体と重なるように少しだけめり込ませてunion
-     intersection() {
-         handle();
-         translate([outer_d/2 - 5, -50, 0]) cube([50, 100, 200]);
-     }
      handle();
  }
SCAD (52 lines)
$fn = 100;

// マグ本体のパラメータ
outer_d = 80;
inner_d = 70;
height = 90;
bottom_thick = 6;

// 取手のパラメータ
handle_h_space = 30; // 取手の空間の高さ
handle_w_space = 25; // 取手の空間の幅
handle_thick = 10;   // 取手の肉厚
handle_depth = 15;   // 取手の奥行き(本体からの突き出し方向)

module mug_body() {
    difference() {
        cylinder(d = outer_d, h = height);
        translate([0, 0, bottom_thick])
            cylinder(d = inner_d, h = height - bottom_thick + 0.1);
    }
}

module handle() {
    // マグの側面に接する平らな部分を作るため、D字型を構築
    // 本体側は円弧に沿うように少し食い込ませる
    translate([outer_d / 2 - 2, 0, height / 2]) {
        rotate([90, 0, 90]) {
            linear_extrude(height = handle_depth) {
                difference() {
                    // 取手の外形
                    union() {
                        translate([0, handle_h_space / 2]) circle(d = handle_h_space + handle_thick * 2);
                        translate([-(handle_h_space / 2 + handle_thick), -handle_h_space / 2]) 
                            square([handle_h_space / 2 + handle_thick, handle_h_space + handle_thick * 2]);
                    }
                    // 取手の内側の空洞(指を通す部分)
                    union() {
                        translate([0, handle_h_space / 2]) circle(d = handle_h_space);
                        translate([-handle_w_space, -handle_h_space / 2]) 
                            square([handle_w_space, handle_h_space]);
                    }
                }
            }
        }
    }
}

// 本体と取手を結合
union() {
    mug_body();
    handle();
}