vibe-openscad

tier-2-l-bracket / gemini-2.5-flash

6 run / 累計 139.1s / 累計 $0.0205

gemini flash 2.5 bare

bare (provider default effort)

run detail →
render
bare render of tier-2-l-bracket
loading STL…
success 31.3s · 252/1252t · $0.0032
SCAD (83 lines)
// L-bracket parameters
flange_width = 50;
flange_depth_horiz = 40;
flange_height_vert = 40;
plate_thickness = 3;

// Countersunk hole parameters (M4 screw)
// M4 specifies a major diameter of 4mm.
// A common clearance hole diameter is 4.5mm.
// A common countersunk head diameter is 8mm, with a depth of 2mm.
cs_hole_depth_cs = 2; // Depth of the conical countersunk part
cs_hole_radius_top = 8 / 2; // Radius at the top of the countersunk part
cs_hole_radius_bottom = 4.5 / 2; // Radius at the bottom of the countersunk part (same as through hole)
thru_hole_radius = 4.5 / 2; // Radius of the straight through hole

// Overall depth for the hole operation to ensure complete cut through the plate
hole_overall_depth = plate_thickness + 2; // plate_thickness (3mm) + extra (2mm) = 5mm

// Hole placement parameters
hole_margin = 10; // Distance from the edge to the center of the hole

// Module for a countersunk hole, defined to originate at [0,0,0] and extend along the +Z axis.
// This allows easy rotation and translation to position the holes.
module countersunk_hole_m4() {
    union() {
        // Conical countersunk part
        cylinder(h = cs_hole_depth_cs, r1 = cs_hole_radius_top, r2 = cs_hole_radius_bottom, $fn = 64);
        // Straight through hole part, starting from where the countersunk part ends
        translate([0, 0, cs_hole_depth_cs])
        cylinder(h = hole_overall_depth - cs_hole_depth_cs, r = thru_hole_radius, $fn = 64);
    }
}

difference() {
    // 1. Main L-bracket shape
    union() {
        // Horizontal flange:
        // Dimensions: [width, depth, thickness] = [50mm, 40mm, 3mm]
        // Placed with inner corner at [0,0,0].
        // Extends from X=0 to 50, Y=0 to 40, Z=0 to 3.
        // +Y direction is depth, +Z direction is upwards (thickness).
        cube([flange_width, flange_depth_horiz, plate_thickness]);

        // Vertical flange:
        // Dimensions: [width, thickness, height] = [50mm, 3mm, 40mm]
        // Placed with inner corner at [0,0,0].
        // Extends from X=0 to 50, Y=0 to 3, Z=0 to 40.
        // +Y direction is thickness (into the bracket), +Z direction is height.
        cube([flange_width, plate_thickness, flange_height_vert]);
    }

    // 2. Countersunk holes to subtract from the bracket
    // The countersunk_hole_m4 module creates a hole along +Z.
    // We need to translate and rotate it to match the desired position and orientation.

    // Horizontal flange holes:
    // Located on the top surface (Z = plate_thickness), facing outwards (downwards, -Z).
    // X-coordinate: Center of the flange (flange_width / 2).
    // Y-coordinates: hole_margin and (flange_depth_horiz - hole_margin).
    // Z-coordinate: Top surface of the flange (plate_thickness).
    // Rotation: [180, 0, 0] to make the hole point downwards (-Z).
    translate([flange_width / 2, hole_margin, plate_thickness])
    rotate([180, 0, 0]) // Rotate 180 deg around X-axis to point hole downwards
    countersunk_hole_m4();

    translate([flange_width / 2, flange_depth_horiz - hole_margin, plate_thickness])
    rotate([180, 0, 0]) // Rotate 180 deg around X-axis to point hole downwards
    countersunk_hole_m4();

    // Vertical flange holes:
    // Located on the front surface (Y = plate_thickness), facing outwards (towards +Y).
    // X-coordinate: Center of the flange (flange_width / 2).
    // Y-coordinate: Front surface of the flange (plate_thickness).
    // Z-coordinates: hole_margin and (flange_height_vert - hole_margin).
    // Rotation: [90, 0, 0] to make the hole point towards +Y.
    translate([flange_width / 2, plate_thickness, hole_margin])
    rotate([90, 0, 0]) // Rotate 90 deg around X-axis to point hole towards +Y
    countersunk_hole_m4();

    translate([flange_width / 2, plate_thickness, flange_height_vert - hole_margin])
    rotate([90, 0, 0]) // Rotate 90 deg around X-axis to point hole towards +Y
    countersunk_hole_m4();
}
パラメータ (6)
スライダを動かすと 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: thinking

off success
off
4.3s · 252/622t · $0.0016
SCAD (58 lines)
// L字金具の寸法
flange_width = 50;  // 幅 (X方向)
horizontal_flange_depth = 40; // 水平フランジの奥行き (Y方向)
vertical_flange_height = 40;  // 垂直フランジの高さ (Z方向)
thickness = 3;      // 板厚

// 皿穴の寸法 (M4用)
hole_diameter = 4.5;    // 貫通穴の直径
countersink_diameter = 8; // 皿座面の直径
countersink_depth = 2;  // 皿座面の深さ

