vibe-openscad

tier-1-mug / gpt-5.4-nano-2026-03-17

7 run / 累計 112.2s / 累計 $0.0266

openai gpt 5.4 nano 2026-03-17 bare

bare (provider default effort)

run detail →
render
bare render of tier-1-mug
loading STL…
success 6.5s · 168/897t · $0.0092
SCAD (97 lines)
// Mug with hollow interior and ring handle
$fn = 128;

outer_d = 80;
outer_r = outer_d/2;

body_h = 100;
wall_t = 4;

bottom_t = 6;

handle_r = 12;       // radius of the ring handle (extrudes outward from the cup)
handle_th = 10;     // handle ring thickness (in the Z direction after rotation)
handle_z  = 50;     // center height of the handle on the mug

inner_r = outer_r - wall_t;
inner_h = body_h - bottom_t; // hollow starts above the bottom thickness

module ring_handle(r=12, z=50, ring_th=10, hole_d=18){
    // A ring (torus-like) oriented so it protrudes radially from the cup wall.
    // We'll create it by rotating a 2D annulus profile around the X axis direction.
    // In this construction, the ring's center is at the mug's side (x = outer_r),
    // so we translate it outward by r.
    rotate([0,90,0]) // rotate so ring is in Y-Z plane and protrudes in +X
    translate([0,0,0]) 
    difference(){
        // Outer torus (generated by revolving a circle)
        torus( rOuter=r + ring_th, rInner=r + ring_th - 1, z=z);
    }
}

// Helper: create a torus by sweeping a circle along a radius
module torus(rOuter, rInner, z=0){
    // rOuter: major radius, rInner: minor radius (approx using outer circle - inner circle)
    // We'll implement as a difference of two spheres swept by linear_extrude? Instead use rotate_extrude annulus:
    // Use rotate_extrude with an annulus cross-section positioned at radius rOuter.
    // Minor radius approximated: use (rOuter - rInner) as thickness; if small, still fine.
    minor = max(0.1, (rOuter - rInner));
    // Cross-section: circle(s) of radius minor about origin, then translate out by rOuter
    // We'll build as an annulus torus: outer and inner subtraction.
    difference(){
        rotate_extrude(angle=360)
            translate([rOuter, 0, z])
                circle(r=minor);
        // inner cut to form ring hole (if ring thickness enough)
        if (minor - 3 > 0)
        rotate_extrude(angle=360)
            translate([rOuter, 0, z])
                circle(r=minor-3);
    }
}

module mug(){
    difference(){
        // Outer body
        cylinder(h=body_h, r=outer_r);

        // Hollow interior
        translate([0,0,bottom_t])
            cylinder(h=inner_h, r=inner_r);
    }
}

difference(){
    // Mug body
    mug();

    // No subtractive operations beyond the hollow are needed here;
    // keep handle addition outside this difference to remain simple.
}

// Add handle as a union with the mug
union(){
    mug();

    // Handle ring placement:
    // Place ring so it protrudes outward from the cup side.
    // We'll position the ring center at (x=outer_r + handle_r/2, y=0, z=handle_z),
    // with the ring's axis along the radial direction via rotation.
    //
    // Use a torus created from an annulus profile with major radius = handle_r
    // and minor radius controlled by handle_th.
    //
    // We'll center the ring at the cup's side by translating its major radius beyond outer_r.
    translate([outer_r + (handle_r/2), 0, handle_z])
        rotate([0,90,0])
            difference(){
                // Outer ring (torus-like)
                rotate_extrude(angle=360)
                    translate([handle_r, 0, 0])
                        circle(r=handle_th/2);
                // Inner hole
                rotate_extrude(angle=360)
                    translate([handle_r, 0, 0])
                        circle(r=handle_th/2 - 2.5);
            }
}
パラメータ (7)
スライダを動かすと openscad-wasm で再レンダリング

prompt

OpenSCAD で、外径 80mm、高さ 100mm、肉厚 4mm のマグカップを作ってください。
底面の厚みは 6mm とし、内側はくり抜いて飲み物を入れられる形状にしてください。
さらに、側面には外径方向に飛び出す半径 12mm の取手(リング状の取手)を付けてください。
取手はカップの中心高さあたりに付け、外周から十分にはみ出して指を通せる形にしてください。

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

