vibe-openscad

tier-3-butt-hinge / gpt-5.4-2026-03-05

7 run / 累計 272.9s / 累計 $0.2604

openai gpt 5.4 2026-03-05 bare

bare (provider default effort)

run detail →
render
bare render of tier-3-butt-hinge
loading STL…
success 10.3s · 592/655t · $0.0117
SCAD (94 lines)
$fn = 96;

// ===== Parameters =====
leaf_len = 30;          // along Y
leaf_w   = 25;          // along X from hinge axis outward
leaf_t   = 2;           // along Z

pin_d = 4;
pin_r = pin_d/2;
pin_len = 32;

knuckle_od = 8;
knuckle_or = knuckle_od/2;
knuckle_id = 4.6;
knuckle_ir = knuckle_id/2;
knuckle_seg = 6;        // 30 / 5

csk_through_d = 3.2;
csk_head_d = 6.0;
csk_depth = 1.0;

// screw positions on each leaf
screw_y = [7, 15, 23];

// ===== Helpers =====
module pin_axis() {
    translate([0, -1, 0])
        rotate([-90, 0, 0])
            cylinder(h = pin_len, r = pin_r);
}

module knuckle_segment(y0) {
    translate([0, y0, 0])
        rotate([-90, 0, 0])
            difference() {
                cylinder(h = knuckle_seg, r = knuckle_or);
                cylinder(h = knuckle_seg, r = knuckle_ir);
            }
}

module countersunk_hole(ypos, xfrom_axis, from_top=true) {
    x = xfrom_axis;
    translate([x, ypos, 0]) {
        // through hole
        cylinder(h = leaf_t, d = csk_through_d);
        // countersink from top surface
        if (from_top) {
            translate([0, 0, leaf_t - csk_depth])
                cylinder(h = csk_depth + 0.001, d1 = csk_through_d, d2 = csk_head_d);
        } else {
            cylinder(h = csk_depth + 0.001, d1 = csk_head_d, d2 = csk_through_d);
        }
    }
}

module leaf_base(side="left") {
    if (side == "left") {
        translate([-leaf_w, 0, 0])
            cube([leaf_w, leaf_len, leaf_t]);
    } else {
        translate([0, 0, 0])
            cube([leaf_w, leaf_len, leaf_t]);
    }
}

module left_leaf() {
    difference() {
        union() {
            leaf_base("left");
            knuckle_segment(0);
            knuckle_segment(12);
            knuckle_segment(24);
        }
        for (yy = screw_y)
            countersunk_hole(yy, -18, true);
    }
}

module right_leaf() {
    difference() {
        union() {
            leaf_base("right");
            knuckle_segment(6);
            knuckle_segment(18);
        }
        for (yy = screw_y)
            countersunk_hole(yy, 18, true);
    }
}

// ===== Assembly: 180° open =====
left_leaf();
right_leaf();
pin_axis();
パラメータ (11)
スライダを動かすと openscad-wasm で再レンダリング

prompt

OpenSCAD で、家具用の小型バット蝶番(butt hinge)を作ってください。
3 つのパーツ(左板、右板、ピン軸)が組み合わさって動作する完成品を、
「開いた状態(180°)」で 1 つの SCAD ファイルに配置して出力します。

寸法と配置:
- 板(leaf)2 枚: 30mm × 25mm × 厚さ 2mm の鉄板形状
  - 縦 30mm の辺がピン軸に沿う(ヒンジ軸方向)
  - 横 25mm の辺が回転で開く方向に伸びる
- ピン軸: 直径 4mm の円柱、長さ 32mm(両端 1mm ずつ knuckle から飛び出す)
- knuckle(筒部): 縦 30mm を 5 等分(各 6mm)に区切り、左板に 3 個・右板に 2 個を
  互い違いに配置(左板は外側 2 個 + 中央 1 個、右板は中間 2 個)
- knuckle 外径 8mm、内径はピン軸 + 0.3mm クリアランス(= 4.6mm 穴)
- 左板と右板はピン軸を共有して回転可能。180° 開いた状態で、両板の
  平らな面が同一平面に来るように配置する
- 各板の knuckle から離れた側に、M3 用の皿穴を 3 個ずつ
  (穴ピッチは板の縦方向に 8mm 間隔、皿穴は表面から見て直径 6mm × 深さ 1mm
  のテーパ + 直径 3.2mm の貫通穴)

