vibe-openscad

tier-2-l-bracket / claude-opus-4-7

10 run / 累計 143.2s / 累計 $0.3171

claude opus 4.7 bare

bare (provider default effort)

run detail →
render
bare render of tier-2-l-bracket
loading STL…
success 20.0s · 386/1503t · $0.0395
SCAD (106 lines)
// L-bracket with countersunk holes

$fn = 64;

// Parameters
width = 50;       // X direction
depth = 40;       // Y direction (horizontal flange)
height = 40;      // Z direction (vertical flange)
thickness = 3;    // plate thickness

hole_dia = 4.5;
csk_dia = 8;
csk_depth = 2;
edge_offset = 10;

// Hole positions along the length axis of each flange (from inner corner)
// Each flange: 2 holes, edge_offset from each end of the 40mm dimension
hole_pos1 = edge_offset;
hole_pos2 = depth - edge_offset; // = 30 (also works for height since both 40)

// X positions: symmetric on width, also edge_offset from sides
x1 = edge_offset;
x2 = width - edge_offset;

module countersunk_hole_z() {
    // Hole through Z, countersink on top (+Z)
    union() {
        // through hole
        translate([0, 0, -1])
            cylinder(d = hole_dia, h = thickness + 2);
        // countersink from top surface
        translate([0, 0, thickness - csk_depth])
            cylinder(d = csk_dia, h = csk_depth + 1);
    }
}

module countersunk_hole_y() {
    // Hole through Y, countersink on -Y side (outer side of vertical flange)
    union() {
        translate([0, -1, 0])
            rotate([-90, 0, 0])
                cylinder(d = hole_dia, h = thickness + 2);
        // countersink on outer face (y = -thickness ... actually outer is y=0? )
        // Vertical flange occupies y in [-thickness, 0], outer is y = -thickness
        translate([0, -thickness, 0])
            rotate([-90, 0, 0])
                cylinder(d = csk_dia, h = csk_depth + 1, center = false);
        // Wait: rotate([-90,0,0]) makes cylinder go in +Y direction from origin
        // We want countersink starting at y=-thickness going in -Y direction (outward)
        // Better approach below
    }
}

// Cleaner version - rebuild
module l_bracket() {
    difference() {
        union() {
            // Horizontal flange: x in [0,width], y in [0,depth], z in [0,thickness]
            // Inner corner at origin, but inner corner means the inside of the L.
            // Horizontal flange extends in +Y, with top surface at z=0 (inner)
            // So horizontal flange: z in [-thickness, 0]
            translate([0, 0, -thickness])
                cube([width, depth, thickness]);
            
            // Vertical flange extends in +Z, inner face at y=0
            // So vertical flange: y in [-thickness, 0], z in [0, height]
            // But we need them to join at the corner properly
            translate([0, -thickness, -thickness])
                cube([width, thickness, height + thickness]);
        }
        
        // Holes in horizontal flange (through Z)
        // Outer surface is at z = -thickness (bottom), countersink there
        for (x = [x1, x2]) {
            for (y = [hole_pos1, hole_pos2]) {
                translate([x, y, 0]) {
                    // through hole
                    translate([0, 0, -thickness - 1])
                        cylinder(d = hole_dia, h = thickness + 2);
                    // countersink from bottom (outer)
                    translate([0, 0, -thickness - 0.01])
                        cylinder(d = csk_dia, h = csk_depth + 0.01);
                }
            }
        }
        
        // Holes in vertical flange (through Y)
        // Outer surface is at y = -thickness, countersink there
        for (x = [x1, x2]) {
            for (z = [hole_pos1, hole_pos2]) {
                translate([x, 0, z]) {
                    // through hole along -Y
                    translate([0, 1, 0])
                        rotate([90, 0, 0])
                            cylinder(d = hole_dia, h = thickness + 2);
                    // countersink on outer face (y = -thickness)
                    translate([0, -thickness + csk_depth + 0.01, 0])
                        rotate([90, 0, 0])
                            cylinder(d = csk_dia, h = csk_depth + 0.01);
                }
            }
        }
    }
}

l_bracket();
パラメータ (8)
スライダを動かすと 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
16.3s · 386/635t · $0.0178
SCAD (49 lines)
$fn = 64;

width = 50;
depth = 40;
height = 40;
t = 3;

hole_d = 4.5;
cs_d = 8;
cs_depth = 2;

module countersunk_hole_z() {
    // axis along Z, countersink on top (+Z side)
    translate([0, 0, -1])
        cylinder(d = hole_d, h = t + 2);
    translate([0, 0, t - cs_depth])
        cylinder(d = cs_d, h = cs_depth + 1);
}