variant: effort

low success
low
7.6s · 168/713t · $0.0004
SCAD (80 lines)
// Mug with handle ring
// Outer diameter 80mm, height 100mm
// Wall thickness 4mm, bottom thickness 6mm
// Handle: semicircular ring sticking outward, radius 12mm, centered at mid-height

$fn = 128;

outer_d = 80;
outer_r = outer_d/2;

height = 100;

wall = 4;
bottom_th = 6;

inner_r = outer_r - wall;
inner_h = height - bottom_th;

handle_r = 12;                 // handle outer radius
handle_th = 8;                // handle thickness (ring cross-section thickness)
handle_gap = 2;              // clearance between ring and cup wall

// --- Main mug body (outer minus inner cavity) ---
module mug() {
  difference() {
    // Outer shell
    union() {
      cylinder(h=height, r=outer_r);
      // (No separate bottom; handled by cavity depth)
    }

    // Inner cavity
    translate([0,0,bottom_th])
      cylinder(h=inner_h, r=inner_r);
  }
}

// --- Handle: ring-like shape (implemented as a thick circular torus section),
// centered at cup mid-height and sticking out to the outside.
// Orientation: ring plane vertical (Y-Z plane), so it's accessible as a loop.
module handle() {
  // Place the handle so its center is offset outward from cup outer surface.
  // Want the handle to stick out with radius 12mm.
  // Torus center offset from cup center = outer_r + (handle_r - handle_th/2 + handle_gap)
  cx = outer_r + (handle_r - handle_th/2 + handle_gap);

  // Ring is a torus cut to an approximate "C" shape by using a half-box.
  // Then we union it with a cylindrical ear to ensure solid attachment at the desired height.
  translate([cx, 0, height/2]) rotate([0,90,0])
  difference() {
    // Outer torus section
    // Major radius = handle_r - handle_th/2 (approx), minor radius = handle_th/2
    // But we use "torus" as a full solid by rotating a circle around Y axis.
    rotate_extrude(angle=360)
      translate([handle_r - handle_th/2, 0, 0])
        circle(r=handle_th/2);

    // Remove inner part to make it ring-like (thin hole)
    // Increase inner subtraction circle radius slightly for clean ring.
    rotate_extrude(angle=360)
      translate([handle_r - handle_th/2, 0, 0])
        circle(r=max(0.01,(handle_th/2 - 1.5)));

    // Optional: cut a window to make it more "C" like (keep enough for finger through)
    // Remove one side of the torus by cutting with a cube.
    translate([-handle_r*2, -handle_r*2, -handle_r*2])
      cube([handle_r*4, handle_r*2, handle_r*4], center=false);
  }
}

// --- Compose mug + handle ---
difference() {
  union() {
    mug();
    handle();
  }

  // Ensure handle doesn't intersect internal cavity aggressively is optional.
  // Not applying extra boolean cuts inside the cup cavity (keeps it simple).
}
medium (default) success
medium
6.5s · 168/897t · $0.0092
SCAD (97 lines)
// Mug with hollow interior and ring handle
$fn = 128;

outer_d = 80;
outer_r = outer_d/2;

body_h = 100;
wall_t = 4;

bottom_t = 6;

handle_r = 12;       // radius of the ring handle (extrudes outward from the cup)
handle_th = 10;     // handle ring thickness (in the Z direction after rotation)
handle_z  = 50;     // center height of the handle on the mug

inner_r = outer_r - wall_t;
inner_h = body_h - bottom_t; // hollow starts above the bottom thickness

module ring_handle(r=12, z=50, ring_th=10, hole_d=18){
    // A ring (torus-like) oriented so it protrudes radially from the cup wall.
    // We'll create it by rotating a 2D annulus profile around the X axis direction.
    // In this construction, the ring's center is at the mug's side (x = outer_r),
    // so we translate it outward by r.
    rotate([0,90,0]) // rotate so ring is in Y-Z plane and protrudes in +X
    translate([0,0,0]) 
    difference(){
        // Outer torus (generated by revolving a circle)
        torus( rOuter=r + ring_th, rInner=r + ring_th - 1, z=z);
    }
}