// 皿穴の位置 (各面の縁から10mm内側)
hole_offset_from_edge = 10;
hole_spacing_x = flange_width - (2 * hole_offset_from_edge); // 左右の穴の間隔
hole_pos_x = flange_width / 2; // X軸の中心

module L_bracket() {
    // 水平フランジ
    cube([flange_width, horizontal_flange_depth, thickness]);

    // 垂直フランジ
    translate([0, thickness, 0]) {
        rotate([90, 0, 0]) {
            cube([flange_width, vertical_flange_height, thickness]);
        }
    }
}

module countersunk_hole() {
    cylinder(h = thickness + 0.1, d = hole_diameter, $fn = 32);
    translate([0, 0, thickness - countersink_depth]) {
        cylinder(h = countersink_depth + 0.1, d1 = countersink_diameter, d2 = hole_diameter, $fn = 32);
    }
}

difference() {
    L_bracket();

    // 水平フランジの皿穴
    for (i = [-1, 1]) {
        translate([hole_pos_x + i * (hole_spacing_x / 2),
                   horizontal_flange_depth - hole_offset_from_edge,
                   0]) {
            countersunk_hole();
        }
    }

    // 垂直フランジの皿穴
    for (i = [-1, 1]) {
        translate([hole_pos_x + i * (hole_spacing_x / 2),
                   0, // Y方向は厚み分ずらす
                   vertical_flange_height - hole_offset_from_edge]) {
            rotate([90, 0, 0]) { // 皿座面が外側を向くように回転
                countersunk_hole();
            }
        }
    }
}
adaptivenot run
dynamic (default) success
dynamic
31.3s · 252/1252t · $0.0032
SCAD (83 lines)
// L-bracket parameters
flange_width = 50;
flange_depth_horiz = 40;
flange_height_vert = 40;
plate_thickness = 3;

// Countersunk hole parameters (M4 screw)
// M4 specifies a major diameter of 4mm.
// A common clearance hole diameter is 4.5mm.
// A common countersunk head diameter is 8mm, with a depth of 2mm.
cs_hole_depth_cs = 2; // Depth of the conical countersunk part
cs_hole_radius_top = 8 / 2; // Radius at the top of the countersunk part
cs_hole_radius_bottom = 4.5 / 2; // Radius at the bottom of the countersunk part (same as through hole)
thru_hole_radius = 4.5 / 2; // Radius of the straight through hole

// Overall depth for the hole operation to ensure complete cut through the plate
hole_overall_depth = plate_thickness + 2; // plate_thickness (3mm) + extra (2mm) = 5mm

// Hole placement parameters
hole_margin = 10; // Distance from the edge to the center of the hole

// Module for a countersunk hole, defined to originate at [0,0,0] and extend along the +Z axis.
// This allows easy rotation and translation to position the holes.
module countersunk_hole_m4() {
    union() {
        // Conical countersunk part
        cylinder(h = cs_hole_depth_cs, r1 = cs_hole_radius_top, r2 = cs_hole_radius_bottom, $fn = 64);
        // Straight through hole part, starting from where the countersunk part ends
        translate([0, 0, cs_hole_depth_cs])
        cylinder(h = hole_overall_depth - cs_hole_depth_cs, r = thru_hole_radius, $fn = 64);
    }
}

difference() {
    // 1. Main L-bracket shape
    union() {
        // Horizontal flange:
        // Dimensions: [width, depth, thickness] = [50mm, 40mm, 3mm]
        // Placed with inner corner at [0,0,0].
        // Extends from X=0 to 50, Y=0 to 40, Z=0 to 3.
        // +Y direction is depth, +Z direction is upwards (thickness).
        cube([flange_width, flange_depth_horiz, plate_thickness]);

        // Vertical flange:
        // Dimensions: [width, thickness, height] = [50mm, 3mm, 40mm]
        // Placed with inner corner at [0,0,0].
        // Extends from X=0 to 50, Y=0 to 3, Z=0 to 40.
        // +Y direction is thickness (into the bracket), +Z direction is height.
        cube([flange_width, plate_thickness, flange_height_vert]);
    }

    // 2. Countersunk holes to subtract from the bracket
    // The countersunk_hole_m4 module creates a hole along +Z.
    // We need to translate and rotate it to match the desired position and orientation.

    // Horizontal flange holes:
    // Located on the top surface (Z = plate_thickness), facing outwards (downwards, -Z).
    // X-coordinate: Center of the flange (flange_width / 2).
    // Y-coordinates: hole_margin and (flange_depth_horiz - hole_margin).
    // Z-coordinate: Top surface of the flange (plate_thickness).
    // Rotation: [180, 0, 0] to make the hole point downwards (-Z).
    translate([flange_width / 2, hole_margin, plate_thickness])
    rotate([180, 0, 0]) // Rotate 180 deg around X-axis to point hole downwards
    countersunk_hole_m4();

    translate([flange_width / 2, flange_depth_horiz - hole_margin, plate_thickness])
    rotate([180, 0, 0]) // Rotate 180 deg around X-axis to point hole downwards
    countersunk_hole_m4();

    // Vertical flange holes:
    // Located on the front surface (Y = plate_thickness), facing outwards (towards +Y).
    // X-coordinate: Center of the flange (flange_width / 2).
    // Y-coordinate: Front surface of the flange (plate_thickness).
    // Z-coordinates: hole_margin and (flange_height_vert - hole_margin).
    // Rotation: [90, 0, 0] to make the hole point towards +Y.
    translate([flange_width / 2, plate_thickness, hole_margin])
    rotate([90, 0, 0]) // Rotate 90 deg around X-axis to point hole towards +Y
    countersunk_hole_m4();

    translate([flange_width / 2, plate_thickness, flange_height_vert - hole_margin])
    rotate([90, 0, 0]) // Rotate 90 deg around X-axis to point hole towards +Y
    countersunk_hole_m4();
}