座標系:
- ピン軸の中心線を Y 軸に重ねる(ピン軸は +Y 方向)
- 板の平らな面は Z 軸に直交し、左板が x<0 側、右板が x>0 側に伸びる(180° 開)
- knuckle は X=0 を中心とし、Y 方向に 6mm ずつ並ぶ

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

variant: effort

low success
low
30.6s · 592/1810t · $0.0301
SCAD (83 lines)
$fn = 96;

leaf_len = 30;
leaf_w   = 25;
leaf_t   = 2;

pin_d    = 4;
pin_r    = pin_d / 2;
pin_len  = 32;

knuckle_od = 8;
knuckle_id = 4.6;
knuckle_r  = knuckle_od / 2;
knuckle_len = 6;

hole_d   = 3.2;
csk_d    = 6;
csink_h  = 1;

left_x0  = -knuckle_r - leaf_w;   // -29
right_x0 =  knuckle_r;            // 4
z0       = -leaf_t / 2;

hole_ys = [7, 15, 23];
left_hole_x  = left_x0  + 7;      // near free edge
right_hole_x = right_x0 + 18;     // near free edge

module pin_axis_cyl(y0, h, d) {
    translate([0, y0, 0])
        rotate([-90, 0, 0])
            cylinder(h = h, d = d);
}

module countersunk_hole(x, y) {
    union() {
        translate([x, y, -leaf_t])
            cylinder(h = leaf_t * 3, d = hole_d);
        translate([x, y, 0])
            cylinder(h = csink_h, d1 = hole_d, d2 = csk_d);
    }
}

module left_leaf() {
    difference() {
        union() {
            translate([left_x0, 0, z0])
                cube([leaf_w, leaf_len, leaf_t]);

            for (y0 = [0, 12, 24])
                pin_axis_cyl(y0, knuckle_len, knuckle_od);
        }

        pin_axis_cyl(0, leaf_len, knuckle_id);

        for (y = hole_ys)
            countersunk_hole(left_hole_x, y);
    }
}

module right_leaf() {
    difference() {
        union() {
            translate([right_x0, 0, z0])
                cube([leaf_w, leaf_len, leaf_t]);

            for (y0 = [6, 18])
                pin_axis_cyl(y0, knuckle_len, knuckle_od);
        }

        pin_axis_cyl(0, leaf_len, knuckle_id);

        for (y = hole_ys)
            countersunk_hole(right_hole_x, y);
    }
}

module pin() {
    pin_axis_cyl(-1, pin_len, pin_d);
}

color("silver") left_leaf();
color("silver") right_leaf();
color("gainsboro") pin();
medium (default) success
medium
10.3s · 592/655t · $0.0117
SCAD (94 lines)
$fn = 96;

// ===== Parameters =====
leaf_len = 30;          // along Y
leaf_w   = 25;          // along X from hinge axis outward
leaf_t   = 2;           // along Z

pin_d = 4;
pin_r = pin_d/2;
pin_len = 32;

knuckle_od = 8;
knuckle_or = knuckle_od/2;
knuckle_id = 4.6;
knuckle_ir = knuckle_id/2;
knuckle_seg = 6;        // 30 / 5

csk_through_d = 3.2;
csk_head_d = 6.0;
csk_depth = 1.0;

// screw positions on each leaf
screw_y = [7, 15, 23];

// ===== Helpers =====
module pin_axis() {
    translate([0, -1, 0])
        rotate([-90, 0, 0])
            cylinder(h = pin_len, r = pin_r);
}

module knuckle_segment(y0) {
    translate([0, y0, 0])
        rotate([-90, 0, 0])
            difference() {
                cylinder(h = knuckle_seg, r = knuckle_or);
                cylinder(h = knuckle_seg, r = knuckle_ir);
            }
}

module countersunk_hole(ypos, xfrom_axis, from_top=true) {
    x = xfrom_axis;
    translate([x, ypos, 0]) {
        // through hole
        cylinder(h = leaf_t, d = csk_through_d);
        // countersink from top surface
        if (from_top) {
            translate([0, 0, leaf_t - csk_depth])
                cylinder(h = csk_depth + 0.001, d1 = csk_through_d, d2 = csk_head_d);
        } else {
            cylinder(h = csk_depth + 0.001, d1 = csk_head_d, d2 = csk_through_d);
        }
    }
}

