vibe-openscad

tier-2-l-bracket / claude-sonnet-4-6

8 run / 累計 148.9s / 累計 $0.1621

claude sonnet 4.6 bare

bare (provider default effort)

run detail →
render
bare render of tier-2-l-bracket
loading STL…
success 20.6s · 361/1242t · $0.0197
SCAD (72 lines)
// L-Bracket (L字金具)
// 内側コーナーが原点、水平面は+Y方向、垂直面は+Z方向

// パラメータ
width       = 50;   // 幅 (X方向)
flange_len  = 40;   // 各フランジの長さ (水平:Y方向, 垂直:Z方向)
thickness   = 3;    // 板厚
hole_d      = 4.5;  // 貫通穴径 (M4)
cs_d        = 8;    // 皿座面径
cs_depth    = 2;    // 皿座面深さ
hole_inset  = 10;   // 縁からの距離
hole_offset = width / 2 - hole_inset; // 中心線からの左右オフセット = 15mm

module countersunk_hole(depth, from_outside=true) {
    // 貫通穴
    cylinder(d=hole_d, h=depth + 1, center=false, $fn=32);
    // 皿座面 (外側から)
    if (from_outside) {
        translate([0, 0, depth - cs_depth])
            cylinder(d1=hole_d, d2=cs_d, h=cs_depth + 0.01, $fn=32);
        // 皿座面の上をフラットにカット(面より上には出ない)
    }
}

module l_bracket() {
    difference() {
        union() {
            // 水平面フランジ: X方向 width, Y方向 flange_len, Z方向 thickness
            // Z: -thickness ~ 0, Y: 0 ~ flange_len
            translate([0, 0, -thickness])
                cube([width, flange_len, thickness]);

            // 垂直面フランジ: X方向 width, Y方向 thickness, Z方向 flange_len
            // Y: -thickness ~ 0, Z: 0 ~ flange_len
            translate([0, -thickness, 0])
                cube([width, thickness, flange_len]);
        }

        // --- 水平面の皿穴 (2個) ---
        // 皿座面は外側(Z下面, Z=-thickness) → 穴はZ=-thickness から上向きに開ける
        // 縁から10mm内側: Y方向の縁はY=flange_len → Y = flange_len - hole_inset = 30
        // 左右対称: X = width/2 ± hole_offset = 25 ± 15 → X=10, X=40
        for (x = [width/2 - hole_offset, width/2 + hole_offset]) {
            translate([x, flange_len - hole_inset, -thickness]) {
                // 貫通穴
                cylinder(d=hole_d, h=thickness + 1, $fn=32);
                // 皿座面は外側(下面 Z=-thickness)→ translate Z=0 で下向きに掘る
                // 皿: 下面から cs_depth 掘り上げる → Z=0 から Z=cs_depth まで
                // 皿形状: 下面(Z=0)で径 cs_d, 上(Z=cs_depth)で径 hole_d
                cylinder(d1=cs_d, d2=hole_d, h=cs_depth + 0.01, $fn=32);
            }
        }

        // --- 垂直面の皿穴 (2個) ---
        // 皿座面は外側(Y下面, Y=-thickness) → 穴はY=-thickness から +Y方向に開ける
        // 縁から10mm内側: Z方向の縁はZ=flange_len → Z = flange_len - hole_inset = 30
        // 左右対称: X=10, X=40
        for (x = [width/2 - hole_offset, width/2 + hole_offset]) {
            translate([x, -thickness, flange_len - hole_inset]) {
                // Y方向に穴を開ける → rotate around X
                rotate([-90, 0, 0]) {
                    // 貫通穴
                    cylinder(d=hole_d, h=thickness + 1, $fn=32);
                    // 皿座面は外側(Y=-thickness面)→ Z=0 (外面) から内側へ cs_depth
                    cylinder(d1=cs_d, d2=hole_d, h=cs_depth + 0.01, $fn=32);
                }
            }
        }
    }
}

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

prompt

OpenSCAD で、L 字に折れた金具(L-bracket)を作ってください。

形状:
- 水平面と垂直面の 2 つのフランジが直角に繋がっている
- 水平面は 50mm × 40mm(幅 × 奥行き)
- 垂直面は 50mm × 40mm(幅 × 高さ)
- 板厚はどちらも 3mm
- 内側コーナーが原点になるように配置(水平面は +Y 方向、垂直面は +Z 方向に伸びる)

皿穴(countersunk holes):
- 各面に 2 個ずつ、合計 4 個
- M4 ねじ用(貫通穴 Φ4.5mm + 皿座面 Φ8mm × 深さ 2mm)
- 各面の中心線上で、面の縁から 10mm 内側、左右対称に 2 個並べる
- 皿座面は外側(ボルト頭が当たる側)に向ける

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

variant: effort

low success
low
20.7s · 361/1143t · $0.0182
SCAD (81 lines)
// L-Bracket

// Parameters
w = 50;   // width (X)
hf = 40;  // horizontal flange depth (Y)
vf = 40;  // vertical flange height (Z)
t = 3;    // thickness