// Helper: create a torus by sweeping a circle along a radius
module torus(rOuter, rInner, z=0){
    // rOuter: major radius, rInner: minor radius (approx using outer circle - inner circle)
    // We'll implement as a difference of two spheres swept by linear_extrude? Instead use rotate_extrude annulus:
    // Use rotate_extrude with an annulus cross-section positioned at radius rOuter.
    // Minor radius approximated: use (rOuter - rInner) as thickness; if small, still fine.
    minor = max(0.1, (rOuter - rInner));
    // Cross-section: circle(s) of radius minor about origin, then translate out by rOuter
    // We'll build as an annulus torus: outer and inner subtraction.
    difference(){
        rotate_extrude(angle=360)
            translate([rOuter, 0, z])
                circle(r=minor);
        // inner cut to form ring hole (if ring thickness enough)
        if (minor - 3 > 0)
        rotate_extrude(angle=360)
            translate([rOuter, 0, z])
                circle(r=minor-3);
    }
}

module mug(){
    difference(){
        // Outer body
        cylinder(h=body_h, r=outer_r);

        // Hollow interior
        translate([0,0,bottom_t])
            cylinder(h=inner_h, r=inner_r);
    }
}

difference(){
    // Mug body
    mug();

    // No subtractive operations beyond the hollow are needed here;
    // keep handle addition outside this difference to remain simple.
}

// Add handle as a union with the mug
union(){
    mug();

    // Handle ring placement:
    // Place ring so it protrudes outward from the cup side.
    // We'll position the ring center at (x=outer_r + handle_r/2, y=0, z=handle_z),
    // with the ring's axis along the radial direction via rotation.
    //
    // Use a torus created from an annulus profile with major radius = handle_r
    // and minor radius controlled by handle_th.
    //
    // We'll center the ring at the cup's side by translating its major radius beyond outer_r.
    translate([outer_r + (handle_r/2), 0, handle_z])
        rotate([0,90,0])
            difference(){
                // Outer ring (torus-like)
                rotate_extrude(angle=360)
                    translate([handle_r, 0, 0])
                        circle(r=handle_th/2);
                // Inner hole
                rotate_extrude(angle=360)
                    translate([handle_r, 0, 0])
                        circle(r=handle_th/2 - 2.5);
            }
}
high render_error render
render_error
64.2s · 168/10689t · $0.0064
openscad stl render failed (exit 1): ERROR: Parser error: syntax error in file ../../../../../tmp/render-oOa0LT/input.scad, line 42
Can't parse file '/tmp/render-oOa0LT/input.scad'!

SCAD (63 lines)
// Mug parameters
outer_d = 80;     // 外径
height  = 100;   // 高さ
wall    = 4;     // 肉厚
bottom  = 6;     // 底面厚み

outer_r = outer_d / 2;
inner_r = outer_r - wall;

// Handle parameters
handle_major_r = 12; // 半径 12mm(リング状取手の大きさ)
handle_tube_r  = wall; // 取手の断面半径(肉厚に合わせる)
handle_center_z = height / 2;

handle_depth = 20; // 取手の側面方向の厚み(見た目調整)

$fn = 100;

module torus(R=12, r=4) {
    rotate_extrude(convexity=10, $fn=200)
        translate([R, 0, 0])
            circle(r=r, $fn=100);
}

module mug() {
    difference() {
        // 外形
        cylinder(h=height, r=outer_r);

        // 内側をくり抜き(底厚 bottom から上)
        translate([0, 0, bottom])
            cylinder(h=height - bottom, r=inner_r);
    }
}

module handle() {
    // 取手(Y軸方向にリング状)
    axis_x = outer_r - (handle_major_r - handle_tube_r);

    handle_torus =
        translate([axis_x, 0, handle_center_z])
        rotate([90, 0, 0])
            torus(handle_major_r, handle_tube_r);

    // 側面に付くようにクリップ(内側には入れすぎない/局所に留める)
    x_clip_min = inner_r;
    x_clip_max = outer_r + handle_major_r + handle_tube_r + 10;
    clip_dx = x_clip_max - x_clip_min;