iteration: iter-png

i1 success
iter 1
38.9s · 1830/1430t · $0.0041
diff vs bare: +13/-7
  // L-bracket parameters
  flange_width = 50;
  flange_depth_horiz = 40;
  flange_height_vert = 40;
  plate_thickness = 3;
  
  // Countersunk hole parameters (M4 screw)
  // M4 specifies a major diameter of 4mm.
  // A common clearance hole diameter is 4.5mm.
  // A common countersunk head diameter is 8mm, with a depth of 2mm.
  cs_hole_depth_cs = 2; // Depth of the conical countersunk part
  cs_hole_radius_top = 8 / 2; // Radius at the top of the countersunk part
  cs_hole_radius_bottom = 4.5 / 2; // Radius at the bottom of the countersunk part (same as through hole)
  thru_hole_radius = 4.5 / 2; // Radius of the straight through hole
  
  // Overall depth for the hole operation to ensure complete cut through the plate
  hole_overall_depth = plate_thickness + 2; // plate_thickness (3mm) + extra (2mm) = 5mm
  
  // Hole placement parameters
  hole_margin = 10; // Distance from the edge to the center of the hole
  
  // Module for a countersunk hole, defined to originate at [0,0,0] and extend along the +Z axis.
- // This allows easy rotation and translation to position the holes.
+ // The wide part of the countersink is at Z=0, and it extends upwards towards +Z.
+ // This allows easy rotation and translation to position the holes correctly for subtraction.
  module countersunk_hole_m4() {
      union() {
-         // Conical countersunk part
+         // Conical countersunk part (from Z=0 to Z=cs_hole_depth_cs)
          cylinder(h = cs_hole_depth_cs, r1 = cs_hole_radius_top, r2 = cs_hole_radius_bottom, $fn = 64);
          // Straight through hole part, starting from where the countersunk part ends
          translate([0, 0, cs_hole_depth_cs])
          cylinder(h = hole_overall_depth - cs_hole_depth_cs, r = thru_hole_radius, $fn = 64);
      }
  }
  
  difference() {
      // 1. Main L-bracket shape
      union() {
          // Horizontal flange:
          // Dimensions: [width, depth, thickness] = [50mm, 40mm, 3mm]
          // Placed with inner corner at [0,0,0].
          // Extends from X=0 to 50, Y=0 to 40, Z=0 to 3.
          // +Y direction is depth, +Z direction is upwards (thickness).
          cube([flange_width, flange_depth_horiz, plate_thickness]);
  
          // Vertical flange:
          // Dimensions: [width, thickness, height] = [50mm, 3mm, 40mm]
          // Placed with inner corner at [0,0,0].
          // Extends from X=0 to 50, Y=0 to 3, Z=0 to 40.
          // +Y direction is thickness (into the bracket), +Z direction is height.
          cube([flange_width, plate_thickness, flange_height_vert]);
      }
  
      // 2. Countersunk holes to subtract from the bracket
-     // The countersunk_hole_m4 module creates a hole along +Z.
-     // We need to translate and rotate it to match the desired position and orientation.
+     // The countersunk_hole_m4 module creates a hole with its wide part at Z=0, extending along +Z.
+     // We need to translate and rotate it to match the desired position and orientation
+     // such that the countersink faces "outwards" from the bracket.
  
      // Horizontal flange holes:
-     // Located on the top surface (Z = plate_thickness), facing outwards (downwards, -Z).
+     // Located on the top surface (Z = plate_thickness), facing outwards (towards +Z).
+     // The inner corner is at [0,0,0], so the "outer" side of the horizontal flange is its top surface (Z=plate_thickness).
      // X-coordinate: Center of the flange (flange_width / 2).
      // Y-coordinates: hole_margin and (flange_depth_horiz - hole_margin).
      // Z-coordinate: Top surface of the flange (plate_thickness).
-     // Rotation: [180, 0, 0] to make the hole point downwards (-Z).
+     // Rotation: [180, 0, 0] makes the hole point downwards (-Z), ensuring the countersink is on the top surface
+     //           and recesses into the material from there.
      translate([flange_width / 2, hole_margin, plate_thickness])
      rotate([180, 0, 0]) // Rotate 180 deg around X-axis to point hole downwards
      countersunk_hole_m4();
  
      translate([flange_width / 2, flange_depth_horiz - hole_margin, plate_thickness])
      rotate([180, 0, 0]) // Rotate 180 deg around X-axis to point hole downwards
      countersunk_hole_m4();
  
      // Vertical flange holes:
      // Located on the front surface (Y = plate_thickness), facing outwards (towards +Y).
+     // The inner corner is at [0,0,0], so the "outer" side of the vertical flange is its front surface (Y=plate_thickness).
      // X-coordinate: Center of the flange (flange_width / 2).
      // Y-coordinate: Front surface of the flange (plate_thickness).
      // Z-coordinates: hole_margin and (flange_height_vert - hole_margin).
-     // Rotation: [90, 0, 0] to make the hole point towards +Y.
+     // Rotation: [90, 0, 0] makes the hole point towards +Y, ensuring the countersink is on the front surface
+     //           and recesses into the material from there.
      translate([flange_width / 2, plate_thickness, hole_margin])
      rotate([90, 0, 0]) // Rotate 90 deg around X-axis to point hole towards +Y
      countersunk_hole_m4();
  
      translate([flange_width / 2, plate_thickness, flange_height_vert - hole_margin])
      rotate([90, 0, 0]) // Rotate 90 deg around X-axis to point hole towards +Y
      countersunk_hole_m4();
  }