difference() {
    union() {
        // Horizontal flange
        cube([width, depth, t]);
        // Vertical flange
        cube([width, t, height]);
    }
    
    // Horizontal flange holes (countersink on bottom, -Z side)
    // Center line in Y at y = (t + depth)/2... wait, "面の縁から10mm内側"
    // Holes along width centerline? "各面の中心線上で、面の縁から10mm内側、左右対称に2個"
    // Center line of horizontal face = y center; holes at x = 10 and x = width-10
    // Actually "中心線上" - on the centerline, "面の縁から10mm内側" from edge
    // 2 holes left-right symmetric -> along X axis at y = depth/2
    
    // Horizontal: countersink faces down (outside = -Z)
    for (x = [10, width - 10]) {
        translate([x, (t + depth) / 2, 0])
            rotate([180, 0, 0])
                translate([0, 0, -t])
                    countersunk_hole_z();
    }
    
    // Vertical flange: countersink faces +Y (outside)
    for (x = [10, width - 10]) {
        translate([x, 0, (t + height) / 2])
            rotate([-90, 0, 0])
                countersunk_hole_z();
    }
}
mediumnot run
high (default) success
high
13.9s · 386/1130t · $0.0302
SCAD (76 lines)
// L-bracket with countersunk holes

$fn = 64;

width    = 50;   // X
depth    = 40;   // Y (horizontal flange)
height   = 40;   // Z (vertical flange)
thk      = 3;    // plate thickness

hole_d   = 4.5;  // through hole
csk_d    = 8;    // countersink diameter
csk_h    = 2;    // countersink depth
edge_off = 10;   // distance from edge

// Hole X positions (symmetric on center line)
hx1 = width/2 - 10;
hx2 = width/2 + 10;

module countersunk_hole_z(z_outer_top) {
    // Hole drilled along Z axis. z_outer_top = top surface Z (outer face).
    // Through hole
    translate([0, 0, z_outer_top - thk - 0.1])
        cylinder(d = hole_d, h = thk + 0.2);
    // Countersink from outer (top) face going down
    translate([0, 0, z_outer_top - csk_h])
        cylinder(d = csk_d, h = csk_h + 0.01);
}

module countersunk_hole_y(y_outer_front) {
    // Hole drilled along Y axis. y_outer_front = outer face Y.
    translate([0, y_outer_front - thk - 0.1, 0])
        rotate([-90, 0, 0])
            cylinder(d = hole_d, h = thk + 0.2);
    translate([0, y_outer_front - csk_h, 0])
        rotate([-90, 0, 0])
            cylinder(d = csk_d, h = csk_h + 0.01);
}

difference() {
    union() {
        // Horizontal flange: top surface at Z=0, extends in +Y
        translate([0, 0, -thk])
            cube([width, depth, thk]);
        // Vertical flange: front surface at Y=0, extends in +Z
        translate([0, -thk, 0])
            cube([width, thk, height]);
    }

    // Horizontal flange holes (countersink on bottom = outer face)
    // Outer face is at Z = -thk; bolt head from below.
    // Use countersunk_hole_z with mirrored orientation: drill from bottom.
    for (x = [hx1, hx2]) {
        translate([x, depth - edge_off, 0]) {
            // Through hole
            translate([0, 0, -thk - 0.1])
                cylinder(d = hole_d, h = thk + 0.2);
            // Countersink on bottom (outer) face, opening downward
            translate([0, 0, -thk])
                cylinder(d1 = csk_d, d2 = csk_d, h = csk_h + 0.01);
        }
    }

    // Vertical flange holes (countersink on front = outer face at Y = -thk)
    for (x = [hx1, hx2]) {
        translate([x, 0, height - edge_off]) {
            // Through hole along Y
            translate([0, -thk - 0.1, 0])
                rotate([-90, 0, 0])
                    cylinder(d = hole_d, h = thk + 0.2);
            // Countersink on front face
            translate([0, -thk, 0])
                rotate([-90, 0, 0])
                    cylinder(d = csk_d, h = csk_h + 0.01);
        }
    }
}
max success
max
12.2s · 386/1002t · $0.0270
SCAD (72 lines)
// L-bracket with countersunk holes
// Inner corner at origin
// Horizontal flange extends in +Y direction
// Vertical flange extends in +Z direction

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

// Hole parameters (M4 countersunk)
hole_dia = 4.5;      // Through hole diameter
csk_dia = 8;         // Countersink diameter
csk_depth = 2;       // Countersink depth
edge_offset = 10;    // Distance from edge to hole center

$fn = 64;

module countersunk_hole_z() {
    // Hole along Z axis, countersink on top (+Z side)
    union() {
        // Through hole
        translate([0, 0, -1])
            cylinder(d = hole_dia, h = thickness + 2);
        // Countersink (cylindrical counterbore for simplicity per spec)
        translate([0, 0, thickness - csk_depth])
            cylinder(d = csk_dia, h = csk_depth + 1);
    }
}