    clip_cube = translate([x_clip_min, -handle_depth/2, 0])
        cube([clip_dx, handle_depth, height], center=false);

    intersection() {
        handle_torus;
        clip_cube;
    }
}

// Final model
union() {
    mug();
    handle();
}
maxnot run
xhighnot run

iteration: iter-png

i1 success
iter 1
17.3s · 1725/602t · $0.0005
diff vs bare: +51/-80
- // Mug with hollow interior and ring handle
+ // Mug with hollow interior and radial ring handle
  $fn = 128;
  
- outer_d = 80;
- outer_r = outer_d/2;
+ // Given dimensions
+ outer_d  = 80;      // outside diameter
+ body_h   = 100;     // height
+ wall_t   = 4;       // side wall thickness
+ bottom_t = 6;       // bottom thickness
  
- body_h = 100;
- wall_t = 4;
- 
- bottom_t = 6;
- 
- handle_r = 12;       // radius of the ring handle (extrudes outward from the cup)
- handle_th = 10;     // handle ring thickness (in the Z direction after rotation)
- handle_z  = 50;     // center height of the handle on the mug
- 
+ outer_r = outer_d/2;
  inner_r = outer_r - wall_t;
- inner_h = body_h - bottom_t; // hollow starts above the bottom thickness
  
- module ring_handle(r=12, z=50, ring_th=10, hole_d=18){
-     // A ring (torus-like) oriented so it protrudes radially from the cup wall.
-     // We'll create it by rotating a 2D annulus profile around the X axis direction.
-     // In this construction, the ring's center is at the mug's side (x = outer_r),
-     // so we translate it outward by r.
-     rotate([0,90,0]) // rotate so ring is in Y-Z plane and protrudes in +X
-     translate([0,0,0]) 
-     difference(){
-         // Outer torus (generated by revolving a circle)
-         torus( rOuter=r + ring_th, rInner=r + ring_th - 1, z=z);
-     }
- }
+ // Handle requirements
+ handle_radius_extrude = 12; // ring's radius that protrudes outward (radially)
+ handle_th = 10;              // ring thickness (height in Z)
+ handle_z  = body_h/2;       // center height of handle
  