SCAD (89 lines)
// L-bracket parameters
flange_width = 50;
flange_depth_horiz = 40;
flange_height_vert = 40;
plate_thickness = 3;

// Countersunk hole parameters (M4 screw)
// M4 specifies a major diameter of 4mm.
// A common clearance hole diameter is 4.5mm.
// A common countersunk head diameter is 8mm, with a depth of 2mm.
cs_hole_depth_cs = 2; // Depth of the conical countersunk part
cs_hole_radius_top = 8 / 2; // Radius at the top of the countersunk part
cs_hole_radius_bottom = 4.5 / 2; // Radius at the bottom of the countersunk part (same as through hole)
thru_hole_radius = 4.5 / 2; // Radius of the straight through hole

// Overall depth for the hole operation to ensure complete cut through the plate
hole_overall_depth = plate_thickness + 2; // plate_thickness (3mm) + extra (2mm) = 5mm

// Hole placement parameters
hole_margin = 10; // Distance from the edge to the center of the hole

// Module for a countersunk hole, defined to originate at [0,0,0] and extend along the +Z axis.
// The wide part of the countersink is at Z=0, and it extends upwards towards +Z.
// This allows easy rotation and translation to position the holes correctly for subtraction.
module countersunk_hole_m4() {
    union() {
        // Conical countersunk part (from Z=0 to Z=cs_hole_depth_cs)
        cylinder(h = cs_hole_depth_cs, r1 = cs_hole_radius_top, r2 = cs_hole_radius_bottom, $fn = 64);
        // Straight through hole part, starting from where the countersunk part ends
        translate([0, 0, cs_hole_depth_cs])
        cylinder(h = hole_overall_depth - cs_hole_depth_cs, r = thru_hole_radius, $fn = 64);
    }
}