module leaf_base(side="left") {
    if (side == "left") {
        translate([-leaf_w, 0, 0])
            cube([leaf_w, leaf_len, leaf_t]);
    } else {
        translate([0, 0, 0])
            cube([leaf_w, leaf_len, leaf_t]);
    }
}

module left_leaf() {
    difference() {
        union() {
            leaf_base("left");
            knuckle_segment(0);
            knuckle_segment(12);
            knuckle_segment(24);
        }
        for (yy = screw_y)
            countersunk_hole(yy, -18, true);
    }
}

module right_leaf() {
    difference() {
        union() {
            leaf_base("right");
            knuckle_segment(6);
            knuckle_segment(18);
        }
        for (yy = screw_y)
            countersunk_hole(yy, 18, true);
    }
}

// ===== Assembly: 180° open =====
left_leaf();
right_leaf();
pin_axis();
high success
high
192.9s · 592/10109t · $0.1629
SCAD (72 lines)
$fn = 96;

eps = 0.01;

leaf_len   = 30;
leaf_w     = 25;
leaf_t     = 2;

pin_d      = 4;
pin_len    = 32;

knuckle_od = 8;
knuckle_id = 4.6;
knuckle_len = 6;

leaf_y0 = 1;          // leaves and knuckles span Y = 1..31
leaf_inner_x = 3;     // inner edge of flat leaf from hinge axis
hole_x = 21;          // countersunk hole center, far from knuckle
hole_ys = [8, 16, 24];

module y_cylinder(d, h) {
    rotate([90, 0, 0]) cylinder(d = d, h = h, center = true);
}

module knuckle_segment(idx) {
    yc = leaf_y0 + idx * knuckle_len + knuckle_len / 2;
    translate([0, yc, 0])
    difference() {
        y_cylinder(knuckle_od, knuckle_len);
        y_cylinder(knuckle_id, knuckle_len + 2 * eps);
    }
}

module mounting_hole() {
    union() {
        translate([0, 0, -leaf_t/2 - eps])
            cylinder(h = leaf_t + 2*eps, d = 3.2);
        translate([0, 0, -eps])
            cylinder(h = 1 + eps, d1 = 3.2, d2 = 6);
    }
}

module leaf_plate(side) {
    x0 = (side < 0) ? -(leaf_inner_x + leaf_w) : leaf_inner_x;
    translate([x0, leaf_y0, -leaf_t/2])
        cube([leaf_w, leaf_len, leaf_t]);
}

module leaf(side) {
    idxs = (side < 0) ? [0, 2, 4] : [1, 3];

    difference() {
        union() {
            leaf_plate(side);
            for (i = idxs)
                knuckle_segment(i);
        }

        for (yh = hole_ys)
            translate([side * hole_x, yh, 0])
                mounting_hole();
    }
}

module pin_axis() {
    translate([0, pin_len/2, 0])
        y_cylinder(pin_d, pin_len);
}

leaf(-1);
leaf( 1);
pin_axis();
maxnot run
xhighnot run

iteration: iter-png

i1 success
iter 1
8.7s · 1912/671t · $0.0146
diff vs bare: +34/-31
  $fn = 96;
  
  // ===== Parameters =====
- leaf_len = 30;          // along Y
- leaf_w   = 25;          // along X from hinge axis outward
- leaf_t   = 2;           // along Z
+ leaf_len = 30;          // Y direction
+ leaf_w   = 25;          // X direction from hinge axis outward
+ leaf_t   = 2;           // Z thickness
  
  pin_d = 4;
- pin_r = pin_d/2;
- pin_len = 32;
+ pin_r = pin_d / 2;
+ pin_len = 32;           // 30 + 1 mm each end exposed
  
  knuckle_od = 8;
- knuckle_or = knuckle_od/2;
- knuckle_id = 4.6;
- knuckle_ir = knuckle_id/2;
+ knuckle_or = knuckle_od / 2;
+ knuckle_id = 4.6;       // pin + 0.3 clearance
+ knuckle_ir = knuckle_id / 2;
  knuckle_seg = 6;        // 30 / 5
  
- csk_through_d = 3.2;
- csk_head_d = 6.0;
+ through_d = 3.2;
+ csk_d = 6.0;
  csk_depth = 1.0;
  
- // screw positions on each leaf
+ screw_pitch = 8;
  screw_y = [7, 15, 23];
  