// Hole parameters
hole_d = 4.5;
cs_d = 8;
cs_depth = 2;
hole_offset_edge = 10;  // from edge along flange direction
hole_offset_side = w/2 - (w/4); // left/right: symmetric, at w/4 from center each side
// holes at X = -w/4 and X = +w/4 ... actually "left-right symmetric, 2 holes"
// Let's place at X = ±(w/2 - 10) ... no, "center line, left-right symmetric 2 holes"
// "各面の中心線上で、面の縁から10mm内側、左右対称に2個"
// I'll interpret: along width, symmetric about center, at X = ±(w/4) 
// Actually let's use X = ±(w/2 - 10) for nice placement
hx1 = -(w/2 - 10);
hx2 =  (w/2 - 10);

module countersunk_hole_vertical(depth_total) {
    // hole along Z, countersink at top (Z = depth_total, i.e., outside face going down)
    // Used for horizontal flange: outside is -Z face
    union() {
        cylinder(h = depth_total, d = hole_d, $fn=32);
        translate([0, 0, -cs_depth])
            cylinder(h = cs_depth + 0.01, d1 = cs_d, d2 = hole_d, $fn=32);
    }
}

module countersunk_hole_horizontal(depth_total) {
    // hole along Y, countersink at -Y face (outside of vertical flange)
    union() {
        cylinder(h = depth_total, d = hole_d, $fn=32);
        cylinder(h = cs_depth, d1 = cs_d, d2 = hole_d, $fn=32);
    }
}

difference() {
    union() {
        // Horizontal flange: extends in +Y, lies in XY plane, thickness in Z (0 to -t)
        translate([-w/2, 0, -t])
            cube([w, hf, t]);
        
        // Vertical flange: extends in +Z, lies in XZ plane, thickness in Y (0 to -t)  
        // Wait: inner corner at origin, vertical goes +Z, horizontal goes +Y
        // Vertical flange: X from -w/2 to w/2, Z from 0 to vf, Y from -t to 0
        translate([-w/2, -t, 0])
            cube([w, t, vf]);
    }
    
    // Holes in horizontal flange (along Z)
    // Outside face is at Z = -t (bottom), countersink opens downward
    // Holes at Y = hf - 10 (10mm from far edge), X = hx1, hx2
    for (hx = [hx1, hx2]) {
        translate([hx, hf - hole_offset_edge, 0]) {
            // drill from Z=0 down to Z=-t
            translate([0, 0, -t])
                union() {
                    cylinder(h = t, d = hole_d, $fn=32);
                    // countersink at bottom (outside = -t face)
                    cylinder(h = cs_depth, d1 = cs_d, d2 = hole_d, $fn=32);
                }
        }
    }
    
    // Holes in vertical flange (along Y)
    // Outside face is at Y = -t, countersink opens outward (-Y direction)
    // Holes at Z = vf - 10, X = hx1, hx2
    for (hx = [hx1, hx2]) {
        translate([hx, -t, vf - hole_offset_edge]) {
            rotate([-90, 0, 0]) {
                cylinder(h = t, d = hole_d, $fn=32);
                // countersink at start (Y = -t face, outside)
                cylinder(h = cs_depth, d1 = cs_d, d2 = hole_d, $fn=32);
            }
        }
    }
}
mediumnot run
high (default) success
high
16.2s · 361/1041t · $0.0167
SCAD (75 lines)
// L-Bracket
// Inner corner at origin
// Horizontal flange extends in +Y direction
// Vertical flange extends in +Z direction

// Parameters
width        = 50;   // X direction
h_depth      = 40;   // Horizontal flange depth (Y direction)
v_height     = 40;   // Vertical flange height (Z direction)
thickness    = 3;    // Plate thickness

// Countersunk hole parameters
through_d    = 4.5;  // Through hole diameter (M4)
cs_d         = 8.0;  // Countersink diameter
cs_depth     = 2.0;  // Countersink depth
edge_offset  = 10;   // Distance from edge to hole center
lr_offset    = 15;   // Distance from center-line to each hole (left/right)

module countersunk_hole(depth, from_top=true) {
    // Cylindrical through hole + countersink cone
    // Hole axis along Z; countersink at +Z face when from_top=true
    union() {
        // Through hole
        cylinder(d=through_d, h=depth, center=false, $fn=32);
        if (from_top) {
            // Countersink at top face (z = depth)
            translate([0, 0, depth - cs_depth])
                cylinder(d1=through_d, d2=cs_d, h=cs_depth, $fn=32);
        } else {
            // Countersink at bottom face (z = 0)
            cylinder(d1=cs_d, d2=through_d, h=cs_depth, $fn=32);
        }
    }
}