module countersunk_hole_y() {
    // Hole along Y axis, countersink on -Y side (outside of vertical flange)
    union() {
        // Through hole
        translate([0, -1, 0])
            rotate([-90, 0, 0])
                cylinder(d = hole_dia, h = thickness + 2);
        // Countersink on outside (-Y side)
        translate([0, -csk_depth - 0.001, 0])
            rotate([-90, 0, 0])
                cylinder(d = csk_dia, h = csk_depth + 1);
    }
}

difference() {
    union() {
        // Horizontal flange: extends in +Y, thickness in -Z
        translate([-width/2, 0, -thickness])
            cube([width, depth, thickness]);
        
        // Vertical flange: extends in +Z, thickness in -Y
        translate([-width/2, -thickness, 0])
            cube([width, thickness, height]);
    }
    
    // Holes in horizontal flange (along Z axis)
    // Center line is X = 0, holes offset symmetrically along X
    // Hole position in Y: edge_offset from far edge, and edge_offset from near edge (corner)
    // Two holes on horizontal flange centerline (Y direction)
    translate([0, edge_offset, 0])
        countersunk_hole_z();
    translate([0, depth - edge_offset, 0])
        countersunk_hole_z();
    
    // Holes in vertical flange (along Y axis)
    // Two holes on vertical flange centerline (Z direction)
    translate([0, 0, edge_offset])
        countersunk_hole_y();
    translate([0, 0, height - edge_offset])
        countersunk_hole_y();
}
xhigh success
xhigh
11.4s · 386/919t · $0.0249
SCAD (62 lines)
// L-bracket with countersunk holes

$fn = 64;

width      = 50;   // 幅 (X方向)
depth      = 40;   // 水平面の奥行き (Y方向)
height     = 40;   // 垂直面の高さ (Z方向)
thickness  = 3;    // 板厚

hole_dia       = 4.5;  // 貫通穴径
csk_dia        = 8;    // 皿座面径
csk_depth      = 2;    // 皿座面深さ
edge_offset    = 10;   // 面の縁からの距離

module countersunk_hole_z() {
    // Z軸方向の穴(水平面用)、皿座面は下側(外側=Z-)
    union() {
        // 貫通穴
        translate([0, 0, -thickness - 1])
            cylinder(h = thickness + 2, d = hole_dia);
        // 皿座面(外側=下面側)
        translate([0, 0, -thickness - 0.01])
            cylinder(h = csk_depth + 0.01, d = csk_dia);
    }
}

module countersunk_hole_y() {
    // Y軸方向の穴(垂直面用)、皿座面は -Y 側(外側)
    union() {
        // 貫通穴
        translate([0, -1, 0])
            rotate([-90, 0, 0])
                cylinder(h = thickness + 2, d = hole_dia);
        // 皿座面(外側=-Y側)
        translate([0, -0.01, 0])
            rotate([90, 0, 0])
                cylinder(h = csk_depth + 0.01, d = csk_dia);
    }
}

difference() {
    union() {
        // 水平面フランジ (内側コーナー=原点、+Y方向、外側は -Z 側)
        translate([-width/2, 0, -thickness])
            cube([width, depth, thickness]);
        // 垂直面フランジ (内側コーナー=原点、+Z方向、外側は -Y 側)
        translate([-width/2, -thickness, 0])
            cube([width, thickness, height]);
    }

    // 水平面の穴 2 個 (X方向に左右対称、Y方向は縁から10mm内側 = Y = depth - 10)
    for (x = [-width/4, width/4]) {
        translate([x, depth - edge_offset, 0])
            countersunk_hole_z();
    }

    // 垂直面の穴 2 個 (X方向に左右対称、Z方向は縁から10mm内側 = Z = height - 10)
    for (x = [-width/4, width/4]) {
        translate([x, 0, height - edge_offset])
            countersunk_hole_y();
    }
}

variant: thinking

off success
off
13.9s · 386/1130t · $0.0302
SCAD (76 lines)
// L-bracket with countersunk holes

$fn = 64;

width    = 50;   // X
depth    = 40;   // Y (horizontal flange)
height   = 40;   // Z (vertical flange)
thk      = 3;    // plate thickness

hole_d   = 4.5;  // through hole
csk_d    = 8;    // countersink diameter
csk_h    = 2;    // countersink depth
edge_off = 10;   // distance from edge

// Hole X positions (symmetric on center line)
hx1 = width/2 - 10;
hx2 = width/2 + 10;

module countersunk_hole_z(z_outer_top) {
    // Hole drilled along Z axis. z_outer_top = top surface Z (outer face).
    // Through hole
    translate([0, 0, z_outer_top - thk - 0.1])
        cylinder(d = hole_d, h = thk + 0.2);
    // Countersink from outer (top) face going down
    translate([0, 0, z_outer_top - csk_h])
        cylinder(d = csk_d, h = csk_h + 0.01);
}

module countersunk_hole_y(y_outer_front) {
    // Hole drilled along Y axis. y_outer_front = outer face Y.
    translate([0, y_outer_front - thk - 0.1, 0])
        rotate([-90, 0, 0])
            cylinder(d = hole_d, h = thk + 0.2);
    translate([0, y_outer_front - csk_h, 0])
        rotate([-90, 0, 0])
            cylinder(d = csk_d, h = csk_h + 0.01);
}