difference() {
    // 1. Main L-bracket shape
    union() {
        // Horizontal flange:
        // Dimensions: [width, depth, thickness] = [50mm, 40mm, 3mm]
        // Placed with inner corner at [0,0,0].
        // Extends from X=0 to 50, Y=0 to 40, Z=0 to 3.
        // +Y direction is depth, +Z direction is upwards (thickness).
        cube([flange_width, flange_depth_horiz, plate_thickness]);

        // Vertical flange:
        // Dimensions: [width, thickness, height] = [50mm, 3mm, 40mm]
        // Placed with inner corner at [0,0,0].
        // Extends from X=0 to 50, Y=0 to 3, Z=0 to 40.
        // +Y direction is thickness (into the bracket), +Z direction is height.
        cube([flange_width, plate_thickness, flange_height_vert]);
    }

    // 2. Countersunk holes to subtract from the bracket
    // The countersunk_hole_m4 module creates a hole with its wide part at Z=0, extending along +Z.
    // We need to translate and rotate it to match the desired position and orientation
    // such that the countersink faces "outwards" from the bracket.

    // Horizontal flange holes:
    // Located on the top surface (Z = plate_thickness), facing outwards (towards +Z).
    // The inner corner is at [0,0,0], so the "outer" side of the horizontal flange is its top surface (Z=plate_thickness).
    // X-coordinate: Center of the flange (flange_width / 2).
    // Y-coordinates: hole_margin and (flange_depth_horiz - hole_margin).
    // Z-coordinate: Top surface of the flange (plate_thickness).
    // Rotation: [180, 0, 0] makes the hole point downwards (-Z), ensuring the countersink is on the top surface
    //           and recesses into the material from there.
    translate([flange_width / 2, hole_margin, plate_thickness])
    rotate([180, 0, 0]) // Rotate 180 deg around X-axis to point hole downwards
    countersunk_hole_m4();

    translate([flange_width / 2, flange_depth_horiz - hole_margin, plate_thickness])
    rotate([180, 0, 0]) // Rotate 180 deg around X-axis to point hole downwards
    countersunk_hole_m4();

    // Vertical flange holes:
    // Located on the front surface (Y = plate_thickness), facing outwards (towards +Y).
    // The inner corner is at [0,0,0], so the "outer" side of the vertical flange is its front surface (Y=plate_thickness).
    // X-coordinate: Center of the flange (flange_width / 2).
    // Y-coordinate: Front surface of the flange (plate_thickness).
    // Z-coordinates: hole_margin and (flange_height_vert - hole_margin).
    // Rotation: [90, 0, 0] makes the hole point towards +Y, ensuring the countersink is on the front surface
    //           and recesses into the material from there.
    translate([flange_width / 2, plate_thickness, hole_margin])
    rotate([90, 0, 0]) // Rotate 90 deg around X-axis to point hole towards +Y
    countersunk_hole_m4();

    translate([flange_width / 2, plate_thickness, flange_height_vert - hole_margin])
    rotate([90, 0, 0]) // Rotate 90 deg around X-axis to point hole towards +Y
    countersunk_hole_m4();
}
i2 success
iter 2
18.1s · 2008/1430t · $0.0042
diff vs i1: +0/-0
  // L-bracket parameters
  flange_width = 50;
  flange_depth_horiz = 40;
  flange_height_vert = 40;
  plate_thickness = 3;
  
  // Countersunk hole parameters (M4 screw)
  // M4 specifies a major diameter of 4mm.
  // A common clearance hole diameter is 4.5mm.
  // A common countersunk head diameter is 8mm, with a depth of 2mm.
  cs_hole_depth_cs = 2; // Depth of the conical countersunk part
  cs_hole_radius_top = 8 / 2; // Radius at the top of the countersunk part
  cs_hole_radius_bottom = 4.5 / 2; // Radius at the bottom of the countersunk part (same as through hole)
  thru_hole_radius = 4.5 / 2; // Radius of the straight through hole
  
  // Overall depth for the hole operation to ensure complete cut through the plate
  hole_overall_depth = plate_thickness + 2; // plate_thickness (3mm) + extra (2mm) = 5mm
  
  // Hole placement parameters
  hole_margin = 10; // Distance from the edge to the center of the hole
  
  // Module for a countersunk hole, defined to originate at [0,0,0] and extend along the +Z axis.
  // The wide part of the countersink is at Z=0, and it extends upwards towards +Z.
  // This allows easy rotation and translation to position the holes correctly for subtraction.
  module countersunk_hole_m4() {
      union() {
          // Conical countersunk part (from Z=0 to Z=cs_hole_depth_cs)
          cylinder(h = cs_hole_depth_cs, r1 = cs_hole_radius_top, r2 = cs_hole_radius_bottom, $fn = 64);
          // Straight through hole part, starting from where the countersunk part ends
          translate([0, 0, cs_hole_depth_cs])
          cylinder(h = hole_overall_depth - cs_hole_depth_cs, r = thru_hole_radius, $fn = 64);
      }
  }
  
  difference() {
      // 1. Main L-bracket shape
      union() {
          // Horizontal flange:
          // Dimensions: [width, depth, thickness] = [50mm, 40mm, 3mm]
          // Placed with inner corner at [0,0,0].
          // Extends from X=0 to 50, Y=0 to 40, Z=0 to 3.
          // +Y direction is depth, +Z direction is upwards (thickness).
          cube([flange_width, flange_depth_horiz, plate_thickness]);
  
          // Vertical flange:
          // Dimensions: [width, thickness, height] = [50mm, 3mm, 40mm]
          // Placed with inner corner at [0,0,0].
          // Extends from X=0 to 50, Y=0 to 3, Z=0 to 40.
          // +Y direction is thickness (into the bracket), +Z direction is height.
          cube([flange_width, plate_thickness, flange_height_vert]);
      }
  
      // 2. Countersunk holes to subtract from the bracket
      // The countersunk_hole_m4 module creates a hole with its wide part at Z=0, extending along +Z.
      // We need to translate and rotate it to match the desired position and orientation
      // such that the countersink faces "outwards" from the bracket.
  
      // Horizontal flange holes:
      // Located on the top surface (Z = plate_thickness), facing outwards (towards +Z).
      // The inner corner is at [0,0,0], so the "outer" side of the horizontal flange is its top surface (Z=plate_thickness).
      // X-coordinate: Center of the flange (flange_width / 2).
      // Y-coordinates: hole_margin and (flange_depth_horiz - hole_margin).
      // Z-coordinate: Top surface of the flange (plate_thickness).
      // Rotation: [180, 0, 0] makes the hole point downwards (-Z), ensuring the countersink is on the top surface
      //           and recesses into the material from there.
      translate([flange_width / 2, hole_margin, plate_thickness])
      rotate([180, 0, 0]) // Rotate 180 deg around X-axis to point hole downwards
      countersunk_hole_m4();
  
      translate([flange_width / 2, flange_depth_horiz - hole_margin, plate_thickness])
      rotate([180, 0, 0]) // Rotate 180 deg around X-axis to point hole downwards
      countersunk_hole_m4();
  
      // Vertical flange holes:
      // Located on the front surface (Y = plate_thickness), facing outwards (towards +Y).
      // The inner corner is at [0,0,0], so the "outer" side of the vertical flange is its front surface (Y=plate_thickness).
      // X-coordinate: Center of the flange (flange_width / 2).
      // Y-coordinate: Front surface of the flange (plate_thickness).
      // Z-coordinates: hole_margin and (flange_height_vert - hole_margin).
      // Rotation: [90, 0, 0] makes the hole point towards +Y, ensuring the countersink is on the front surface
      //           and recesses into the material from there.
      translate([flange_width / 2, plate_thickness, hole_margin])
      rotate([90, 0, 0]) // Rotate 90 deg around X-axis to point hole towards +Y
      countersunk_hole_m4();
  
      translate([flange_width / 2, plate_thickness, flange_height_vert - hole_margin])
      rotate([90, 0, 0]) // Rotate 90 deg around X-axis to point hole towards +Y
      countersunk_hole_m4();
  }