difference() {
    union() {
        // Horizontal flange: lies on XY plane, extends in +Y
        // Z from -thickness to 0  →  but inner corner is at origin,
        // so horizontal plate occupies Z = [-thickness, 0], Y = [0, h_depth]
        translate([0, 0, -thickness])
            cube([width, h_depth, thickness]);

        // Vertical flange: stands in XZ plane, extends in +Z
        // Y from -thickness to 0, Z = [0, v_height]
        translate([0, -thickness, 0])
            cube([width, thickness, v_height]);
    }

    // --- Countersunk holes in HORIZONTAL flange ---
    // Bolt heads on top (outside = +Z face at z=0), so countersink at top.
    // Holes located at Y = h_depth - edge_offset (10 mm from far edge)
    // X positions: width/2 ± lr_offset
    for (xpos = [width/2 - lr_offset, width/2 + lr_offset]) {
        translate([xpos, h_depth - edge_offset, -thickness])
            // from_top=false → countersink at bottom (z=0 of the shifted solid = z=-thickness global)
            // Actually we want countersink on the OUTER (top) face which is z=0 global.
            // Hole goes from z=-thickness upward, countersink at the top (z=0 global).
            countersunk_hole(thickness, from_top=true);
    }

    // --- Countersunk holes in VERTICAL flange ---
    // Bolt heads on outer face (outside = -Y face at y=-thickness).
    // Holes located at Z = v_height - edge_offset (10 mm from top edge)
    // X positions: width/2 ± lr_offset
    // We'll rotate the hole so its axis is along Y.
    for (xpos = [width/2 - lr_offset, width/2 + lr_offset]) {
        translate([xpos, -thickness, v_height - edge_offset])
            rotate([-90, 0, 0])
                // Hole travels in +Y from y=-thickness to y=0
                // Countersink at top of hole cylinder = outer face (y=-thickness side)
                // from_top=false puts countersink at z=0 of local system = y=-thickness global
                countersunk_hole(thickness, from_top=false);
    }
}
maxnot run
xhighnot run

variant: thinking

off success
off
16.2s · 361/1041t · $0.0167
SCAD (75 lines)
// L-Bracket
// Inner corner at origin
// Horizontal flange extends in +Y direction
// Vertical flange extends in +Z direction

// Parameters
width        = 50;   // X direction
h_depth      = 40;   // Horizontal flange depth (Y direction)
v_height     = 40;   // Vertical flange height (Z direction)
thickness    = 3;    // Plate thickness

// Countersunk hole parameters
through_d    = 4.5;  // Through hole diameter (M4)
cs_d         = 8.0;  // Countersink diameter
cs_depth     = 2.0;  // Countersink depth
edge_offset  = 10;   // Distance from edge to hole center
lr_offset    = 15;   // Distance from center-line to each hole (left/right)

module countersunk_hole(depth, from_top=true) {
    // Cylindrical through hole + countersink cone
    // Hole axis along Z; countersink at +Z face when from_top=true
    union() {
        // Through hole
        cylinder(d=through_d, h=depth, center=false, $fn=32);
        if (from_top) {
            // Countersink at top face (z = depth)
            translate([0, 0, depth - cs_depth])
                cylinder(d1=through_d, d2=cs_d, h=cs_depth, $fn=32);
        } else {
            // Countersink at bottom face (z = 0)
            cylinder(d1=cs_d, d2=through_d, h=cs_depth, $fn=32);
        }
    }
}

difference() {
    union() {
        // Horizontal flange: lies on XY plane, extends in +Y
        // Z from -thickness to 0  →  but inner corner is at origin,
        // so horizontal plate occupies Z = [-thickness, 0], Y = [0, h_depth]
        translate([0, 0, -thickness])
            cube([width, h_depth, thickness]);

        // Vertical flange: stands in XZ plane, extends in +Z
        // Y from -thickness to 0, Z = [0, v_height]
        translate([0, -thickness, 0])
            cube([width, thickness, v_height]);
    }

    // --- Countersunk holes in HORIZONTAL flange ---
    // Bolt heads on top (outside = +Z face at z=0), so countersink at top.
    // Holes located at Y = h_depth - edge_offset (10 mm from far edge)
    // X positions: width/2 ± lr_offset
    for (xpos = [width/2 - lr_offset, width/2 + lr_offset]) {
        translate([xpos, h_depth - edge_offset, -thickness])
            // from_top=false → countersink at bottom (z=0 of the shifted solid = z=-thickness global)
            // Actually we want countersink on the OUTER (top) face which is z=0 global.
            // Hole goes from z=-thickness upward, countersink at the top (z=0 global).
            countersunk_hole(thickness, from_top=true);
    }

    // --- Countersunk holes in VERTICAL flange ---
    // Bolt heads on outer face (outside = -Y face at y=-thickness).
    // Holes located at Z = v_height - edge_offset (10 mm from top edge)
    // X positions: width/2 ± lr_offset
    // We'll rotate the hole so its axis is along Y.
    for (xpos = [width/2 - lr_offset, width/2 + lr_offset]) {
        translate([xpos, -thickness, v_height - edge_offset])
            rotate([-90, 0, 0])
                // Hole travels in +Y from y=-thickness to y=0
                // Countersink at top of hole cylinder = outer face (y=-thickness side)
                // from_top=false puts countersink at z=0 of local system = y=-thickness global
                countersunk_hole(thickness, from_top=false);
    }
}
adaptive (default) success
adaptive
20.7s · 361/1143t · $0.0182
SCAD (81 lines)
// L-Bracket

// Parameters
w = 50;   // width (X)
hf = 40;  // horizontal flange depth (Y)
vf = 40;  // vertical flange height (Z)
t = 3;    // thickness

// Hole parameters
hole_d = 4.5;
cs_d = 8;
cs_depth = 2;
hole_offset_edge = 10;  // from edge along flange direction
hole_offset_side = w/2 - (w/4); // left/right: symmetric, at w/4 from center each side
// holes at X = -w/4 and X = +w/4 ... actually "left-right symmetric, 2 holes"
// Let's place at X = ±(w/2 - 10) ... no, "center line, left-right symmetric 2 holes"
// "各面の中心線上で、面の縁から10mm内側、左右対称に2個"
// I'll interpret: along width, symmetric about center, at X = ±(w/4) 
// Actually let's use X = ±(w/2 - 10) for nice placement
hx1 = -(w/2 - 10);
hx2 =  (w/2 - 10);