difference() {
    union() {
        // Horizontal flange: top surface at Z=0, extends in +Y
        translate([0, 0, -thk])
            cube([width, depth, thk]);
        // Vertical flange: front surface at Y=0, extends in +Z
        translate([0, -thk, 0])
            cube([width, thk, height]);
    }

    // Horizontal flange holes (countersink on bottom = outer face)
    // Outer face is at Z = -thk; bolt head from below.
    // Use countersunk_hole_z with mirrored orientation: drill from bottom.
    for (x = [hx1, hx2]) {
        translate([x, depth - edge_off, 0]) {
            // Through hole
            translate([0, 0, -thk - 0.1])
                cylinder(d = hole_d, h = thk + 0.2);
            // Countersink on bottom (outer) face, opening downward
            translate([0, 0, -thk])
                cylinder(d1 = csk_d, d2 = csk_d, h = csk_h + 0.01);
        }
    }

    // Vertical flange holes (countersink on front = outer face at Y = -thk)
    for (x = [hx1, hx2]) {
        translate([x, 0, height - edge_off]) {
            // Through hole along Y
            translate([0, -thk - 0.1, 0])
                rotate([-90, 0, 0])
                    cylinder(d = hole_d, h = thk + 0.2);
            // Countersink on front face
            translate([0, -thk, 0])
                rotate([-90, 0, 0])
                    cylinder(d = csk_d, h = csk_h + 0.01);
        }
    }
}
adaptive (default) success
adaptive
11.4s · 386/919t · $0.0249
SCAD (62 lines)
// L-bracket with countersunk holes

$fn = 64;

width      = 50;   // 幅 (X方向)
depth      = 40;   // 水平面の奥行き (Y方向)
height     = 40;   // 垂直面の高さ (Z方向)
thickness  = 3;    // 板厚

hole_dia       = 4.5;  // 貫通穴径
csk_dia        = 8;    // 皿座面径
csk_depth      = 2;    // 皿座面深さ
edge_offset    = 10;   // 面の縁からの距離

module countersunk_hole_z() {
    // Z軸方向の穴(水平面用)、皿座面は下側(外側=Z-)
    union() {
        // 貫通穴
        translate([0, 0, -thickness - 1])
            cylinder(h = thickness + 2, d = hole_dia);
        // 皿座面(外側=下面側)
        translate([0, 0, -thickness - 0.01])
            cylinder(h = csk_depth + 0.01, d = csk_dia);
    }
}

module countersunk_hole_y() {
    // Y軸方向の穴(垂直面用)、皿座面は -Y 側(外側)
    union() {
        // 貫通穴
        translate([0, -1, 0])
            rotate([-90, 0, 0])
                cylinder(h = thickness + 2, d = hole_dia);
        // 皿座面(外側=-Y側)
        translate([0, -0.01, 0])
            rotate([90, 0, 0])
                cylinder(h = csk_depth + 0.01, d = csk_dia);
    }
}

difference() {
    union() {
        // 水平面フランジ (内側コーナー=原点、+Y方向、外側は -Z 側)
        translate([-width/2, 0, -thickness])
            cube([width, depth, thickness]);
        // 垂直面フランジ (内側コーナー=原点、+Z方向、外側は -Y 側)
        translate([-width/2, -thickness, 0])
            cube([width, thickness, height]);
    }

    // 水平面の穴 2 個 (X方向に左右対称、Y方向は縁から10mm内側 = Y = depth - 10)
    for (x = [-width/4, width/4]) {
        translate([x, depth - edge_offset, 0])
            countersunk_hole_z();
    }

    // 垂直面の穴 2 個 (X方向に左右対称、Z方向は縁から10mm内側 = Z = height - 10)
    for (x = [-width/4, width/4]) {
        translate([x, 0, height - edge_offset])
            countersunk_hole_y();
    }
}
dynamicnot run

iteration: iter-png

i1 success
iter 1
17.4s · 2655/1206t · $0.0434
diff vs bare: +30/-73
  // L-bracket with countersunk holes
  
  $fn = 64;
  
  // Parameters
  width = 50;       // X direction
- depth = 40;       // Y direction (horizontal flange)
- height = 40;      // Z direction (vertical flange)
+ depth = 40;       // Y direction (horizontal flange depth)
+ height = 40;      // Z direction (vertical flange height)
  thickness = 3;    // plate thickness
  
  hole_dia = 4.5;
  csk_dia = 8;
  csk_depth = 2;
  edge_offset = 10;
  