- // ===== Helpers =====
+ // Screw columns placed away from knuckle side
+ screw_x_left  = -18;
+ screw_x_right =  18;
+ 
+ // Leaf surface position so that flat faces are coplanar at z=0
+ leaf_z0 = -leaf_t;
+ 
+ // ===== Modules =====
  module pin_axis() {
      translate([0, -1, 0])
          rotate([-90, 0, 0])
              cylinder(h = pin_len, r = pin_r);
  }
  
  module knuckle_segment(y0) {
      translate([0, y0, 0])
          rotate([-90, 0, 0])
              difference() {
                  cylinder(h = knuckle_seg, r = knuckle_or);
                  cylinder(h = knuckle_seg, r = knuckle_ir);
              }
  }
  
- module countersunk_hole(ypos, xfrom_axis, from_top=true) {
-     x = xfrom_axis;
-     translate([x, ypos, 0]) {
+ module countersunk_hole(x, y) {
+     translate([x, y, leaf_z0]) {
          // through hole
-         cylinder(h = leaf_t, d = csk_through_d);
-         // countersink from top surface
-         if (from_top) {
-             translate([0, 0, leaf_t - csk_depth])
-                 cylinder(h = csk_depth + 0.001, d1 = csk_through_d, d2 = csk_head_d);
-         } else {
-             cylinder(h = csk_depth + 0.001, d1 = csk_head_d, d2 = csk_through_d);
-         }
+         cylinder(h = leaf_t + 0.01, d = through_d);
+ 
+         // countersink from top flat face (z=0 side)
+         translate([0, 0, leaf_t - csk_depth])
+             cylinder(h = csk_depth + 0.02, d1 = through_d, d2 = csk_d);
      }
  }
  
- module leaf_base(side="left") {
+ module leaf_plate(side="left") {
      if (side == "left") {
-         translate([-leaf_w, 0, 0])
+         translate([-leaf_w, 0, leaf_z0])
              cube([leaf_w, leaf_len, leaf_t]);
      } else {
-         translate([0, 0, 0])
+         translate([0, 0, leaf_z0])
              cube([leaf_w, leaf_len, leaf_t]);
      }
  }
  
  module left_leaf() {
      difference() {
          union() {
-             leaf_base("left");
+             leaf_plate("left");
              knuckle_segment(0);
              knuckle_segment(12);
              knuckle_segment(24);
          }
          for (yy = screw_y)
-             countersunk_hole(yy, -18, true);
+             countersunk_hole(screw_x_left, yy);
      }
  }
  
  module right_leaf() {
      difference() {
          union() {
-             leaf_base("right");
+             leaf_plate("right");
              knuckle_segment(6);
              knuckle_segment(18);
          }
          for (yy = screw_y)
-             countersunk_hole(yy, 18, true);
+             countersunk_hole(screw_x_right, yy);
      }
  }
  
- // ===== Assembly: 180° open =====
+ // ===== Assembly =====
  left_leaf();
  right_leaf();
  pin_axis();
SCAD (97 lines)
$fn = 96;

// ===== Parameters =====
leaf_len = 30;          // Y direction
leaf_w   = 25;          // X direction from hinge axis outward
leaf_t   = 2;           // Z thickness

pin_d = 4;
pin_r = pin_d / 2;
pin_len = 32;           // 30 + 1 mm each end exposed

knuckle_od = 8;
knuckle_or = knuckle_od / 2;
knuckle_id = 4.6;       // pin + 0.3 clearance
knuckle_ir = knuckle_id / 2;
knuckle_seg = 6;        // 30 / 5

through_d = 3.2;
csk_d = 6.0;
csk_depth = 1.0;

screw_pitch = 8;
screw_y = [7, 15, 23];

// Screw columns placed away from knuckle side
screw_x_left  = -18;
screw_x_right =  18;

// Leaf surface position so that flat faces are coplanar at z=0
leaf_z0 = -leaf_t;

// ===== Modules =====
module pin_axis() {
    translate([0, -1, 0])
        rotate([-90, 0, 0])
            cylinder(h = pin_len, r = pin_r);
}

module knuckle_segment(y0) {
    translate([0, y0, 0])
        rotate([-90, 0, 0])
            difference() {
                cylinder(h = knuckle_seg, r = knuckle_or);
                cylinder(h = knuckle_seg, r = knuckle_ir);
            }
}

module countersunk_hole(x, y) {
    translate([x, y, leaf_z0]) {
        // through hole
        cylinder(h = leaf_t + 0.01, d = through_d);

        // countersink from top flat face (z=0 side)
        translate([0, 0, leaf_t - csk_depth])
            cylinder(h = csk_depth + 0.02, d1 = through_d, d2 = csk_d);
    }
}

module leaf_plate(side="left") {
    if (side == "left") {
        translate([-leaf_w, 0, leaf_z0])
            cube([leaf_w, leaf_len, leaf_t]);
    } else {
        translate([0, 0, leaf_z0])
            cube([leaf_w, leaf_len, leaf_t]);
    }
}

module left_leaf() {
    difference() {
        union() {
            leaf_plate("left");
            knuckle_segment(0);
            knuckle_segment(12);
            knuckle_segment(24);
        }
        for (yy = screw_y)
            countersunk_hole(screw_x_left, yy);
    }
}

module right_leaf() {
    difference() {
        union() {
            leaf_plate("right");
            knuckle_segment(6);
            knuckle_segment(18);
        }
        for (yy = screw_y)
            countersunk_hole(screw_x_right, yy);
    }
}

// ===== Assembly =====
left_leaf();
right_leaf();
pin_axis();
i2 success
iter 2
8.3s · 1928/673t · $0.0146
diff vs i1: +2/-2
  $fn = 96;
  
  // ===== Parameters =====
  leaf_len = 30;          // Y direction
  leaf_w   = 25;          // X direction from hinge axis outward
  leaf_t   = 2;           // Z thickness
  
  pin_d = 4;
  pin_r = pin_d / 2;
  pin_len = 32;           // 30 + 1 mm each end exposed
  
  knuckle_od = 8;
  knuckle_or = knuckle_od / 2;
  knuckle_id = 4.6;       // pin + 0.3 clearance
  knuckle_ir = knuckle_id / 2;
  knuckle_seg = 6;        // 30 / 5
  
  through_d = 3.2;
  csk_d = 6.0;
  csk_depth = 1.0;
  
  screw_pitch = 8;
  screw_y = [7, 15, 23];
  
  // Screw columns placed away from knuckle side
  screw_x_left  = -18;
  screw_x_right =  18;
  
- // Leaf surface position so that flat faces are coplanar at z=0
+ // Plate faces are coplanar at z=0 in the 180° open state
  leaf_z0 = -leaf_t;
  
  // ===== Modules =====
  module pin_axis() {
      translate([0, -1, 0])
          rotate([-90, 0, 0])
              cylinder(h = pin_len, r = pin_r);
  }
  
  module knuckle_segment(y0) {
      translate([0, y0, 0])
          rotate([-90, 0, 0])
              difference() {
                  cylinder(h = knuckle_seg, r = knuckle_or);
                  cylinder(h = knuckle_seg, r = knuckle_ir);
              }
  }
  
  module countersunk_hole(x, y) {
      translate([x, y, leaf_z0]) {
          // through hole
-         cylinder(h = leaf_t + 0.01, d = through_d);
+         cylinder(h = leaf_t + 0.02, d = through_d);
  
          // countersink from top flat face (z=0 side)
          translate([0, 0, leaf_t - csk_depth])
              cylinder(h = csk_depth + 0.02, d1 = through_d, d2 = csk_d);
      }
  }
  
  module leaf_plate(side="left") {
      if (side == "left") {
          translate([-leaf_w, 0, leaf_z0])
              cube([leaf_w, leaf_len, leaf_t]);
      } else {
          translate([0, 0, leaf_z0])
              cube([leaf_w, leaf_len, leaf_t]);
      }
  }
  
  module left_leaf() {
      difference() {
          union() {
              leaf_plate("left");
              knuckle_segment(0);
              knuckle_segment(12);
              knuckle_segment(24);
          }
          for (yy = screw_y)
              countersunk_hole(screw_x_left, yy);
      }
  }
  
  module right_leaf() {
      difference() {
          union() {
              leaf_plate("right");
              knuckle_segment(6);
              knuckle_segment(18);
          }
          for (yy = screw_y)
              countersunk_hole(screw_x_right, yy);
      }
  }
  
  // ===== Assembly =====
  left_leaf();
  right_leaf();
  pin_axis();
SCAD (97 lines)
$fn = 96;

// ===== Parameters =====
leaf_len = 30;          // Y direction
leaf_w   = 25;          // X direction from hinge axis outward
leaf_t   = 2;           // Z thickness

pin_d = 4;
pin_r = pin_d / 2;
pin_len = 32;           // 30 + 1 mm each end exposed

knuckle_od = 8;
knuckle_or = knuckle_od / 2;
knuckle_id = 4.6;       // pin + 0.3 clearance
knuckle_ir = knuckle_id / 2;
knuckle_seg = 6;        // 30 / 5

through_d = 3.2;
csk_d = 6.0;
csk_depth = 1.0;

screw_pitch = 8;
screw_y = [7, 15, 23];

// Screw columns placed away from knuckle side
screw_x_left  = -18;
screw_x_right =  18;

// Plate faces are coplanar at z=0 in the 180° open state
leaf_z0 = -leaf_t;

// ===== Modules =====
module pin_axis() {
    translate([0, -1, 0])
        rotate([-90, 0, 0])
            cylinder(h = pin_len, r = pin_r);
}

module knuckle_segment(y0) {
    translate([0, y0, 0])
        rotate([-90, 0, 0])
            difference() {
                cylinder(h = knuckle_seg, r = knuckle_or);
                cylinder(h = knuckle_seg, r = knuckle_ir);
            }
}

module countersunk_hole(x, y) {
    translate([x, y, leaf_z0]) {
        // through hole
        cylinder(h = leaf_t + 0.02, d = through_d);

        // countersink from top flat face (z=0 side)
        translate([0, 0, leaf_t - csk_depth])
            cylinder(h = csk_depth + 0.02, d1 = through_d, d2 = csk_d);
    }
}

module leaf_plate(side="left") {
    if (side == "left") {
        translate([-leaf_w, 0, leaf_z0])
            cube([leaf_w, leaf_len, leaf_t]);
    } else {
        translate([0, 0, leaf_z0])
            cube([leaf_w, leaf_len, leaf_t]);
    }
}

module left_leaf() {
    difference() {
        union() {
            leaf_plate("left");
            knuckle_segment(0);
            knuckle_segment(12);
            knuckle_segment(24);
        }
        for (yy = screw_y)
            countersunk_hole(screw_x_left, yy);
    }
}

module right_leaf() {
    difference() {
        union() {
            leaf_plate("right");
            knuckle_segment(6);
            knuckle_segment(18);
        }
        for (yy = screw_y)
            countersunk_hole(screw_x_right, yy);
    }
}

// ===== Assembly =====
left_leaf();
right_leaf();
pin_axis();
i3 success
iter 3
11.7s · 1930/684t · $0.0148
diff vs i2: +16/-21
  $fn = 96;
  
  // ===== Parameters =====
- leaf_len = 30;          // Y direction
- leaf_w   = 25;          // X direction from hinge axis outward
- leaf_t   = 2;           // Z thickness
+ leaf_len = 30;          // along hinge axis (Y)
+ leaf_w   = 25;          // opening direction (X)
+ leaf_t   = 2;           // plate thickness (Z)
  
  pin_d = 4;
  pin_r = pin_d / 2;
- pin_len = 32;           // 30 + 1 mm each end exposed
+ pin_len = 32;           // 30 mm knuckle stack + 1 mm protrusion each end
  
  knuckle_od = 8;
  knuckle_or = knuckle_od / 2;
- knuckle_id = 4.6;       // pin + 0.3 clearance
+ knuckle_id = 4.6;       // 4.0 + 0.3 clearance radial? per prompt given as hole dia 4.6
  knuckle_ir = knuckle_id / 2;
  knuckle_seg = 6;        // 30 / 5
  
  through_d = 3.2;
  csk_d = 6.0;
  csk_depth = 1.0;
  
- screw_pitch = 8;
  screw_y = [7, 15, 23];
- 
- // Screw columns placed away from knuckle side
  screw_x_left  = -18;
  screw_x_right =  18;
  
- // Plate faces are coplanar at z=0 in the 180° open state
+ // Common plate top surface at Z=0 in 180° open state
  leaf_z0 = -leaf_t;
  
  // ===== Modules =====
  module pin_axis() {
+     // centered on Y-axis, protruding 1 mm beyond knuckle stack at both ends
      translate([0, -1, 0])
          rotate([-90, 0, 0])
              cylinder(h = pin_len, r = pin_r);
  }
  
- module knuckle_segment(y0) {
+ module knuckle_tube(y0) {
      translate([0, y0, 0])
          rotate([-90, 0, 0])
              difference() {
                  cylinder(h = knuckle_seg, r = knuckle_or);
                  cylinder(h = knuckle_seg, r = knuckle_ir);
              }
  }
  
  module countersunk_hole(x, y) {
      translate([x, y, leaf_z0]) {
-         // through hole
          cylinder(h = leaf_t + 0.02, d = through_d);
- 
-         // countersink from top flat face (z=0 side)
          translate([0, 0, leaf_t - csk_depth])
              cylinder(h = csk_depth + 0.02, d1 = through_d, d2 = csk_d);
      }
  }
  
- module leaf_plate(side="left") {
+ module leaf_body(side="left") {
      if (side == "left") {
          translate([-leaf_w, 0, leaf_z0])
              cube([leaf_w, leaf_len, leaf_t]);
      } else {
          translate([0, 0, leaf_z0])
              cube([leaf_w, leaf_len, leaf_t]);
      }
  }
  
  module left_leaf() {
      difference() {
          union() {
-             leaf_plate("left");
-             knuckle_segment(0);
-             knuckle_segment(12);
-             knuckle_segment(24);
+             leaf_body("left");
+             knuckle_tube(0);
+             knuckle_tube(12);
+             knuckle_tube(24);
          }
          for (yy = screw_y)
              countersunk_hole(screw_x_left, yy);
      }
  }
  
  module right_leaf() {
      difference() {
          union() {
-             leaf_plate("right");
-             knuckle_segment(6);
-             knuckle_segment(18);
+             leaf_body("right");
+             knuckle_tube(6);
+             knuckle_tube(18);
          }
          for (yy = screw_y)
              countersunk_hole(screw_x_right, yy);
      }
  }
  
  // ===== Assembly =====
  left_leaf();
  right_leaf();
  pin_axis();
SCAD (92 lines)
$fn = 96;

// ===== Parameters =====
leaf_len = 30;          // along hinge axis (Y)
leaf_w   = 25;          // opening direction (X)
leaf_t   = 2;           // plate thickness (Z)

pin_d = 4;
pin_r = pin_d / 2;
pin_len = 32;           // 30 mm knuckle stack + 1 mm protrusion each end

knuckle_od = 8;
knuckle_or = knuckle_od / 2;
knuckle_id = 4.6;       // 4.0 + 0.3 clearance radial? per prompt given as hole dia 4.6
knuckle_ir = knuckle_id / 2;
knuckle_seg = 6;        // 30 / 5

through_d = 3.2;
csk_d = 6.0;
csk_depth = 1.0;

screw_y = [7, 15, 23];
screw_x_left  = -18;
screw_x_right =  18;

// Common plate top surface at Z=0 in 180° open state
leaf_z0 = -leaf_t;

// ===== Modules =====
module pin_axis() {
    // centered on Y-axis, protruding 1 mm beyond knuckle stack at both ends
    translate([0, -1, 0])
        rotate([-90, 0, 0])
            cylinder(h = pin_len, r = pin_r);
}

module knuckle_tube(y0) {
    translate([0, y0, 0])
        rotate([-90, 0, 0])
            difference() {
                cylinder(h = knuckle_seg, r = knuckle_or);
                cylinder(h = knuckle_seg, r = knuckle_ir);
            }
}

module countersunk_hole(x, y) {
    translate([x, y, leaf_z0]) {
        cylinder(h = leaf_t + 0.02, d = through_d);
        translate([0, 0, leaf_t - csk_depth])
            cylinder(h = csk_depth + 0.02, d1 = through_d, d2 = csk_d);
    }
}

module leaf_body(side="left") {
    if (side == "left") {
        translate([-leaf_w, 0, leaf_z0])
            cube([leaf_w, leaf_len, leaf_t]);
    } else {
        translate([0, 0, leaf_z0])
            cube([leaf_w, leaf_len, leaf_t]);
    }
}

module left_leaf() {
    difference() {
        union() {
            leaf_body("left");
            knuckle_tube(0);
            knuckle_tube(12);
            knuckle_tube(24);
        }
        for (yy = screw_y)
            countersunk_hole(screw_x_left, yy);
    }
}

module right_leaf() {
    difference() {
        union() {
            leaf_body("right");
            knuckle_tube(6);
            knuckle_tube(18);
        }
        for (yy = screw_y)
            countersunk_hole(screw_x_right, yy);
    }
}

// ===== Assembly =====
left_leaf();
right_leaf();
pin_axis();