module countersunk_hole_vertical(depth_total) {
    // hole along Z, countersink at top (Z = depth_total, i.e., outside face going down)
    // Used for horizontal flange: outside is -Z face
    union() {
        cylinder(h = depth_total, d = hole_d, $fn=32);
        translate([0, 0, -cs_depth])
            cylinder(h = cs_depth + 0.01, d1 = cs_d, d2 = hole_d, $fn=32);
    }
}

module countersunk_hole_horizontal(depth_total) {
    // hole along Y, countersink at -Y face (outside of vertical flange)
    union() {
        cylinder(h = depth_total, d = hole_d, $fn=32);
        cylinder(h = cs_depth, d1 = cs_d, d2 = hole_d, $fn=32);
    }
}

difference() {
    union() {
        // Horizontal flange: extends in +Y, lies in XY plane, thickness in Z (0 to -t)
        translate([-w/2, 0, -t])
            cube([w, hf, t]);
        
        // Vertical flange: extends in +Z, lies in XZ plane, thickness in Y (0 to -t)  
        // Wait: inner corner at origin, vertical goes +Z, horizontal goes +Y
        // Vertical flange: X from -w/2 to w/2, Z from 0 to vf, Y from -t to 0
        translate([-w/2, -t, 0])
            cube([w, t, vf]);
    }
    
    // Holes in horizontal flange (along Z)
    // Outside face is at Z = -t (bottom), countersink opens downward
    // Holes at Y = hf - 10 (10mm from far edge), X = hx1, hx2
    for (hx = [hx1, hx2]) {
        translate([hx, hf - hole_offset_edge, 0]) {
            // drill from Z=0 down to Z=-t
            translate([0, 0, -t])
                union() {
                    cylinder(h = t, d = hole_d, $fn=32);
                    // countersink at bottom (outside = -t face)
                    cylinder(h = cs_depth, d1 = cs_d, d2 = hole_d, $fn=32);
                }
        }
    }
    
    // Holes in vertical flange (along Y)
    // Outside face is at Y = -t, countersink opens outward (-Y direction)
    // Holes at Z = vf - 10, X = hx1, hx2
    for (hx = [hx1, hx2]) {
        translate([hx, -t, vf - hole_offset_edge]) {
            rotate([-90, 0, 0]) {
                cylinder(h = t, d = hole_d, $fn=32);
                // countersink at start (Y = -t face, outside)
                cylinder(h = cs_depth, d1 = cs_d, d2 = hole_d, $fn=32);
            }
        }
    }
}
dynamicnot run

iteration: iter-png

i1 success
iter 1
18.8s · 2359/1112t · $0.0238
diff vs bare: +37/-50
  // L-Bracket (L字金具)
  // 内側コーナーが原点、水平面は+Y方向、垂直面は+Z方向
  
- // パラメータ
- width       = 50;   // 幅 (X方向)
- flange_len  = 40;   // 各フランジの長さ (水平:Y方向, 垂直:Z方向)
- thickness   = 3;    // 板厚
- hole_d      = 4.5;  // 貫通穴径 (M4)
- cs_d        = 8;    // 皿座面径
- cs_depth    = 2;    // 皿座面深さ
- hole_inset  = 10;   // 縁からの距離
- hole_offset = width / 2 - hole_inset; // 中心線からの左右オフセット = 15mm
+ width      = 50;   // 幅 (X方向)
+ fl_horiz   = 40;   // 水平フランジ奥行き (Y方向)
+ fl_vert    = 40;   // 垂直フランジ高さ (Z方向)
+ t          = 3;    // 板厚
+ hole_d     = 4.5;  // 貫通穴径
+ cs_d       = 8;    // 皿座面径
+ cs_dep     = 2;    // 皿座面深さ
+ inset      = 10;   // 縁からの距離
+ eps        = 0.01; // 干渉回避用微小値
  