- // Hole positions along the length axis of each flange (from inner corner)
- // Each flange: 2 holes, edge_offset from each end of the 40mm dimension
- hole_pos1 = edge_offset;
- hole_pos2 = depth - edge_offset; // = 30 (also works for height since both 40)
+ // Holes are placed on the centerline of each face (x = width/2),
+ // 10mm from each edge along the length of the flange.
+ x_center = width / 2;
+ pos_a = edge_offset;          // 10mm from inner-corner-side edge
+ pos_b = depth - edge_offset;  // 10mm from far edge (=30mm)
  
- // X positions: symmetric on width, also edge_offset from sides
- x1 = edge_offset;
- x2 = width - edge_offset;
- 
- module countersunk_hole_z() {
-     // Hole through Z, countersink on top (+Z)
-     union() {
-         // through hole
-         translate([0, 0, -1])
-             cylinder(d = hole_dia, h = thickness + 2);
-         // countersink from top surface
-         translate([0, 0, thickness - csk_depth])
-             cylinder(d = csk_dia, h = csk_depth + 1);
-     }
- }
- 
- module countersunk_hole_y() {
-     // Hole through Y, countersink on -Y side (outer side of vertical flange)
-     union() {
-         translate([0, -1, 0])
-             rotate([-90, 0, 0])
-                 cylinder(d = hole_dia, h = thickness + 2);
-         // countersink on outer face (y = -thickness ... actually outer is y=0? )
-         // Vertical flange occupies y in [-thickness, 0], outer is y = -thickness
-         translate([0, -thickness, 0])
-             rotate([-90, 0, 0])
-                 cylinder(d = csk_dia, h = csk_depth + 1, center = false);
-         // Wait: rotate([-90,0,0]) makes cylinder go in +Y direction from origin
-         // We want countersink starting at y=-thickness going in -Y direction (outward)
-         // Better approach below
-     }
- }
- 
- // Cleaner version - rebuild
  module l_bracket() {
      difference() {
          union() {
-             // Horizontal flange: x in [0,width], y in [0,depth], z in [0,thickness]
-             // Inner corner at origin, but inner corner means the inside of the L.
-             // Horizontal flange extends in +Y, with top surface at z=0 (inner)
-             // So horizontal flange: z in [-thickness, 0]
+             // Horizontal flange: inner (top) surface at z=0, extends in +Y
              translate([0, 0, -thickness])
                  cube([width, depth, thickness]);
              
-             // Vertical flange extends in +Z, inner face at y=0
-             // So vertical flange: y in [-thickness, 0], z in [0, height]
-             // But we need them to join at the corner properly
+             // Vertical flange: inner face at y=0, extends in +Z
+             // Includes the corner block (z from -thickness to 0) for clean joint
              translate([0, -thickness, -thickness])
                  cube([width, thickness, height + thickness]);
          }
          
-         // Holes in horizontal flange (through Z)
-         // Outer surface is at z = -thickness (bottom), countersink there
-         for (x = [x1, x2]) {
-             for (y = [hole_pos1, hole_pos2]) {
-                 translate([x, y, 0]) {
-                     // through hole
-                     translate([0, 0, -thickness - 1])
-                         cylinder(d = hole_dia, h = thickness + 2);
-                     // countersink from bottom (outer)
-                     translate([0, 0, -thickness - 0.01])
-                         cylinder(d = csk_dia, h = csk_depth + 0.01);
-                 }
+         // Holes in horizontal flange (through Z), countersink on bottom (outer, -Z)
+         for (y = [pos_a, pos_b]) {
+             translate([x_center, y, 0]) {
+                 // through hole
+                 translate([0, 0, -thickness - 1])
+                     cylinder(d = hole_dia, h = thickness + 2);
+                 // countersink on outer (bottom) face
+                 translate([0, 0, -thickness - 0.01])
+                     cylinder(d = csk_dia, h = csk_depth + 0.01);
              }
          }
          
-         // Holes in vertical flange (through Y)
-         // Outer surface is at y = -thickness, countersink there
-         for (x = [x1, x2]) {
-             for (z = [hole_pos1, hole_pos2]) {
-                 translate([x, 0, z]) {
-                     // through hole along -Y
-                     translate([0, 1, 0])
-                         rotate([90, 0, 0])
-                             cylinder(d = hole_dia, h = thickness + 2);
-                     // countersink on outer face (y = -thickness)
-                     translate([0, -thickness + csk_depth + 0.01, 0])
-                         rotate([90, 0, 0])
-                             cylinder(d = csk_dia, h = csk_depth + 0.01);
-                 }
+         // Holes in vertical flange (through Y), countersink on outer (-Y) face
+         for (z = [pos_a, pos_b]) {
+             translate([x_center, 0, z]) {
+                 // through hole along Y
+                 translate([0, 1, 0])
+                     rotate([90, 0, 0])
+                         cylinder(d = hole_dia, h = thickness + 2);
+                 // countersink on outer (-Y) face
+                 translate([0, -thickness + csk_depth + 0.01, 0])
+                     rotate([90, 0, 0])
+                         cylinder(d = csk_dia, h = csk_depth + 0.01);
              }
          }
      }
  }
  
  l_bracket();
SCAD (63 lines)
// L-bracket with countersunk holes

$fn = 64;

// Parameters
width = 50;       // X direction
depth = 40;       // Y direction (horizontal flange depth)
height = 40;      // Z direction (vertical flange height)
thickness = 3;    // plate thickness

hole_dia = 4.5;
csk_dia = 8;
csk_depth = 2;
edge_offset = 10;

// Holes are placed on the centerline of each face (x = width/2),
// 10mm from each edge along the length of the flange.
x_center = width / 2;
pos_a = edge_offset;          // 10mm from inner-corner-side edge
pos_b = depth - edge_offset;  // 10mm from far edge (=30mm)

module l_bracket() {
    difference() {
        union() {
            // Horizontal flange: inner (top) surface at z=0, extends in +Y
            translate([0, 0, -thickness])
                cube([width, depth, thickness]);
            
            // Vertical flange: inner face at y=0, extends in +Z
            // Includes the corner block (z from -thickness to 0) for clean joint
            translate([0, -thickness, -thickness])
                cube([width, thickness, height + thickness]);
        }
        
        // Holes in horizontal flange (through Z), countersink on bottom (outer, -Z)
        for (y = [pos_a, pos_b]) {
            translate([x_center, y, 0]) {
                // through hole
                translate([0, 0, -thickness - 1])
                    cylinder(d = hole_dia, h = thickness + 2);
                // countersink on outer (bottom) face
                translate([0, 0, -thickness - 0.01])
                    cylinder(d = csk_dia, h = csk_depth + 0.01);
            }
        }
        
        // Holes in vertical flange (through Y), countersink on outer (-Y) face
        for (z = [pos_a, pos_b]) {
            translate([x_center, 0, z]) {
                // through hole along Y
                translate([0, 1, 0])
                    rotate([90, 0, 0])
                        cylinder(d = hole_dia, h = thickness + 2);
                // countersink on outer (-Y) face
                translate([0, -thickness + csk_depth + 0.01, 0])
                    rotate([90, 0, 0])
                        cylinder(d = csk_dia, h = csk_depth + 0.01);
            }
        }
    }
}

l_bracket();
i2 success
iter 2
13.4s · 2001/1176t · $0.0394
diff vs i1: +34/-30
  // L-bracket with countersunk holes
  
  $fn = 64;
  
  // Parameters
- width = 50;       // X direction
- depth = 40;       // Y direction (horizontal flange depth)
- height = 40;      // Z direction (vertical flange height)
+ width     = 50;   // X direction
+ depth     = 40;   // Y direction (horizontal flange depth)
+ height    = 40;   // Z direction (vertical flange height)
  thickness = 3;    // plate thickness
  
- hole_dia = 4.5;
- csk_dia = 8;
- csk_depth = 2;
+ hole_dia    = 4.5;
+ csk_dia     = 8;
+ csk_depth   = 2;
  edge_offset = 10;
  
- // Holes are placed on the centerline of each face (x = width/2),
- // 10mm from each edge along the length of the flange.
+ eps = 0.05;
+ 
+ // Hole positions: on centerline (x = width/2),
+ // 10mm from each end along the flange length, symmetrical pair.
  x_center = width / 2;
- pos_a = edge_offset;          // 10mm from inner-corner-side edge
- pos_b = depth - edge_offset;  // 10mm from far edge (=30mm)
+ pos_a = edge_offset;          // 10
+ pos_b = depth - edge_offset;  // 30
  
  module l_bracket() {
      difference() {
          union() {
-             // Horizontal flange: inner (top) surface at z=0, extends in +Y
+             // Horizontal flange: inner (top) face at z=0, extends in +Y
              translate([0, 0, -thickness])
                  cube([width, depth, thickness]);
-             
-             // Vertical flange: inner face at y=0, extends in +Z
-             // Includes the corner block (z from -thickness to 0) for clean joint
+ 
+             // Vertical flange: inner face at y=0, extends in +Z.
+             // Includes corner block (z: -thickness..0) for a clean joint.
              translate([0, -thickness, -thickness])
                  cube([width, thickness, height + thickness]);
          }
-         
-         // Holes in horizontal flange (through Z), countersink on bottom (outer, -Z)
+ 
+         // --- Horizontal flange holes (axis along Z) ---
+         // Outer face is at z = -thickness (bottom) -> countersink there.
          for (y = [pos_a, pos_b]) {
              translate([x_center, y, 0]) {
-                 // through hole
-                 translate([0, 0, -thickness - 1])
-                     cylinder(d = hole_dia, h = thickness + 2);
-                 // countersink on outer (bottom) face
-                 translate([0, 0, -thickness - 0.01])
-                     cylinder(d = csk_dia, h = csk_depth + 0.01);
+                 // Through hole
+                 translate([0, 0, -thickness - eps])
+                     cylinder(d = hole_dia, h = thickness + 2*eps);
+                 // Countersink on outer (-Z) face
+                 translate([0, 0, -thickness - eps])
+                     cylinder(d = csk_dia, h = csk_depth + eps);
              }
          }
-         
-         // Holes in vertical flange (through Y), countersink on outer (-Y) face
+ 
+         // --- Vertical flange holes (axis along Y) ---
+         // Outer face is at y = -thickness -> countersink there.
          for (z = [pos_a, pos_b]) {
              translate([x_center, 0, z]) {
-                 // through hole along Y
-                 translate([0, 1, 0])
+                 // Through hole along Y
+                 translate([0, eps, 0])
                      rotate([90, 0, 0])
-                         cylinder(d = hole_dia, h = thickness + 2);
-                 // countersink on outer (-Y) face
-                 translate([0, -thickness + csk_depth + 0.01, 0])
+                         cylinder(d = hole_dia, h = thickness + 2*eps);
+                 // Countersink on outer (-Y) face
+                 translate([0, -thickness + csk_depth + eps, 0])
                      rotate([90, 0, 0])
-                         cylinder(d = csk_dia, h = csk_depth + 0.01);
+                         cylinder(d = csk_dia, h = csk_depth + eps);
              }
          }
      }
  }
  
  l_bracket();
SCAD (67 lines)
// L-bracket with countersunk holes

$fn = 64;

// Parameters
width     = 50;   // X direction
depth     = 40;   // Y direction (horizontal flange depth)
height    = 40;   // Z direction (vertical flange height)
thickness = 3;    // plate thickness

hole_dia    = 4.5;
csk_dia     = 8;
csk_depth   = 2;
edge_offset = 10;

eps = 0.05;

// Hole positions: on centerline (x = width/2),
// 10mm from each end along the flange length, symmetrical pair.
x_center = width / 2;
pos_a = edge_offset;          // 10
pos_b = depth - edge_offset;  // 30

module l_bracket() {
    difference() {
        union() {
            // Horizontal flange: inner (top) face at z=0, extends in +Y
            translate([0, 0, -thickness])
                cube([width, depth, thickness]);

            // Vertical flange: inner face at y=0, extends in +Z.
            // Includes corner block (z: -thickness..0) for a clean joint.
            translate([0, -thickness, -thickness])
                cube([width, thickness, height + thickness]);
        }

        // --- Horizontal flange holes (axis along Z) ---
        // Outer face is at z = -thickness (bottom) -> countersink there.
        for (y = [pos_a, pos_b]) {
            translate([x_center, y, 0]) {
                // Through hole
                translate([0, 0, -thickness - eps])
                    cylinder(d = hole_dia, h = thickness + 2*eps);
                // Countersink on outer (-Z) face
                translate([0, 0, -thickness - eps])
                    cylinder(d = csk_dia, h = csk_depth + eps);
            }
        }

        // --- Vertical flange holes (axis along Y) ---
        // Outer face is at y = -thickness -> countersink there.
        for (z = [pos_a, pos_b]) {
            translate([x_center, 0, z]) {
                // Through hole along Y
                translate([0, eps, 0])
                    rotate([90, 0, 0])
                        cylinder(d = hole_dia, h = thickness + 2*eps);
                // Countersink on outer (-Y) face
                translate([0, -thickness + csk_depth + eps, 0])
                    rotate([90, 0, 0])
                        cylinder(d = csk_dia, h = csk_depth + eps);
            }
        }
    }
}

l_bracket();
i3 success
iter 3
13.2s · 2021/1189t · $0.0398
diff vs i2: +28/-24
  // L-bracket with countersunk holes
  
  $fn = 64;
  
  // Parameters
- width     = 50;   // X direction
- depth     = 40;   // Y direction (horizontal flange depth)
- height    = 40;   // Z direction (vertical flange height)
- thickness = 3;    // plate thickness
+ width     = 50;   // X direction (幅)
+ depth     = 40;   // Y direction (水平面の奥行き)
+ height    = 40;   // Z direction (垂直面の高さ)
+ thickness = 3;    // 板厚
  
  hole_dia    = 4.5;
  csk_dia     = 8;
  csk_depth   = 2;
  edge_offset = 10;
  
  eps = 0.05;
  
- // Hole positions: on centerline (x = width/2),
- // 10mm from each end along the flange length, symmetrical pair.
- x_center = width / 2;
- pos_a = edge_offset;          // 10
- pos_b = depth - edge_offset;  // 30
+ // 各面の「中心線」= 奥行き/高さ方向の中央線。
+ // その上に、幅方向で縁から 10mm 内側に左右対称な 2 点。
+ x_a = edge_offset;          // 10
+ x_b = width - edge_offset;  // 40
  
+ // 水平面: 中心線は y = depth/2
+ y_center = depth / 2;
+ // 垂直面: 中心線は z = height/2
+ z_center = height / 2;
+ 
  module l_bracket() {
      difference() {
          union() {
-             // Horizontal flange: inner (top) face at z=0, extends in +Y
+             // 水平フランジ: 内側(上)面が z=0、+Y 方向に伸びる
              translate([0, 0, -thickness])
                  cube([width, depth, thickness]);
  
-             // Vertical flange: inner face at y=0, extends in +Z.
-             // Includes corner block (z: -thickness..0) for a clean joint.
+             // 垂直フランジ: 内側面が y=0、+Z 方向に伸びる
+             // コーナー部 (z: -thickness..0) も含めて一体化
              translate([0, -thickness, -thickness])
                  cube([width, thickness, height + thickness]);
          }
  
-         // --- Horizontal flange holes (axis along Z) ---
-         // Outer face is at z = -thickness (bottom) -> countersink there.
-         for (y = [pos_a, pos_b]) {
-             translate([x_center, y, 0]) {
-                 // Through hole
+         // --- 水平フランジの穴 (軸は Z 方向) ---
+         // 外側(ボルト頭側)は -Z 面なので、そちらに皿座面
+         for (x = [x_a, x_b]) {
+             translate([x, y_center, 0]) {
+                 // 貫通穴
                  translate([0, 0, -thickness - eps])
                      cylinder(d = hole_dia, h = thickness + 2*eps);
-                 // Countersink on outer (-Z) face
+                 // 皿座面 (外側 = -Z 面側)
                  translate([0, 0, -thickness - eps])
                      cylinder(d = csk_dia, h = csk_depth + eps);
              }
          }
  
-         // --- Vertical flange holes (axis along Y) ---
-         // Outer face is at y = -thickness -> countersink there.
-         for (z = [pos_a, pos_b]) {
-             translate([x_center, 0, z]) {
-                 // Through hole along Y
+         // --- 垂直フランジの穴 (軸は Y 方向) ---
+         // 外側は -Y 面なので、そちらに皿座面
+         for (x = [x_a, x_b]) {
+             translate([x, 0, z_center]) {
+                 // 貫通穴 (Y 方向)
                  translate([0, eps, 0])
                      rotate([90, 0, 0])
                          cylinder(d = hole_dia, h = thickness + 2*eps);
-                 // Countersink on outer (-Y) face
+                 // 皿座面 (外側 = -Y 面側)
                  translate([0, -thickness + csk_depth + eps, 0])
                      rotate([90, 0, 0])
                          cylinder(d = csk_dia, h = csk_depth + eps);
              }
          }
      }
  }
  
  l_bracket();
SCAD (71 lines)
// L-bracket with countersunk holes

$fn = 64;

// Parameters
width     = 50;   // X direction (幅)
depth     = 40;   // Y direction (水平面の奥行き)
height    = 40;   // Z direction (垂直面の高さ)
thickness = 3;    // 板厚

hole_dia    = 4.5;
csk_dia     = 8;
csk_depth   = 2;
edge_offset = 10;

eps = 0.05;

// 各面の「中心線」= 奥行き/高さ方向の中央線。
// その上に、幅方向で縁から 10mm 内側に左右対称な 2 点。
x_a = edge_offset;          // 10
x_b = width - edge_offset;  // 40

// 水平面: 中心線は y = depth/2
y_center = depth / 2;
// 垂直面: 中心線は z = height/2
z_center = height / 2;

module l_bracket() {
    difference() {
        union() {
            // 水平フランジ: 内側(上)面が z=0、+Y 方向に伸びる
            translate([0, 0, -thickness])
                cube([width, depth, thickness]);

            // 垂直フランジ: 内側面が y=0、+Z 方向に伸びる
            // コーナー部 (z: -thickness..0) も含めて一体化
            translate([0, -thickness, -thickness])
                cube([width, thickness, height + thickness]);
        }

        // --- 水平フランジの穴 (軸は Z 方向) ---
        // 外側(ボルト頭側)は -Z 面なので、そちらに皿座面
        for (x = [x_a, x_b]) {
            translate([x, y_center, 0]) {
                // 貫通穴
                translate([0, 0, -thickness - eps])
                    cylinder(d = hole_dia, h = thickness + 2*eps);
                // 皿座面 (外側 = -Z 面側)
                translate([0, 0, -thickness - eps])
                    cylinder(d = csk_dia, h = csk_depth + eps);
            }
        }

        // --- 垂直フランジの穴 (軸は Y 方向) ---
        // 外側は -Y 面なので、そちらに皿座面
        for (x = [x_a, x_b]) {
            translate([x, 0, z_center]) {
                // 貫通穴 (Y 方向)
                translate([0, eps, 0])
                    rotate([90, 0, 0])
                        cylinder(d = hole_dia, h = thickness + 2*eps);
                // 皿座面 (外側 = -Y 面側)
                translate([0, -thickness + csk_depth + eps, 0])
                    rotate([90, 0, 0])
                        cylinder(d = csk_dia, h = csk_depth + eps);
            }
        }
    }
}

l_bracket();