SCAD (89 lines)
// L-bracket parameters
flange_width = 50;
flange_depth_horiz = 40;
flange_height_vert = 40;
plate_thickness = 3;

// Countersunk hole parameters (M4 screw)
// M4 specifies a major diameter of 4mm.
// A common clearance hole diameter is 4.5mm.
// A common countersunk head diameter is 8mm, with a depth of 2mm.
cs_hole_depth_cs = 2; // Depth of the conical countersunk part
cs_hole_radius_top = 8 / 2; // Radius at the top of the countersunk part
cs_hole_radius_bottom = 4.5 / 2; // Radius at the bottom of the countersunk part (same as through hole)
thru_hole_radius = 4.5 / 2; // Radius of the straight through hole

// Overall depth for the hole operation to ensure complete cut through the plate
hole_overall_depth = plate_thickness + 2; // plate_thickness (3mm) + extra (2mm) = 5mm

// Hole placement parameters
hole_margin = 10; // Distance from the edge to the center of the hole

// Module for a countersunk hole, defined to originate at [0,0,0] and extend along the +Z axis.
// The wide part of the countersink is at Z=0, and it extends upwards towards +Z.
// This allows easy rotation and translation to position the holes correctly for subtraction.
module countersunk_hole_m4() {
    union() {
        // Conical countersunk part (from Z=0 to Z=cs_hole_depth_cs)
        cylinder(h = cs_hole_depth_cs, r1 = cs_hole_radius_top, r2 = cs_hole_radius_bottom, $fn = 64);
        // Straight through hole part, starting from where the countersunk part ends
        translate([0, 0, cs_hole_depth_cs])
        cylinder(h = hole_overall_depth - cs_hole_depth_cs, r = thru_hole_radius, $fn = 64);
    }
}