- // Helper: create a torus by sweeping a circle along a radius
- module torus(rOuter, rInner, z=0){
-     // rOuter: major radius, rInner: minor radius (approx using outer circle - inner circle)
-     // We'll implement as a difference of two spheres swept by linear_extrude? Instead use rotate_extrude annulus:
-     // Use rotate_extrude with an annulus cross-section positioned at radius rOuter.
-     // Minor radius approximated: use (rOuter - rInner) as thickness; if small, still fine.
-     minor = max(0.1, (rOuter - rInner));
-     // Cross-section: circle(s) of radius minor about origin, then translate out by rOuter
-     // We'll build as an annulus torus: outer and inner subtraction.
-     difference(){
-         rotate_extrude(angle=360)
-             translate([rOuter, 0, z])
-                 circle(r=minor);
-         // inner cut to form ring hole (if ring thickness enough)
-         if (minor - 3 > 0)
-         rotate_extrude(angle=360)
-             translate([rOuter, 0, z])
-                 circle(r=minor-3);
-     }
- }
- 
- module mug(){
-     difference(){
-         // Outer body
+ // -------------------- Geometry --------------------
+ module mug() {
+     // Outer shell
+     difference() {
          cylinder(h=body_h, r=outer_r);
  
-         // Hollow interior
+         // Hollow interior (keep bottom thickness)
          translate([0,0,bottom_t])
-             cylinder(h=inner_h, r=inner_r);
+             cylinder(h=body_h - bottom_t, r=inner_r);
      }
  }
  
- difference(){
-     // Mug body
-     mug();
+ module ring_handle(rad=12, zc=50, ring_th=10, hole=6) {
+     /*
+       Radial ring oriented so it protrudes in +X direction from the cup wall.
+       Implemented as a torus whose major radius is 'rad' and whose minor
+       radius is ring_th/2, then cut out an inner hole to make it a ring
+       (so a finger can pass).
+       
+       Position: center of ring cross-section is located at the cup's outer
+       surface plane (x=outer_r), and the ring extends further outward
+       to x=outer_r + rad*2 (i.e., "外径方向に飛び出す").
+     */
+     minor_outer = ring_th/2;
  
-     // No subtractive operations beyond the hollow are needed here;
-     // keep handle addition outside this difference to remain simple.
+     // Safety for subtraction
+     minor_inner = max(0.1, minor_outer - hole);
+ 
+     // Torus constructed from rotate_extrude of an annulus cross-section.
+     // Major radius uses translate([rad,0,z]) before rotate_extrude.
+     rotate([0,90,0])  // make torus axis align such that it protrudes radially in +X
+     translate([outer_r, 0, zc])
+     difference() {
+         // Outer torus
+         rotate_extrude(angle=360)
+             translate([rad, 0, 0])
+                 circle(r=minor_outer);
+ 
+         // Inner cutout (hole)
+         rotate_extrude(angle=360)
+             translate([rad, 0, 0])
+                 circle(r=minor_inner);
+     }
  }
  
- // Add handle as a union with the mug
- union(){
+ union() {
      mug();
- 
-     // Handle ring placement:
-     // Place ring so it protrudes outward from the cup side.
-     // We'll position the ring center at (x=outer_r + handle_r/2, y=0, z=handle_z),
-     // with the ring's axis along the radial direction via rotation.
-     //
-     // Use a torus created from an annulus profile with major radius = handle_r
-     // and minor radius controlled by handle_th.
-     //
-     // We'll center the ring at the cup's side by translating its major radius beyond outer_r.
-     translate([outer_r + (handle_r/2), 0, handle_z])
-         rotate([0,90,0])
-             difference(){
-                 // Outer ring (torus-like)
-                 rotate_extrude(angle=360)
-                     translate([handle_r, 0, 0])
-                         circle(r=handle_th/2);
-                 // Inner hole
-                 rotate_extrude(angle=360)
-                     translate([handle_r, 0, 0])
-                         circle(r=handle_th/2 - 2.5);
-             }
+     // Place handle at cup center height, centered on the outer wall plane,
+     // protruding outward with major radius=12.
+     ring_handle(rad=handle_radius_extrude, zc=handle_z, ring_th=handle_th, hole=6);
  }
SCAD (68 lines)
// Mug with hollow interior and radial ring handle
$fn = 128;

// Given dimensions
outer_d  = 80;      // outside diameter
body_h   = 100;     // height
wall_t   = 4;       // side wall thickness
bottom_t = 6;       // bottom thickness

outer_r = outer_d/2;
inner_r = outer_r - wall_t;

// Handle requirements
handle_radius_extrude = 12; // ring's radius that protrudes outward (radially)
handle_th = 10;              // ring thickness (height in Z)
handle_z  = body_h/2;       // center height of handle

// -------------------- Geometry --------------------
module mug() {
    // Outer shell
    difference() {
        cylinder(h=body_h, r=outer_r);

        // Hollow interior (keep bottom thickness)
        translate([0,0,bottom_t])
            cylinder(h=body_h - bottom_t, r=inner_r);
    }
}

module ring_handle(rad=12, zc=50, ring_th=10, hole=6) {
    /*
      Radial ring oriented so it protrudes in +X direction from the cup wall.
      Implemented as a torus whose major radius is 'rad' and whose minor
      radius is ring_th/2, then cut out an inner hole to make it a ring
      (so a finger can pass).
      
      Position: center of ring cross-section is located at the cup's outer
      surface plane (x=outer_r), and the ring extends further outward
      to x=outer_r + rad*2 (i.e., "外径方向に飛び出す").
    */
    minor_outer = ring_th/2;

    // Safety for subtraction
    minor_inner = max(0.1, minor_outer - hole);

    // Torus constructed from rotate_extrude of an annulus cross-section.
    // Major radius uses translate([rad,0,z]) before rotate_extrude.
    rotate([0,90,0])  // make torus axis align such that it protrudes radially in +X
    translate([outer_r, 0, zc])
    difference() {
        // Outer torus
        rotate_extrude(angle=360)
            translate([rad, 0, 0])
                circle(r=minor_outer);

        // Inner cutout (hole)
        rotate_extrude(angle=360)
            translate([rad, 0, 0])
                circle(r=minor_inner);
    }
}

union() {
    mug();
    // Place handle at cup center height, centered on the outer wall plane,
    // protruding outward with major radius=12.
    ring_handle(rad=handle_radius_extrude, zc=handle_z, ring_th=handle_th, hole=6);
}
i2 success
iter 2
5.0s · 1430/555t · $0.0004
diff vs i1: +29/-35
  // Mug with hollow interior and radial ring handle
  $fn = 128;
  
  // Given dimensions
  outer_d  = 80;      // outside diameter
  body_h   = 100;     // height
  wall_t   = 4;       // side wall thickness
  bottom_t = 6;       // bottom thickness
  
  outer_r = outer_d/2;
  inner_r = outer_r - wall_t;
  
- // Handle requirements
- handle_radius_extrude = 12; // ring's radius that protrudes outward (radially)
- handle_th = 10;              // ring thickness (height in Z)
- handle_z  = body_h/2;       // center height of handle
+ // Handle requirements (ring protruding outward in radial direction)
+ handle_rad_out = 12; // "半径 12mm の外径方向に飛び出す" => protruding major radius
+ handle_th = 10;      // handle thickness (height in Z)
+ handle_z  = body_h/2; // center height of handle
  
+ // Ensure ring thickness doesn't invert
+ hole_d = 6; // finger hole diameter
+ minor_outer = max(0.1, handle_th/2);
+ minor_inner = max(0.1, minor_outer - hole_d/2);
+ 
  // -------------------- Geometry --------------------
  module mug() {
-     // Outer shell
      difference() {
          cylinder(h=body_h, r=outer_r);
  
          // Hollow interior (keep bottom thickness)
          translate([0,0,bottom_t])
              cylinder(h=body_h - bottom_t, r=inner_r);
      }
  }
  
+ // Radial ring handle (torus) oriented so it protrudes in +X direction.
+ // The torus major radius is 'handle_rad_out', and its center is placed
+ // at the cup outer surface plane (x=outer_r), so it protrudes outward.
  module ring_handle(rad=12, zc=50, ring_th=10, hole=6) {
-     /*
-       Radial ring oriented so it protrudes in +X direction from the cup wall.
-       Implemented as a torus whose major radius is 'rad' and whose minor
-       radius is ring_th/2, then cut out an inner hole to make it a ring
-       (so a finger can pass).
-       
-       Position: center of ring cross-section is located at the cup's outer
-       surface plane (x=outer_r), and the ring extends further outward
-       to x=outer_r + rad*2 (i.e., "外径方向に飛び出す").
-     */
-     minor_outer = ring_th/2;
+     minor_outer_local = max(0.1, ring_th/2);
+     minor_inner_local = max(0.1, minor_outer_local - hole/2);
  
-     // Safety for subtraction
-     minor_inner = max(0.1, minor_outer - hole);
+     rotate([0,90,0]) {
+         translate([outer_r, 0, zc])
+             difference() {
+                 // Outer torus
+                 rotate_extrude(angle=360)
+                     translate([rad, 0, 0])
+                         circle(r=minor_outer_local);
  
-     // Torus constructed from rotate_extrude of an annulus cross-section.
-     // Major radius uses translate([rad,0,z]) before rotate_extrude.
-     rotate([0,90,0])  // make torus axis align such that it protrudes radially in +X
-     translate([outer_r, 0, zc])
-     difference() {
-         // Outer torus
-         rotate_extrude(angle=360)
-             translate([rad, 0, 0])
-                 circle(r=minor_outer);
- 
-         // Inner cutout (hole)
-         rotate_extrude(angle=360)
-             translate([rad, 0, 0])
-                 circle(r=minor_inner);
+                 // Inner cutout to form a ring (finger hole)
+                 rotate_extrude(angle=360)
+                     translate([rad, 0, 0])
+                         circle(r=minor_inner_local);
+             }
      }
  }
  
  union() {
      mug();
-     // Place handle at cup center height, centered on the outer wall plane,
-     // protruding outward with major radius=12.
-     ring_handle(rad=handle_radius_extrude, zc=handle_z, ring_th=handle_th, hole=6);
+     // Place handle at cup center height
+     // (protrudes outward from outer wall; ring is centered radially at x=outer_r)
+     ring_handle(rad=handle_rad_out, zc=handle_z, ring_th=handle_th, hole=hole_d);
  }
SCAD (62 lines)
// Mug with hollow interior and radial ring handle
$fn = 128;

// Given dimensions
outer_d  = 80;      // outside diameter
body_h   = 100;     // height
wall_t   = 4;       // side wall thickness
bottom_t = 6;       // bottom thickness

outer_r = outer_d/2;
inner_r = outer_r - wall_t;

// Handle requirements (ring protruding outward in radial direction)
handle_rad_out = 12; // "半径 12mm の外径方向に飛び出す" => protruding major radius
handle_th = 10;      // handle thickness (height in Z)
handle_z  = body_h/2; // center height of handle

// Ensure ring thickness doesn't invert
hole_d = 6; // finger hole diameter
minor_outer = max(0.1, handle_th/2);
minor_inner = max(0.1, minor_outer - hole_d/2);

// -------------------- Geometry --------------------
module mug() {
    difference() {
        cylinder(h=body_h, r=outer_r);

        // Hollow interior (keep bottom thickness)
        translate([0,0,bottom_t])
            cylinder(h=body_h - bottom_t, r=inner_r);
    }
}

// Radial ring handle (torus) oriented so it protrudes in +X direction.
// The torus major radius is 'handle_rad_out', and its center is placed
// at the cup outer surface plane (x=outer_r), so it protrudes outward.
module ring_handle(rad=12, zc=50, ring_th=10, hole=6) {
    minor_outer_local = max(0.1, ring_th/2);
    minor_inner_local = max(0.1, minor_outer_local - hole/2);

    rotate([0,90,0]) {
        translate([outer_r, 0, zc])
            difference() {
                // Outer torus
                rotate_extrude(angle=360)
                    translate([rad, 0, 0])
                        circle(r=minor_outer_local);

                // Inner cutout to form a ring (finger hole)
                rotate_extrude(angle=360)
                    translate([rad, 0, 0])
                        circle(r=minor_inner_local);
            }
    }
}

union() {
    mug();
    // Place handle at cup center height
    // (protrudes outward from outer wall; ring is centered radially at x=outer_r)
    ring_handle(rad=handle_rad_out, zc=handle_z, ring_th=handle_th, hole=hole_d);
}
i3 success
iter 3
5.0s · 1383/493t · $0.0004
diff vs i2: +29/-32
- // Mug with hollow interior and radial ring handle
+ // Mug with hollow interior and outward ring handle (radial)
+ 
  $fn = 128;
  
- // Given dimensions
- outer_d  = 80;      // outside diameter
- body_h   = 100;     // height
- wall_t   = 4;       // side wall thickness
- bottom_t = 6;       // bottom thickness
+ // Dimensions from prompt
+ outer_d  = 80;     // outer diameter
+ body_h   = 100;    // height
+ wall_t   = 4;      // side thickness
+ bottom_t = 6;     // bottom thickness
  
  outer_r = outer_d/2;
  inner_r = outer_r - wall_t;
  
- // Handle requirements (ring protruding outward in radial direction)
- handle_rad_out = 12; // "半径 12mm の外径方向に飛び出す" => protruding major radius
- handle_th = 10;      // handle thickness (height in Z)
- handle_z  = body_h/2; // center height of handle
+ // Handle (ring) parameters
+ handle_major_r = 12;   // "半径 12mm" => ring major radius
+ handle_zc = body_h/2;  // attach at cup center height
+ handle_th = 10;        // ring cross-section thickness along Z
+ finger_hole_d = 6;    // finger hole diameter
  
- // Ensure ring thickness doesn't invert
- hole_d = 6; // finger hole diameter
- minor_outer = max(0.1, handle_th/2);
- minor_inner = max(0.1, minor_outer - hole_d/2);
- 
- // -------------------- Geometry --------------------
  module mug() {
      difference() {
+         // outer shell
          cylinder(h=body_h, r=outer_r);
  
-         // Hollow interior (keep bottom thickness)
+         // hollow interior leaving bottom thickness
          translate([0,0,bottom_t])
              cylinder(h=body_h - bottom_t, r=inner_r);
      }
  }
  
- // Radial ring handle (torus) oriented so it protrudes in +X direction.
- // The torus major radius is 'handle_rad_out', and its center is placed
- // at the cup outer surface plane (x=outer_r), so it protrudes outward.
- module ring_handle(rad=12, zc=50, ring_th=10, hole=6) {
-     minor_outer_local = max(0.1, ring_th/2);
-     minor_inner_local = max(0.1, minor_outer_local - hole/2);
+ // Ring handle created as a torus, oriented to protrude radially outward (+X)
+ module ring_handle(major_r, zc, ring_th, hole_d) {
+     // Torus minor radius is set by ring_th/2.
+     // The finger hole is modeled by subtracting a smaller torus (same major radius).
+     minor_outer = max(0.5, ring_th/2);
+     minor_inner = max(0.5, minor_outer - hole_d/2);
  
      rotate([0,90,0]) {
+         // Place torus so that its center lies at the cup outer surface (x = outer_r)
+         // => it protrudes outward from the cup.
          translate([outer_r, 0, zc])
              difference() {
-                 // Outer torus
+                 // outer torus
                  rotate_extrude(angle=360)
-                     translate([rad, 0, 0])
-                         circle(r=minor_outer_local);
+                     translate([major_r, 0, 0])
+                         circle(r=minor_outer);
  
-                 // Inner cutout to form a ring (finger hole)
+                 // inner cutout torus to form finger hole
                  rotate_extrude(angle=360)
-                     translate([rad, 0, 0])
-                         circle(r=minor_inner_local);
+                     translate([major_r, 0, 0])
+                         circle(r=minor_inner);
              }
      }
  }
  
  union() {
      mug();
-     // Place handle at cup center height
-     // (protrudes outward from outer wall; ring is centered radially at x=outer_r)
-     ring_handle(rad=handle_rad_out, zc=handle_z, ring_th=handle_th, hole=hole_d);
+     ring_handle(handle_major_r, handle_zc, handle_th, finger_hole_d);
  }
SCAD (59 lines)
// Mug with hollow interior and outward ring handle (radial)

$fn = 128;

// Dimensions from prompt
outer_d  = 80;     // outer diameter
body_h   = 100;    // height
wall_t   = 4;      // side thickness
bottom_t = 6;     // bottom thickness

outer_r = outer_d/2;
inner_r = outer_r - wall_t;

// Handle (ring) parameters
handle_major_r = 12;   // "半径 12mm" => ring major radius
handle_zc = body_h/2;  // attach at cup center height
handle_th = 10;        // ring cross-section thickness along Z
finger_hole_d = 6;    // finger hole diameter

module mug() {
    difference() {
        // outer shell
        cylinder(h=body_h, r=outer_r);

        // hollow interior leaving bottom thickness
        translate([0,0,bottom_t])
            cylinder(h=body_h - bottom_t, r=inner_r);
    }
}

// Ring handle created as a torus, oriented to protrude radially outward (+X)
module ring_handle(major_r, zc, ring_th, hole_d) {
    // Torus minor radius is set by ring_th/2.
    // The finger hole is modeled by subtracting a smaller torus (same major radius).
    minor_outer = max(0.5, ring_th/2);
    minor_inner = max(0.5, minor_outer - hole_d/2);

    rotate([0,90,0]) {
        // Place torus so that its center lies at the cup outer surface (x = outer_r)
        // => it protrudes outward from the cup.
        translate([outer_r, 0, zc])
            difference() {
                // outer torus
                rotate_extrude(angle=360)
                    translate([major_r, 0, 0])
                        circle(r=minor_outer);

                // inner cutout torus to form finger hole
                rotate_extrude(angle=360)
                    translate([major_r, 0, 0])
                        circle(r=minor_inner);
            }
    }
}

union() {
    mug();
    ring_handle(handle_major_r, handle_zc, handle_th, finger_hole_d);
}