- module countersunk_hole(depth, from_outside=true) {
-     // 貫通穴
-     cylinder(d=hole_d, h=depth + 1, center=false, $fn=32);
-     // 皿座面 (外側から)
-     if (from_outside) {
-         translate([0, 0, depth - cs_depth])
-             cylinder(d1=hole_d, d2=cs_d, h=cs_depth + 0.01, $fn=32);
-         // 皿座面の上をフラットにカット(面より上には出ない)
-     }
- }
+ // 穴のX位置(左右対称、中心線から±15mm)
+ hole_xs = [width/2 - (width/2 - inset), width/2 + (width/2 - inset)];
+ // = [10, 40]
  
  module l_bracket() {
      difference() {
          union() {
-             // 水平面フランジ: X方向 width, Y方向 flange_len, Z方向 thickness
-             // Z: -thickness ~ 0, Y: 0 ~ flange_len
-             translate([0, 0, -thickness])
-                 cube([width, flange_len, thickness]);
+             // 水平面: X[0~50], Y[0~40], Z[-3~0]
+             translate([0, 0, -t])
+                 cube([width, fl_horiz, t]);
  
-             // 垂直面フランジ: X方向 width, Y方向 thickness, Z方向 flange_len
-             // Y: -thickness ~ 0, Z: 0 ~ flange_len
-             translate([0, -thickness, 0])
-                 cube([width, thickness, flange_len]);
+             // 垂直面: X[0~50], Y[-3~0], Z[0~40]
+             translate([0, -t, 0])
+                 cube([width, t, fl_vert]);
          }
  
-         // --- 水平面の皿穴 (2個) ---
-         // 皿座面は外側(Z下面, Z=-thickness) → 穴はZ=-thickness から上向きに開ける
-         // 縁から10mm内側: Y方向の縁はY=flange_len → Y = flange_len - hole_inset = 30
-         // 左右対称: X = width/2 ± hole_offset = 25 ± 15 → X=10, X=40
-         for (x = [width/2 - hole_offset, width/2 + hole_offset]) {
-             translate([x, flange_len - hole_inset, -thickness]) {
-                 // 貫通穴
-                 cylinder(d=hole_d, h=thickness + 1, $fn=32);
-                 // 皿座面は外側(下面 Z=-thickness)→ translate Z=0 で下向きに掘る
-                 // 皿: 下面から cs_depth 掘り上げる → Z=0 から Z=cs_depth まで
-                 // 皿形状: 下面(Z=0)で径 cs_d, 上(Z=cs_depth)で径 hole_d
-                 cylinder(d1=cs_d, d2=hole_d, h=cs_depth + 0.01, $fn=32);
+         // --- 水平面の皿穴 ---
+         // 外側 = 下面(Z = -t)、穴は下から上(+Z)へ開ける
+         // Y方向: 縁(Y=fl_horiz)から inset 内側 → Y = fl_horiz - inset = 30
+         for (x = hole_xs) {
+             translate([x, fl_horiz - inset, -t - eps]) {
+                 // 貫通穴(下から上へ)
+                 cylinder(d=hole_d, h=t + 2*eps, $fn=48);
+                 // 皿座面: 外側(下面)から内側へ cs_dep 掘る
+                 // 下端(Z=0相当)が大径(cs_d)、上が小径(hole_d)
+                 cylinder(d1=cs_d, d2=hole_d, h=cs_dep + eps, $fn=48);
              }
          }
  
-         // --- 垂直面の皿穴 (2個) ---
-         // 皿座面は外側(Y下面, Y=-thickness) → 穴はY=-thickness から +Y方向に開ける
-         // 縁から10mm内側: Z方向の縁はZ=flange_len → Z = flange_len - hole_inset = 30
-         // 左右対称: X=10, X=40
-         for (x = [width/2 - hole_offset, width/2 + hole_offset]) {
-             translate([x, -thickness, flange_len - hole_inset]) {
-                 // Y方向に穴を開ける → rotate around X
+         // --- 垂直面の皿穴 ---
+         // 外側 = 前面(Y = -t)、穴は前(-Y)から後(+Y)へ開ける
+         // Z方向: 縁(Z=fl_vert)から inset 内側 → Z = fl_vert - inset = 30
+         for (x = hole_xs) {
+             translate([x, -t - eps, fl_vert - inset]) {
                  rotate([-90, 0, 0]) {
-                     // 貫通穴
-                     cylinder(d=hole_d, h=thickness + 1, $fn=32);
-                     // 皿座面は外側(Y=-thickness面)→ Z=0 (外面) から内側へ cs_depth
-                     cylinder(d1=cs_d, d2=hole_d, h=cs_depth + 0.01, $fn=32);
+                     // 貫通穴(前から後へ)
+                     cylinder(d=hole_d, h=t + 2*eps, $fn=48);
+                     // 皿座面: 外側(前面)から内側へ cs_dep 掘る
+                     cylinder(d1=cs_d, d2=hole_d, h=cs_dep + eps, $fn=48);
                  }
              }
          }
      }
  }
  
  l_bracket();
SCAD (59 lines)
// L-Bracket (L字金具)
// 内側コーナーが原点、水平面は+Y方向、垂直面は+Z方向

width      = 50;   // 幅 (X方向)
fl_horiz   = 40;   // 水平フランジ奥行き (Y方向)
fl_vert    = 40;   // 垂直フランジ高さ (Z方向)
t          = 3;    // 板厚
hole_d     = 4.5;  // 貫通穴径
cs_d       = 8;    // 皿座面径
cs_dep     = 2;    // 皿座面深さ
inset      = 10;   // 縁からの距離
eps        = 0.01; // 干渉回避用微小値

// 穴のX位置(左右対称、中心線から±15mm)
hole_xs = [width/2 - (width/2 - inset), width/2 + (width/2 - inset)];
// = [10, 40]

module l_bracket() {
    difference() {
        union() {
            // 水平面: X[0~50], Y[0~40], Z[-3~0]
            translate([0, 0, -t])
                cube([width, fl_horiz, t]);

            // 垂直面: X[0~50], Y[-3~0], Z[0~40]
            translate([0, -t, 0])
                cube([width, t, fl_vert]);
        }

        // --- 水平面の皿穴 ---
        // 外側 = 下面(Z = -t)、穴は下から上(+Z)へ開ける
        // Y方向: 縁(Y=fl_horiz)から inset 内側 → Y = fl_horiz - inset = 30
        for (x = hole_xs) {
            translate([x, fl_horiz - inset, -t - eps]) {
                // 貫通穴(下から上へ)
                cylinder(d=hole_d, h=t + 2*eps, $fn=48);
                // 皿座面: 外側(下面)から内側へ cs_dep 掘る
                // 下端(Z=0相当)が大径(cs_d)、上が小径(hole_d)
                cylinder(d1=cs_d, d2=hole_d, h=cs_dep + eps, $fn=48);
            }
        }

        // --- 垂直面の皿穴 ---
        // 外側 = 前面(Y = -t)、穴は前(-Y)から後(+Y)へ開ける
        // Z方向: 縁(Z=fl_vert)から inset 内側 → Z = fl_vert - inset = 30
        for (x = hole_xs) {
            translate([x, -t - eps, fl_vert - inset]) {
                rotate([-90, 0, 0]) {
                    // 貫通穴(前から後へ)
                    cylinder(d=hole_d, h=t + 2*eps, $fn=48);
                    // 皿座面: 外側(前面)から内側へ cs_dep 掘る
                    cylinder(d1=cs_d, d2=hole_d, h=cs_dep + eps, $fn=48);
                }
            }
        }
    }
}

l_bracket();
i2 success
iter 2
15.0s · 2049/1247t · $0.0249
diff vs i1: +28/-26
  // L-Bracket (L字金具)
  // 内側コーナーが原点、水平面は+Y方向、垂直面は+Z方向
  
- width      = 50;   // 幅 (X方向)
- fl_horiz   = 40;   // 水平フランジ奥行き (Y方向)
- fl_vert    = 40;   // 垂直フランジ高さ (Z方向)
- t          = 3;    // 板厚
- hole_d     = 4.5;  // 貫通穴径
- cs_d       = 8;    // 皿座面径
- cs_dep     = 2;    // 皿座面深さ
- inset      = 10;   // 縁からの距離
- eps        = 0.01; // 干渉回避用微小値
+ width    = 50;   // 幅 (X方向)
+ fl_horiz = 40;   // 水平フランジ奥行き (Y方向)
+ fl_vert  = 40;   // 垂直フランジ高さ (Z方向)
+ t        = 3;    // 板厚
+ hole_d   = 4.5;  // 貫通穴径
+ cs_d     = 8;    // 皿座面径
+ cs_dep   = 2;    // 皿座面深さ
+ inset    = 10;   // 縁からの距離
+ eps      = 0.1;  // 干渉回避用微小値
  
- // 穴のX位置(左右対称、中心線から±15mm)
- hole_xs = [width/2 - (width/2 - inset), width/2 + (width/2 - inset)];
- // = [10, 40]
+ // 穴のX位置: 幅50mm、縁から10mm内側 → X=10 と X=40
+ hole_xs = [inset, width - inset]; // [10, 40]
  
  module l_bracket() {
      difference() {
          union() {
              // 水平面: X[0~50], Y[0~40], Z[-3~0]
              translate([0, 0, -t])
                  cube([width, fl_horiz, t]);
  
              // 垂直面: X[0~50], Y[-3~0], Z[0~40]
              translate([0, -t, 0])
                  cube([width, t, fl_vert]);
          }
  
          // --- 水平面の皿穴 ---
-         // 外側 = 下面(Z = -t)、穴は下から上(+Z)へ開ける
-         // Y方向: 縁(Y=fl_horiz)から inset 内側 → Y = fl_horiz - inset = 30
+         // 外側 = 下面(Z = -t)
+         // 皿座面は下(外側)が大径、上(内側)が小径
+         // Y位置: 奥の縁(Y=40)から inset=10 内側 → Y=30
          for (x = hole_xs) {
              translate([x, fl_horiz - inset, -t - eps]) {
-                 // 貫通穴(下から上へ)
-                 cylinder(d=hole_d, h=t + 2*eps, $fn=48);
-                 // 皿座面: 外側(下面)から内側へ cs_dep 掘る
-                 // 下端(Z=0相当)が大径(cs_d)、上が小径(hole_d)
-                 cylinder(d1=cs_d, d2=hole_d, h=cs_dep + eps, $fn=48);
+                 // 皿座面(外側=下から): d1=cs_d(下/外), d2=hole_d(上/内)
+                 cylinder(d1=cs_d, d2=hole_d, h=cs_dep + eps, $fn=64);
+                 // 残りの貫通穴
+                 cylinder(d=hole_d, h=t + 2*eps, $fn=64);
              }
          }
  
          // --- 垂直面の皿穴 ---
-         // 外側 = 前面(Y = -t)、穴は前(-Y)から後(+Y)へ開ける
-         // Z方向: 縁(Z=fl_vert)から inset 内側 → Z = fl_vert - inset = 30
+         // 外側 = 前面(Y = -t)
+         // 皿座面は前(外側)が大径、後(内側)が小径
+         // Z位置: 上の縁(Z=40)から inset=10 内側 → Z=30
          for (x = hole_xs) {
+             // 前面(外側)から穴を開ける: Y方向に +t 進む
              translate([x, -t - eps, fl_vert - inset]) {
-                 rotate([-90, 0, 0]) {
-                     // 貫通穴(前から後へ)
-                     cylinder(d=hole_d, h=t + 2*eps, $fn=48);
-                     // 皿座面: 外側(前面)から内側へ cs_dep 掘る
-                     cylinder(d1=cs_d, d2=hole_d, h=cs_dep + eps, $fn=48);
+                 rotate([90, 0, 0]) {
+                     // rotate後: Z方向が -Y方向(穴が内側へ向く)
+                     // 皿座面を外側(前面)に: d1=cs_d, d2=hole_d
+                     cylinder(d1=cs_d, d2=hole_d, h=cs_dep + eps, $fn=64);
+                     // 残りの貫通穴
+                     cylinder(d=hole_d, h=t + 2*eps, $fn=64);
                  }
              }
          }
      }
  }
  
  l_bracket();
SCAD (61 lines)
// L-Bracket (L字金具)
// 内側コーナーが原点、水平面は+Y方向、垂直面は+Z方向

width    = 50;   // 幅 (X方向)
fl_horiz = 40;   // 水平フランジ奥行き (Y方向)
fl_vert  = 40;   // 垂直フランジ高さ (Z方向)
t        = 3;    // 板厚
hole_d   = 4.5;  // 貫通穴径
cs_d     = 8;    // 皿座面径
cs_dep   = 2;    // 皿座面深さ
inset    = 10;   // 縁からの距離
eps      = 0.1;  // 干渉回避用微小値

// 穴のX位置: 幅50mm、縁から10mm内側 → X=10 と X=40
hole_xs = [inset, width - inset]; // [10, 40]

module l_bracket() {
    difference() {
        union() {
            // 水平面: X[0~50], Y[0~40], Z[-3~0]
            translate([0, 0, -t])
                cube([width, fl_horiz, t]);

            // 垂直面: X[0~50], Y[-3~0], Z[0~40]
            translate([0, -t, 0])
                cube([width, t, fl_vert]);
        }

        // --- 水平面の皿穴 ---
        // 外側 = 下面(Z = -t)
        // 皿座面は下(外側)が大径、上(内側)が小径
        // Y位置: 奥の縁(Y=40)から inset=10 内側 → Y=30
        for (x = hole_xs) {
            translate([x, fl_horiz - inset, -t - eps]) {
                // 皿座面(外側=下から): d1=cs_d(下/外), d2=hole_d(上/内)
                cylinder(d1=cs_d, d2=hole_d, h=cs_dep + eps, $fn=64);
                // 残りの貫通穴
                cylinder(d=hole_d, h=t + 2*eps, $fn=64);
            }
        }

        // --- 垂直面の皿穴 ---
        // 外側 = 前面(Y = -t)
        // 皿座面は前(外側)が大径、後(内側)が小径
        // Z位置: 上の縁(Z=40)から inset=10 内側 → Z=30
        for (x = hole_xs) {
            // 前面(外側)から穴を開ける: Y方向に +t 進む
            translate([x, -t - eps, fl_vert - inset]) {
                rotate([90, 0, 0]) {
                    // rotate後: Z方向が -Y方向(穴が内側へ向く)
                    // 皿座面を外側(前面)に: d1=cs_d, d2=hole_d
                    cylinder(d1=cs_d, d2=hole_d, h=cs_dep + eps, $fn=64);
                    // 残りの貫通穴
                    cylinder(d=hole_d, h=t + 2*eps, $fn=64);
                }
            }
        }
    }
}

l_bracket();
i3 success
iter 3
20.6s · 2062/1184t · $0.0239
diff vs i2: +27/-23
  // L-Bracket (L字金具)
  // 内側コーナーが原点、水平面は+Y方向、垂直面は+Z方向
  
  width    = 50;   // 幅 (X方向)
  fl_horiz = 40;   // 水平フランジ奥行き (Y方向)
  fl_vert  = 40;   // 垂直フランジ高さ (Z方向)
  t        = 3;    // 板厚
  hole_d   = 4.5;  // 貫通穴径
  cs_d     = 8;    // 皿座面径
  cs_dep   = 2;    // 皿座面深さ
  inset    = 10;   // 縁からの距離
  eps      = 0.1;  // 干渉回避用微小値
  
  // 穴のX位置: 幅50mm、縁から10mm内側 → X=10 と X=40
- hole_xs = [inset, width - inset]; // [10, 40]
+ hole_xs = [inset, width - inset];
  
+ module countersunk_hole_vertical(depth) {
+     // 上から下へ: 皿座面は上(外側=上面)
+     translate([0, 0, depth])
+         rotate([180, 0, 0]) {
+             cylinder(d1=cs_d, d2=hole_d, h=cs_dep + eps, $fn=64);
+             translate([0, 0, cs_dep])
+                 cylinder(d=hole_d, h=depth - cs_dep + eps, $fn=64);
+         }
+ }
+ 
+ module countersunk_hole_horizontal(depth) {
+     // 前面(Y=-t)から後方(+Y)へ掘る: 皿座面は前(外側=前面)
+     cylinder(d1=cs_d, d2=hole_d, h=cs_dep + eps, $fn=64);
+     translate([0, 0, cs_dep])
+         cylinder(d=hole_d, h=depth - cs_dep + eps, $fn=64);
+ }
+ 
  module l_bracket() {
      difference() {
          union() {
              // 水平面: X[0~50], Y[0~40], Z[-3~0]
              translate([0, 0, -t])
                  cube([width, fl_horiz, t]);
  
              // 垂直面: X[0~50], Y[-3~0], Z[0~40]
              translate([0, -t, 0])
                  cube([width, t, fl_vert]);
          }
  
          // --- 水平面の皿穴 ---
-         // 外側 = 下面(Z = -t)
-         // 皿座面は下(外側)が大径、上(内側)が小径
-         // Y位置: 奥の縁(Y=40)から inset=10 内側 → Y=30
+         // 外側 = 上面(Z=0)、穴は上から下へ
+         // Y位置: 縁(Y=fl_horiz)から inset 内側 → Y = fl_horiz - inset = 30
          for (x = hole_xs) {
-             translate([x, fl_horiz - inset, -t - eps]) {
-                 // 皿座面(外側=下から): d1=cs_d(下/外), d2=hole_d(上/内)
-                 cylinder(d1=cs_d, d2=hole_d, h=cs_dep + eps, $fn=64);
-                 // 残りの貫通穴
-                 cylinder(d=hole_d, h=t + 2*eps, $fn=64);
-             }
+             translate([x, fl_horiz - inset, 0])
+                 countersunk_hole_vertical(t + 2*eps);
          }
  
          // --- 垂直面の皿穴 ---
-         // 外側 = 前面(Y = -t)
-         // 皿座面は前(外側)が大径、後(内側)が小径
-         // Z位置: 上の縁(Z=40)から inset=10 内側 → Z=30
+         // 外側 = 前面(Y=-t)、穴は前面から後方(+Y)へ
+         // Z位置: 縁(Z=fl_vert)から inset 内側 → Z = fl_vert - inset = 30
          for (x = hole_xs) {
-             // 前面(外側)から穴を開ける: Y方向に +t 進む
-             translate([x, -t - eps, fl_vert - inset]) {
-                 rotate([90, 0, 0]) {
-                     // rotate後: Z方向が -Y方向(穴が内側へ向く)
-                     // 皿座面を外側(前面)に: d1=cs_d, d2=hole_d
-                     cylinder(d1=cs_d, d2=hole_d, h=cs_dep + eps, $fn=64);
-                     // 残りの貫通穴
-                     cylinder(d=hole_d, h=t + 2*eps, $fn=64);
-                 }
-             }
+             translate([x, -t - eps, fl_vert - inset])
+                 rotate([-90, 0, 0])
+                     countersunk_hole_horizontal(t + 2*eps);
          }
      }
  }
  
  l_bracket();
SCAD (65 lines)
// L-Bracket (L字金具)
// 内側コーナーが原点、水平面は+Y方向、垂直面は+Z方向

width    = 50;   // 幅 (X方向)
fl_horiz = 40;   // 水平フランジ奥行き (Y方向)
fl_vert  = 40;   // 垂直フランジ高さ (Z方向)
t        = 3;    // 板厚
hole_d   = 4.5;  // 貫通穴径
cs_d     = 8;    // 皿座面径
cs_dep   = 2;    // 皿座面深さ
inset    = 10;   // 縁からの距離
eps      = 0.1;  // 干渉回避用微小値

// 穴のX位置: 幅50mm、縁から10mm内側 → X=10 と X=40
hole_xs = [inset, width - inset];

module countersunk_hole_vertical(depth) {
    // 上から下へ: 皿座面は上(外側=上面)
    translate([0, 0, depth])
        rotate([180, 0, 0]) {
            cylinder(d1=cs_d, d2=hole_d, h=cs_dep + eps, $fn=64);
            translate([0, 0, cs_dep])
                cylinder(d=hole_d, h=depth - cs_dep + eps, $fn=64);
        }
}

module countersunk_hole_horizontal(depth) {
    // 前面(Y=-t)から後方(+Y)へ掘る: 皿座面は前(外側=前面)
    cylinder(d1=cs_d, d2=hole_d, h=cs_dep + eps, $fn=64);
    translate([0, 0, cs_dep])
        cylinder(d=hole_d, h=depth - cs_dep + eps, $fn=64);
}

module l_bracket() {
    difference() {
        union() {
            // 水平面: X[0~50], Y[0~40], Z[-3~0]
            translate([0, 0, -t])
                cube([width, fl_horiz, t]);

            // 垂直面: X[0~50], Y[-3~0], Z[0~40]
            translate([0, -t, 0])
                cube([width, t, fl_vert]);
        }

        // --- 水平面の皿穴 ---
        // 外側 = 上面(Z=0)、穴は上から下へ
        // Y位置: 縁(Y=fl_horiz)から inset 内側 → Y = fl_horiz - inset = 30
        for (x = hole_xs) {
            translate([x, fl_horiz - inset, 0])
                countersunk_hole_vertical(t + 2*eps);
        }

        // --- 垂直面の皿穴 ---
        // 外側 = 前面(Y=-t)、穴は前面から後方(+Y)へ
        // Z位置: 縁(Z=fl_vert)から inset 内側 → Z = fl_vert - inset = 30
        for (x = hole_xs) {
            translate([x, -t - eps, fl_vert - inset])
                rotate([-90, 0, 0])
                    countersunk_hole_horizontal(t + 2*eps);
        }
    }
}

l_bracket();