difference() {
    // 1. Main L-bracket shape
    union() {
        // Horizontal flange:
        // Dimensions: [width, depth, thickness] = [50mm, 40mm, 3mm]
        // Placed with inner corner at [0,0,0].
        // Extends from X=0 to 50, Y=0 to 40, Z=0 to 3.
        // +Y direction is depth, +Z direction is upwards (thickness).
        cube([flange_width, flange_depth_horiz, plate_thickness]);

        // Vertical flange:
        // Dimensions: [width, thickness, height] = [50mm, 3mm, 40mm]
        // Placed with inner corner at [0,0,0].
        // Extends from X=0 to 50, Y=0 to 3, Z=0 to 40.
        // +Y direction is thickness (into the bracket), +Z direction is height.
        cube([flange_width, plate_thickness, flange_height_vert]);
    }

    // 2. Countersunk holes to subtract from the bracket
    // The countersunk_hole_m4 module creates a hole with its wide part at Z=0, extending along +Z.
    // We need to translate and rotate it to match the desired position and orientation
    // such that the countersink faces "outwards" from the bracket.

    // Horizontal flange holes:
    // Located on the top surface (Z = plate_thickness), facing outwards (towards +Z).
    // The inner corner is at [0,0,0], so the "outer" side of the horizontal flange is its top surface (Z=plate_thickness).
    // X-coordinate: Center of the flange (flange_width / 2).
    // Y-coordinates: hole_margin and (flange_depth_horiz - hole_margin).
    // Z-coordinate: Top surface of the flange (plate_thickness).
    // Rotation: [180, 0, 0] makes the hole point downwards (-Z), ensuring the countersink is on the top surface
    //           and recesses into the material from there.
    translate([flange_width / 2, hole_margin, plate_thickness])
    rotate([180, 0, 0]) // Rotate 180 deg around X-axis to point hole downwards
    countersunk_hole_m4();

    translate([flange_width / 2, flange_depth_horiz - hole_margin, plate_thickness])
    rotate([180, 0, 0]) // Rotate 180 deg around X-axis to point hole downwards
    countersunk_hole_m4();

    // Vertical flange holes:
    // Located on the front surface (Y = plate_thickness), facing outwards (towards +Y).
    // The inner corner is at [0,0,0], so the "outer" side of the vertical flange is its front surface (Y=plate_thickness).
    // X-coordinate: Center of the flange (flange_width / 2).
    // Y-coordinate: Front surface of the flange (plate_thickness).
    // Z-coordinates: hole_margin and (flange_height_vert - hole_margin).
    // Rotation: [90, 0, 0] makes the hole point towards +Y, ensuring the countersink is on the front surface
    //           and recesses into the material from there.
    translate([flange_width / 2, plate_thickness, hole_margin])
    rotate([90, 0, 0]) // Rotate 90 deg around X-axis to point hole towards +Y
    countersunk_hole_m4();

    translate([flange_width / 2, plate_thickness, flange_height_vert - hole_margin])
    rotate([90, 0, 0]) // Rotate 90 deg around X-axis to point hole towards +Y
    countersunk_hole_m4();
}
i3 success
iter 3
15.3s · 2008/1430t · $0.0042
diff vs i2: +0/-0
  // L-bracket parameters
  flange_width = 50;
  flange_depth_horiz = 40;
  flange_height_vert = 40;
  plate_thickness = 3;
  
  // Countersunk hole parameters (M4 screw)
  // M4 specifies a major diameter of 4mm.
  // A common clearance hole diameter is 4.5mm.
  // A common countersunk head diameter is 8mm, with a depth of 2mm.
  cs_hole_depth_cs = 2; // Depth of the conical countersunk part
  cs_hole_radius_top = 8 / 2; // Radius at the top of the countersunk part
  cs_hole_radius_bottom = 4.5 / 2; // Radius at the bottom of the countersunk part (same as through hole)
  thru_hole_radius = 4.5 / 2; // Radius of the straight through hole
  
  // Overall depth for the hole operation to ensure complete cut through the plate
  hole_overall_depth = plate_thickness + 2; // plate_thickness (3mm) + extra (2mm) = 5mm
  
  // Hole placement parameters
  hole_margin = 10; // Distance from the edge to the center of the hole
  
  // Module for a countersunk hole, defined to originate at [0,0,0] and extend along the +Z axis.
  // The wide part of the countersink is at Z=0, and it extends upwards towards +Z.
  // This allows easy rotation and translation to position the holes correctly for subtraction.
  module countersunk_hole_m4() {
      union() {
          // Conical countersunk part (from Z=0 to Z=cs_hole_depth_cs)
          cylinder(h = cs_hole_depth_cs, r1 = cs_hole_radius_top, r2 = cs_hole_radius_bottom, $fn = 64);
          // Straight through hole part, starting from where the countersunk part ends
          translate([0, 0, cs_hole_depth_cs])
          cylinder(h = hole_overall_depth - cs_hole_depth_cs, r = thru_hole_radius, $fn = 64);
      }
  }
  
  difference() {
      // 1. Main L-bracket shape
      union() {
          // Horizontal flange:
          // Dimensions: [width, depth, thickness] = [50mm, 40mm, 3mm]
          // Placed with inner corner at [0,0,0].
          // Extends from X=0 to 50, Y=0 to 40, Z=0 to 3.
          // +Y direction is depth, +Z direction is upwards (thickness).
          cube([flange_width, flange_depth_horiz, plate_thickness]);
  
          // Vertical flange:
          // Dimensions: [width, thickness, height] = [50mm, 3mm, 40mm]
          // Placed with inner corner at [0,0,0].
          // Extends from X=0 to 50, Y=0 to 3, Z=0 to 40.
          // +Y direction is thickness (into the bracket), +Z direction is height.
          cube([flange_width, plate_thickness, flange_height_vert]);
      }
  
      // 2. Countersunk holes to subtract from the bracket
      // The countersunk_hole_m4 module creates a hole with its wide part at Z=0, extending along +Z.
      // We need to translate and rotate it to match the desired position and orientation
      // such that the countersink faces "outwards" from the bracket.
  
      // Horizontal flange holes:
      // Located on the top surface (Z = plate_thickness), facing outwards (towards +Z).
      // The inner corner is at [0,0,0], so the "outer" side of the horizontal flange is its top surface (Z=plate_thickness).
      // X-coordinate: Center of the flange (flange_width / 2).
      // Y-coordinates: hole_margin and (flange_depth_horiz - hole_margin).
      // Z-coordinate: Top surface of the flange (plate_thickness).
      // Rotation: [180, 0, 0] makes the hole point downwards (-Z), ensuring the countersink is on the top surface
      //           and recesses into the material from there.
      translate([flange_width / 2, hole_margin, plate_thickness])
      rotate([180, 0, 0]) // Rotate 180 deg around X-axis to point hole downwards
      countersunk_hole_m4();
  
      translate([flange_width / 2, flange_depth_horiz - hole_margin, plate_thickness])
      rotate([180, 0, 0]) // Rotate 180 deg around X-axis to point hole downwards
      countersunk_hole_m4();
  
      // Vertical flange holes:
      // Located on the front surface (Y = plate_thickness), facing outwards (towards +Y).
      // The inner corner is at [0,0,0], so the "outer" side of the vertical flange is its front surface (Y=plate_thickness).
      // X-coordinate: Center of the flange (flange_width / 2).
      // Y-coordinate: Front surface of the flange (plate_thickness).
      // Z-coordinates: hole_margin and (flange_height_vert - hole_margin).
      // Rotation: [90, 0, 0] makes the hole point towards +Y, ensuring the countersink is on the front surface
      //           and recesses into the material from there.
      translate([flange_width / 2, plate_thickness, hole_margin])
      rotate([90, 0, 0]) // Rotate 90 deg around X-axis to point hole towards +Y
      countersunk_hole_m4();
  
      translate([flange_width / 2, plate_thickness, flange_height_vert - hole_margin])
      rotate([90, 0, 0]) // Rotate 90 deg around X-axis to point hole towards +Y
      countersunk_hole_m4();
  }
SCAD (89 lines)
// L-bracket parameters
flange_width = 50;
flange_depth_horiz = 40;
flange_height_vert = 40;
plate_thickness = 3;

// Countersunk hole parameters (M4 screw)
// M4 specifies a major diameter of 4mm.
// A common clearance hole diameter is 4.5mm.
// A common countersunk head diameter is 8mm, with a depth of 2mm.
cs_hole_depth_cs = 2; // Depth of the conical countersunk part
cs_hole_radius_top = 8 / 2; // Radius at the top of the countersunk part
cs_hole_radius_bottom = 4.5 / 2; // Radius at the bottom of the countersunk part (same as through hole)
thru_hole_radius = 4.5 / 2; // Radius of the straight through hole

// Overall depth for the hole operation to ensure complete cut through the plate
hole_overall_depth = plate_thickness + 2; // plate_thickness (3mm) + extra (2mm) = 5mm

// Hole placement parameters
hole_margin = 10; // Distance from the edge to the center of the hole

// Module for a countersunk hole, defined to originate at [0,0,0] and extend along the +Z axis.
// The wide part of the countersink is at Z=0, and it extends upwards towards +Z.
// This allows easy rotation and translation to position the holes correctly for subtraction.
module countersunk_hole_m4() {
    union() {
        // Conical countersunk part (from Z=0 to Z=cs_hole_depth_cs)
        cylinder(h = cs_hole_depth_cs, r1 = cs_hole_radius_top, r2 = cs_hole_radius_bottom, $fn = 64);
        // Straight through hole part, starting from where the countersunk part ends
        translate([0, 0, cs_hole_depth_cs])
        cylinder(h = hole_overall_depth - cs_hole_depth_cs, r = thru_hole_radius, $fn = 64);
    }
}

difference() {
    // 1. Main L-bracket shape
    union() {
        // Horizontal flange:
        // Dimensions: [width, depth, thickness] = [50mm, 40mm, 3mm]
        // Placed with inner corner at [0,0,0].
        // Extends from X=0 to 50, Y=0 to 40, Z=0 to 3.
        // +Y direction is depth, +Z direction is upwards (thickness).
        cube([flange_width, flange_depth_horiz, plate_thickness]);

        // Vertical flange:
        // Dimensions: [width, thickness, height] = [50mm, 3mm, 40mm]
        // Placed with inner corner at [0,0,0].
        // Extends from X=0 to 50, Y=0 to 3, Z=0 to 40.
        // +Y direction is thickness (into the bracket), +Z direction is height.
        cube([flange_width, plate_thickness, flange_height_vert]);
    }

    // 2. Countersunk holes to subtract from the bracket
    // The countersunk_hole_m4 module creates a hole with its wide part at Z=0, extending along +Z.
    // We need to translate and rotate it to match the desired position and orientation
    // such that the countersink faces "outwards" from the bracket.

    // Horizontal flange holes:
    // Located on the top surface (Z = plate_thickness), facing outwards (towards +Z).
    // The inner corner is at [0,0,0], so the "outer" side of the horizontal flange is its top surface (Z=plate_thickness).
    // X-coordinate: Center of the flange (flange_width / 2).
    // Y-coordinates: hole_margin and (flange_depth_horiz - hole_margin).
    // Z-coordinate: Top surface of the flange (plate_thickness).
    // Rotation: [180, 0, 0] makes the hole point downwards (-Z), ensuring the countersink is on the top surface
    //           and recesses into the material from there.
    translate([flange_width / 2, hole_margin, plate_thickness])
    rotate([180, 0, 0]) // Rotate 180 deg around X-axis to point hole downwards
    countersunk_hole_m4();

    translate([flange_width / 2, flange_depth_horiz - hole_margin, plate_thickness])
    rotate([180, 0, 0]) // Rotate 180 deg around X-axis to point hole downwards
    countersunk_hole_m4();

    // Vertical flange holes:
    // Located on the front surface (Y = plate_thickness), facing outwards (towards +Y).
    // The inner corner is at [0,0,0], so the "outer" side of the vertical flange is its front surface (Y=plate_thickness).
    // X-coordinate: Center of the flange (flange_width / 2).
    // Y-coordinate: Front surface of the flange (plate_thickness).
    // Z-coordinates: hole_margin and (flange_height_vert - hole_margin).
    // Rotation: [90, 0, 0] makes the hole point towards +Y, ensuring the countersink is on the front surface
    //           and recesses into the material from there.
    translate([flange_width / 2, plate_thickness, hole_margin])
    rotate([90, 0, 0]) // Rotate 90 deg around X-axis to point hole towards +Y
    countersunk_hole_m4();

    translate([flange_width / 2, plate_thickness, flange_height_vert - hole_margin])
    rotate([90, 0, 0]) // Rotate 90 deg around X-axis to point hole towards +Y
    countersunk_hole_m4();
}