vibe-openscad

tier-3-butt-hinge / claude-haiku-4-5-20251001

5 run / 累計 42.4s / 累計 $0.0382

claude haiku 4.5 2025-10-01 bare

bare (provider default effort)

run detail →
render
bare render of tier-3-butt-hinge
loading STL…
success 7.3s · 707/1031t · $0.0059
SCAD (105 lines)
// Butt Hinge Assembly - 180° Open State

// Parameters
leaf_length = 30;      // Y direction (along hinge axis)
leaf_width = 25;       // X direction (opening direction)
leaf_thickness = 2;
pin_diameter = 4;
pin_length = 32;
knuckle_outer_dia = 8;
knuckle_inner_dia = 4.6;
knuckle_width = 6;
clearance = 0.3;

// Module: Single leaf (flat plate)
module leaf() {
    cube([leaf_width, leaf_length, leaf_thickness], center=false);
}

// Module: Knuckle (cylindrical hinge element)
module knuckle() {
    difference() {
        cylinder(d=knuckle_outer_dia, h=knuckle_width, center=false, $fn=32);
        cylinder(d=knuckle_inner_dia, h=knuckle_width, center=false, $fn=32);
    }
}

// Module: Countersunk hole (M3)
module countersunk_hole(depth_countersink=1, dia_countersink=6, dia_hole=3.2) {
    union() {
        cylinder(d=dia_countersink, h=depth_countersink, center=false, $fn=16);
        cylinder(d=dia_hole, h=leaf_length, center=false, $fn=16);
    }
}

// Module: Left leaf with knuckles and countersunk holes
module left_leaf_assembly() {
    difference() {
        union() {
            // Base plate
            translate([-(leaf_width), 0, 0])
                leaf();
            
            // Knuckles: positions at Y = 0, 6, 12 mm
            // Left leaf has knuckles at outer positions and center
            for (y_pos = [0, 12]) {
                translate([0, y_pos, 0])
                    knuckle();
            }
            // Center knuckle
            translate([0, 6, 0])
                knuckle();
        }
        
        // Countersunk holes at Y = 2, 10, 18 mm (8mm spacing, away from knuckles)
        for (y_pos = [2, 10, 18]) {
            translate([-(leaf_width/2), y_pos, -(leaf_thickness)])
                countersunk_hole();
        }
    }
}

// Module: Right leaf with knuckles and countersunk holes
module right_leaf_assembly() {
    difference() {
        union() {
            // Base plate (mirrored position)
            leaf();
            
            // Knuckles: positions at Y = 6, 18 mm
            // Right leaf has knuckles at intermediate positions
            for (y_pos = [6, 18]) {
                translate([0, y_pos, 0])
                    knuckle();
            }
        }
        
        // Countersunk holes at Y = 2, 10, 18 mm (same spacing)
        for (y_pos = [2, 10, 18]) {
            translate([leaf_width/2, y_pos, -(leaf_thickness)])
                countersunk_hole();
        }
    }
}

// Module: Pin shaft (cylindrical)
module pin_shaft() {
    cylinder(d=pin_diameter, h=pin_length, center=false, $fn=32);
}

// Assembly
// Pin shaft along Y axis, centered at X=0
translate([0, -1, 0])
    pin_shaft();

// Left leaf: positioned at X negative, rotated 180° to open flat
// Knuckles at X=0, leaf extends to X negative
translate([0, 0, 0])
    rotate([0, 0, 180])
        translate([0, 0, 0])
            left_leaf_assembly();

// Right leaf: positioned at X positive, at Z=0 plane
// Knuckles at X=0, leaf extends to X positive
translate([0, 0, 0])
    right_leaf_assembly();
パラメータ (9)
スライダを動かすと 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: thinking

off (default) success
off
7.3s · 707/1031t · $0.0059
SCAD (105 lines)
// Butt Hinge Assembly - 180° Open State

// Parameters
leaf_length = 30;      // Y direction (along hinge axis)
leaf_width = 25;       // X direction (opening direction)
leaf_thickness = 2;
pin_diameter = 4;
pin_length = 32;
knuckle_outer_dia = 8;
knuckle_inner_dia = 4.6;
knuckle_width = 6;
clearance = 0.3;

// Module: Single leaf (flat plate)
module leaf() {
    cube([leaf_width, leaf_length, leaf_thickness], center=false);
}

// Module: Knuckle (cylindrical hinge element)
module knuckle() {
    difference() {
        cylinder(d=knuckle_outer_dia, h=knuckle_width, center=false, $fn=32);
        cylinder(d=knuckle_inner_dia, h=knuckle_width, center=false, $fn=32);
    }
}

// Module: Countersunk hole (M3)
module countersunk_hole(depth_countersink=1, dia_countersink=6, dia_hole=3.2) {
    union() {
        cylinder(d=dia_countersink, h=depth_countersink, center=false, $fn=16);
        cylinder(d=dia_hole, h=leaf_length, center=false, $fn=16);
    }
}

// Module: Left leaf with knuckles and countersunk holes
module left_leaf_assembly() {
    difference() {
        union() {
            // Base plate
            translate([-(leaf_width), 0, 0])
                leaf();
            
            // Knuckles: positions at Y = 0, 6, 12 mm
            // Left leaf has knuckles at outer positions and center
            for (y_pos = [0, 12]) {
                translate([0, y_pos, 0])
                    knuckle();
            }
            // Center knuckle
            translate([0, 6, 0])
                knuckle();
        }
        
        // Countersunk holes at Y = 2, 10, 18 mm (8mm spacing, away from knuckles)
        for (y_pos = [2, 10, 18]) {
            translate([-(leaf_width/2), y_pos, -(leaf_thickness)])
                countersunk_hole();
        }
    }
}

// Module: Right leaf with knuckles and countersunk holes
module right_leaf_assembly() {
    difference() {
        union() {
            // Base plate (mirrored position)
            leaf();
            
            // Knuckles: positions at Y = 6, 18 mm
            // Right leaf has knuckles at intermediate positions
            for (y_pos = [6, 18]) {
                translate([0, y_pos, 0])
                    knuckle();
            }
        }
        
        // Countersunk holes at Y = 2, 10, 18 mm (same spacing)
        for (y_pos = [2, 10, 18]) {
            translate([leaf_width/2, y_pos, -(leaf_thickness)])
                countersunk_hole();
        }
    }
}

// Module: Pin shaft (cylindrical)
module pin_shaft() {
    cylinder(d=pin_diameter, h=pin_length, center=false, $fn=32);
}

// Assembly
// Pin shaft along Y axis, centered at X=0
translate([0, -1, 0])
    pin_shaft();

// Left leaf: positioned at X negative, rotated 180° to open flat
// Knuckles at X=0, leaf extends to X negative
translate([0, 0, 0])
    rotate([0, 0, 180])
        translate([0, 0, 0])
            left_leaf_assembly();

// Right leaf: positioned at X positive, at Z=0 plane
// Knuckles at X=0, leaf extends to X positive
translate([0, 0, 0])
    right_leaf_assembly();
adaptivenot run
dynamicnot run

iteration: iter-png

i1 success
iter 1
9.6s · 2494/1251t · $0.0087
diff vs bare: +27/-35
  // Butt Hinge Assembly - 180° Open State
  
  // Parameters
  leaf_length = 30;      // Y direction (along hinge axis)
  leaf_width = 25;       // X direction (opening direction)
  leaf_thickness = 2;
  pin_diameter = 4;
  pin_length = 32;
  knuckle_outer_dia = 8;
  knuckle_inner_dia = 4.6;
  knuckle_width = 6;
- clearance = 0.3;
  
  // Module: Single leaf (flat plate)
- module leaf() {
-     cube([leaf_width, leaf_length, leaf_thickness], center=false);
+ module leaf(width, length, thickness) {
+     cube([width, length, thickness], center=false);
  }
  
  // Module: Knuckle (cylindrical hinge element)
  module knuckle() {
      difference() {
          cylinder(d=knuckle_outer_dia, h=knuckle_width, center=false, $fn=32);
          cylinder(d=knuckle_inner_dia, h=knuckle_width, center=false, $fn=32);
      }
  }
  
  // Module: Countersunk hole (M3)
- module countersunk_hole(depth_countersink=1, dia_countersink=6, dia_hole=3.2) {
+ module countersunk_hole() {
      union() {
-         cylinder(d=dia_countersink, h=depth_countersink, center=false, $fn=16);
-         cylinder(d=dia_hole, h=leaf_length, center=false, $fn=16);
+         // Countersink: 6mm dia, 1mm deep
+         cylinder(d=6, h=1, center=false, $fn=16);
+         // Through hole: 3.2mm dia
+         cylinder(d=3.2, h=leaf_thickness+2, center=false, $fn=16);
      }
  }
  
  // Module: Left leaf with knuckles and countersunk holes
  module left_leaf_assembly() {
      difference() {
          union() {
-             // Base plate
+             // Base plate (extends in negative X direction)
              translate([-(leaf_width), 0, 0])
-                 leaf();
+                 leaf(leaf_width, leaf_length, leaf_thickness);
              
-             // Knuckles: positions at Y = 0, 6, 12 mm
-             // Left leaf has knuckles at outer positions and center
-             for (y_pos = [0, 12]) {
-                 translate([0, y_pos, 0])
+             // Knuckles at Y = 0, 12, 24 mm (left leaf: outer 2 + center 1)
+             for (y_pos = [0, 12, 24]) {
+                 translate([-knuckle_outer_dia/2, y_pos, 0])
                      knuckle();
              }
-             // Center knuckle
-             translate([0, 6, 0])
-                 knuckle();
          }
          
-         // Countersunk holes at Y = 2, 10, 18 mm (8mm spacing, away from knuckles)
+         // Countersunk holes at Y = 2, 10, 18 mm (8mm spacing)
          for (y_pos = [2, 10, 18]) {
-             translate([-(leaf_width/2), y_pos, -(leaf_thickness)])
+             translate([-(leaf_width/2), y_pos, -0.5])
                  countersunk_hole();
          }
      }
  }
  
  // Module: Right leaf with knuckles and countersunk holes
  module right_leaf_assembly() {
      difference() {
          union() {
-             // Base plate (mirrored position)
-             leaf();
+             // Base plate (extends in positive X direction)
+             leaf(leaf_width, leaf_length, leaf_thickness);
              
-             // Knuckles: positions at Y = 6, 18 mm
-             // Right leaf has knuckles at intermediate positions
+             // Knuckles at Y = 6, 18 mm (right leaf: intermediate 2)
              for (y_pos = [6, 18]) {
-                 translate([0, y_pos, 0])
+                 translate([knuckle_outer_dia/2, y_pos, 0])
                      knuckle();
              }
          }
          
-         // Countersunk holes at Y = 2, 10, 18 mm (same spacing)
+         // Countersunk holes at Y = 2, 10, 18 mm (8mm spacing)
          for (y_pos = [2, 10, 18]) {
-             translate([leaf_width/2, y_pos, -(leaf_thickness)])
+             translate([leaf_width/2, y_pos, -0.5])
                  countersunk_hole();
          }
      }
  }
  
- // Module: Pin shaft (cylindrical)
+ // Module: Pin shaft
  module pin_shaft() {
      cylinder(d=pin_diameter, h=pin_length, center=false, $fn=32);
  }
  
- // Assembly
- // Pin shaft along Y axis, centered at X=0
- translate([0, -1, 0])
+ // Assembly - 180° open state
+ // Pin shaft centered at X=0, running along Y axis from Y=0 to Y=32
+ translate([0, 0, leaf_thickness])
      pin_shaft();
  
- // Left leaf: positioned at X negative, rotated 180° to open flat
- // Knuckles at X=0, leaf extends to X negative
+ // Left leaf: plate extends in negative X, centered at origin
  translate([0, 0, 0])
-     rotate([0, 0, 180])
-         translate([0, 0, 0])
-             left_leaf_assembly();
+     left_leaf_assembly();
  
- // Right leaf: positioned at X positive, at Z=0 plane
- // Knuckles at X=0, leaf extends to X positive
+ // Right leaf: plate extends in positive X, centered at origin, at same Z height
  translate([0, 0, 0])
      right_leaf_assembly();
SCAD (97 lines)
// Butt Hinge Assembly - 180° Open State

// Parameters
leaf_length = 30;      // Y direction (along hinge axis)
leaf_width = 25;       // X direction (opening direction)
leaf_thickness = 2;
pin_diameter = 4;
pin_length = 32;
knuckle_outer_dia = 8;
knuckle_inner_dia = 4.6;
knuckle_width = 6;

// Module: Single leaf (flat plate)
module leaf(width, length, thickness) {
    cube([width, length, thickness], center=false);
}

// Module: Knuckle (cylindrical hinge element)
module knuckle() {
    difference() {
        cylinder(d=knuckle_outer_dia, h=knuckle_width, center=false, $fn=32);
        cylinder(d=knuckle_inner_dia, h=knuckle_width, center=false, $fn=32);
    }
}

// Module: Countersunk hole (M3)
module countersunk_hole() {
    union() {
        // Countersink: 6mm dia, 1mm deep
        cylinder(d=6, h=1, center=false, $fn=16);
        // Through hole: 3.2mm dia
        cylinder(d=3.2, h=leaf_thickness+2, center=false, $fn=16);
    }
}

// Module: Left leaf with knuckles and countersunk holes
module left_leaf_assembly() {
    difference() {
        union() {
            // Base plate (extends in negative X direction)
            translate([-(leaf_width), 0, 0])
                leaf(leaf_width, leaf_length, leaf_thickness);
            
            // Knuckles at Y = 0, 12, 24 mm (left leaf: outer 2 + center 1)
            for (y_pos = [0, 12, 24]) {
                translate([-knuckle_outer_dia/2, y_pos, 0])
                    knuckle();
            }
        }
        
        // Countersunk holes at Y = 2, 10, 18 mm (8mm spacing)
        for (y_pos = [2, 10, 18]) {
            translate([-(leaf_width/2), y_pos, -0.5])
                countersunk_hole();
        }
    }
}

// Module: Right leaf with knuckles and countersunk holes
module right_leaf_assembly() {
    difference() {
        union() {
            // Base plate (extends in positive X direction)
            leaf(leaf_width, leaf_length, leaf_thickness);
            
            // Knuckles at Y = 6, 18 mm (right leaf: intermediate 2)
            for (y_pos = [6, 18]) {
                translate([knuckle_outer_dia/2, y_pos, 0])
                    knuckle();
            }
        }
        
        // Countersunk holes at Y = 2, 10, 18 mm (8mm spacing)
        for (y_pos = [2, 10, 18]) {
            translate([leaf_width/2, y_pos, -0.5])
                countersunk_hole();
        }
    }
}

// Module: Pin shaft
module pin_shaft() {
    cylinder(d=pin_diameter, h=pin_length, center=false, $fn=32);
}

// Assembly - 180° open state
// Pin shaft centered at X=0, running along Y axis from Y=0 to Y=32
translate([0, 0, leaf_thickness])
    pin_shaft();

// Left leaf: plate extends in negative X, centered at origin
translate([0, 0, 0])
    left_leaf_assembly();

// Right leaf: plate extends in positive X, centered at origin, at same Z height
translate([0, 0, 0])
    right_leaf_assembly();
i2 success
iter 2
8.9s · 2451/1274t · $0.0088
diff vs i1: +18/-10
  // Butt Hinge Assembly - 180° Open State
  
  // Parameters
  leaf_length = 30;      // Y direction (along hinge axis)
  leaf_width = 25;       // X direction (opening direction)
  leaf_thickness = 2;
  pin_diameter = 4;
  pin_length = 32;
  knuckle_outer_dia = 8;
  knuckle_inner_dia = 4.6;
  knuckle_width = 6;
  
  // Module: Single leaf (flat plate)
  module leaf(width, length, thickness) {
      cube([width, length, thickness], center=false);
  }
  
  // Module: Knuckle (cylindrical hinge element)
  module knuckle() {
      difference() {
          cylinder(d=knuckle_outer_dia, h=knuckle_width, center=false, $fn=32);
          cylinder(d=knuckle_inner_dia, h=knuckle_width, center=false, $fn=32);
      }
  }
  
  // Module: Countersunk hole (M3)
  module countersunk_hole() {
      union() {
          // Countersink: 6mm dia, 1mm deep
          cylinder(d=6, h=1, center=false, $fn=16);
          // Through hole: 3.2mm dia
          cylinder(d=3.2, h=leaf_thickness+2, center=false, $fn=16);
      }
  }
  
  // Module: Left leaf with knuckles and countersunk holes
  module left_leaf_assembly() {
      difference() {
          union() {
              // Base plate (extends in negative X direction)
              translate([-(leaf_width), 0, 0])
-                 leaf(leaf_width, leaf_length, leaf_thickness);
+                 cube([leaf_width, leaf_length, leaf_thickness]);
              
-             // Knuckles at Y = 0, 12, 24 mm (left leaf: outer 2 + center 1)
-             for (y_pos = [0, 12, 24]) {
+             // Knuckles at Y = 0, 12, 24 mm (left leaf: positions 0, 2, 4)
+             for (i = [0, 2, 4]) {
+                 y_pos = i * knuckle_width;
                  translate([-knuckle_outer_dia/2, y_pos, 0])
                      knuckle();
              }
          }
          
          // Countersunk holes at Y = 2, 10, 18 mm (8mm spacing)
          for (y_pos = [2, 10, 18]) {
              translate([-(leaf_width/2), y_pos, -0.5])
                  countersunk_hole();
          }
      }
  }
  
  // Module: Right leaf with knuckles and countersunk holes
  module right_leaf_assembly() {
      difference() {
          union() {
              // Base plate (extends in positive X direction)
-             leaf(leaf_width, leaf_length, leaf_thickness);
+             cube([leaf_width, leaf_length, leaf_thickness]);
              
-             // Knuckles at Y = 6, 18 mm (right leaf: intermediate 2)
-             for (y_pos = [6, 18]) {
+             // Knuckles at Y = 6, 18 mm (right leaf: positions 1, 3)
+             for (i = [1, 3]) {
+                 y_pos = i * knuckle_width;
                  translate([knuckle_outer_dia/2, y_pos, 0])
                      knuckle();
              }
          }
          
          // Countersunk holes at Y = 2, 10, 18 mm (8mm spacing)
          for (y_pos = [2, 10, 18]) {
              translate([leaf_width/2, y_pos, -0.5])
                  countersunk_hole();
          }
      }
  }
  
  // Module: Pin shaft
  module pin_shaft() {
+     // Pin runs along Z axis from -1mm to 31mm (protrudes 1mm on each end)
      cylinder(d=pin_diameter, h=pin_length, center=false, $fn=32);
  }
  
  // Assembly - 180° open state
- // Pin shaft centered at X=0, running along Y axis from Y=0 to Y=32
- translate([0, 0, leaf_thickness])
+ // Coordinate system:
+ // - Y axis: hinge axis direction (0-30mm along leaves)
+ // - X axis: opening direction (left leaf negative, right leaf positive)
+ // - Z axis: pin shaft axis
+ 
+ // Pin shaft: centered at X=0, Y direction from 0-30mm, Z from -1 to 31mm
+ translate([0, 0, -1])
      pin_shaft();
  
- // Left leaf: plate extends in negative X, centered at origin
+ // Left leaf: extends in negative X, base at Z=0
  translate([0, 0, 0])
      left_leaf_assembly();
  
- // Right leaf: plate extends in positive X, centered at origin, at same Z height
+ // Right leaf: extends in positive X, base at Z=0 (180° open, same plane)
  translate([0, 0, 0])
      right_leaf_assembly();
SCAD (105 lines)
// Butt Hinge Assembly - 180° Open State

// Parameters
leaf_length = 30;      // Y direction (along hinge axis)
leaf_width = 25;       // X direction (opening direction)
leaf_thickness = 2;
pin_diameter = 4;
pin_length = 32;
knuckle_outer_dia = 8;
knuckle_inner_dia = 4.6;
knuckle_width = 6;

// Module: Single leaf (flat plate)
module leaf(width, length, thickness) {
    cube([width, length, thickness], center=false);
}

// Module: Knuckle (cylindrical hinge element)
module knuckle() {
    difference() {
        cylinder(d=knuckle_outer_dia, h=knuckle_width, center=false, $fn=32);
        cylinder(d=knuckle_inner_dia, h=knuckle_width, center=false, $fn=32);
    }
}

// Module: Countersunk hole (M3)
module countersunk_hole() {
    union() {
        // Countersink: 6mm dia, 1mm deep
        cylinder(d=6, h=1, center=false, $fn=16);
        // Through hole: 3.2mm dia
        cylinder(d=3.2, h=leaf_thickness+2, center=false, $fn=16);
    }
}

// Module: Left leaf with knuckles and countersunk holes
module left_leaf_assembly() {
    difference() {
        union() {
            // Base plate (extends in negative X direction)
            translate([-(leaf_width), 0, 0])
                cube([leaf_width, leaf_length, leaf_thickness]);
            
            // Knuckles at Y = 0, 12, 24 mm (left leaf: positions 0, 2, 4)
            for (i = [0, 2, 4]) {
                y_pos = i * knuckle_width;
                translate([-knuckle_outer_dia/2, y_pos, 0])
                    knuckle();
            }
        }
        
        // Countersunk holes at Y = 2, 10, 18 mm (8mm spacing)
        for (y_pos = [2, 10, 18]) {
            translate([-(leaf_width/2), y_pos, -0.5])
                countersunk_hole();
        }
    }
}

// Module: Right leaf with knuckles and countersunk holes
module right_leaf_assembly() {
    difference() {
        union() {
            // Base plate (extends in positive X direction)
            cube([leaf_width, leaf_length, leaf_thickness]);
            
            // Knuckles at Y = 6, 18 mm (right leaf: positions 1, 3)
            for (i = [1, 3]) {
                y_pos = i * knuckle_width;
                translate([knuckle_outer_dia/2, y_pos, 0])
                    knuckle();
            }
        }
        
        // Countersunk holes at Y = 2, 10, 18 mm (8mm spacing)
        for (y_pos = [2, 10, 18]) {
            translate([leaf_width/2, y_pos, -0.5])
                countersunk_hole();
        }
    }
}

// Module: Pin shaft
module pin_shaft() {
    // Pin runs along Z axis from -1mm to 31mm (protrudes 1mm on each end)
    cylinder(d=pin_diameter, h=pin_length, center=false, $fn=32);
}

// Assembly - 180° open state
// Coordinate system:
// - Y axis: hinge axis direction (0-30mm along leaves)
// - X axis: opening direction (left leaf negative, right leaf positive)
// - Z axis: pin shaft axis

// Pin shaft: centered at X=0, Y direction from 0-30mm, Z from -1 to 31mm
translate([0, 0, -1])
    pin_shaft();

// Left leaf: extends in negative X, base at Z=0
translate([0, 0, 0])
    left_leaf_assembly();

// Right leaf: extends in positive X, base at Z=0 (180° open, same plane)
translate([0, 0, 0])
    right_leaf_assembly();
i3 success
iter 3
9.3s · 2567/1269t · $0.0089
diff vs i2: +17/-29
- // Butt Hinge Assembly - 180° Open State
+ // Butt Hinge Assembly - 180° Open State (Corrected)
  
  // Parameters
  leaf_length = 30;      // Y direction (along hinge axis)
  leaf_width = 25;       // X direction (opening direction)
  leaf_thickness = 2;
  pin_diameter = 4;
  pin_length = 32;
  knuckle_outer_dia = 8;
  knuckle_inner_dia = 4.6;
- knuckle_width = 6;
+ knuckle_length = 6;    // Height along Z axis
  
- // Module: Single leaf (flat plate)
- module leaf(width, length, thickness) {
-     cube([width, length, thickness], center=false);
- }
- 
  // Module: Knuckle (cylindrical hinge element)
  module knuckle() {
      difference() {
-         cylinder(d=knuckle_outer_dia, h=knuckle_width, center=false, $fn=32);
-         cylinder(d=knuckle_inner_dia, h=knuckle_width, center=false, $fn=32);
+         cylinder(d=knuckle_outer_dia, h=knuckle_length, center=false, $fn=32);
+         cylinder(d=knuckle_inner_dia, h=knuckle_length, center=false, $fn=32);
      }
  }
  
  // Module: Countersunk hole (M3)
  module countersunk_hole() {
-     union() {
-         // Countersink: 6mm dia, 1mm deep
-         cylinder(d=6, h=1, center=false, $fn=16);
-         // Through hole: 3.2mm dia
-         cylinder(d=3.2, h=leaf_thickness+2, center=false, $fn=16);
+     // Countersink: 6mm dia (top), 3.2mm dia (bottom), 1mm deep with taper
+     translate([0, 0, -0.5]) {
+         cylinder(d1=6, d2=3.2, h=1, center=false, $fn=16);
+         cylinder(d=3.2, h=leaf_thickness+1, center=false, $fn=16);
      }
  }
  
  // Module: Left leaf with knuckles and countersunk holes
  module left_leaf_assembly() {
      difference() {
          union() {
              // Base plate (extends in negative X direction)
              translate([-(leaf_width), 0, 0])
                  cube([leaf_width, leaf_length, leaf_thickness]);
              
-             // Knuckles at Y = 0, 12, 24 mm (left leaf: positions 0, 2, 4)
+             // Knuckles at Y = 0, 12, 24 mm (positions 0, 2, 4 of 5 divisions)
              for (i = [0, 2, 4]) {
-                 y_pos = i * knuckle_width;
-                 translate([-knuckle_outer_dia/2, y_pos, 0])
+                 y_pos = i * knuckle_length;
+                 translate([-knuckle_outer_dia/2, y_pos, -knuckle_length])
                      knuckle();
              }
          }
          
          // Countersunk holes at Y = 2, 10, 18 mm (8mm spacing)
          for (y_pos = [2, 10, 18]) {
-             translate([-(leaf_width/2), y_pos, -0.5])
+             translate([-(leaf_width/2), y_pos, leaf_thickness])
                  countersunk_hole();
          }
      }
  }
  
  // Module: Right leaf with knuckles and countersunk holes
  module right_leaf_assembly() {
      difference() {
          union() {
              // Base plate (extends in positive X direction)
              cube([leaf_width, leaf_length, leaf_thickness]);
              
-             // Knuckles at Y = 6, 18 mm (right leaf: positions 1, 3)
+             // Knuckles at Y = 6, 18 mm (positions 1, 3 of 5 divisions)
              for (i = [1, 3]) {
-                 y_pos = i * knuckle_width;
-                 translate([knuckle_outer_dia/2, y_pos, 0])
+                 y_pos = i * knuckle_length;
+                 translate([knuckle_outer_dia/2, y_pos, -knuckle_length])
                      knuckle();
              }
          }
          
          // Countersunk holes at Y = 2, 10, 18 mm (8mm spacing)
          for (y_pos = [2, 10, 18]) {
-             translate([leaf_width/2, y_pos, -0.5])
+             translate([leaf_width/2, y_pos, leaf_thickness])
                  countersunk_hole();
          }
      }
  }
  
  // Module: Pin shaft
  module pin_shaft() {
-     // Pin runs along Z axis from -1mm to 31mm (protrudes 1mm on each end)
      cylinder(d=pin_diameter, h=pin_length, center=false, $fn=32);
  }
  
  // Assembly - 180° open state
- // Coordinate system:
- // - Y axis: hinge axis direction (0-30mm along leaves)
- // - X axis: opening direction (left leaf negative, right leaf positive)
- // - Z axis: pin shaft axis
- 
- // Pin shaft: centered at X=0, Y direction from 0-30mm, Z from -1 to 31mm
+ // Pin shaft: centered at X=0, Y=0 to 30mm, Z=-1 to 31mm
  translate([0, 0, -1])
      pin_shaft();
  
  // Left leaf: extends in negative X, base at Z=0
  translate([0, 0, 0])
      left_leaf_assembly();
  
  // Right leaf: extends in positive X, base at Z=0 (180° open, same plane)
  translate([0, 0, 0])
      right_leaf_assembly();
SCAD (93 lines)
// Butt Hinge Assembly - 180° Open State (Corrected)

// Parameters
leaf_length = 30;      // Y direction (along hinge axis)
leaf_width = 25;       // X direction (opening direction)
leaf_thickness = 2;
pin_diameter = 4;
pin_length = 32;
knuckle_outer_dia = 8;
knuckle_inner_dia = 4.6;
knuckle_length = 6;    // Height along Z axis

// Module: Knuckle (cylindrical hinge element)
module knuckle() {
    difference() {
        cylinder(d=knuckle_outer_dia, h=knuckle_length, center=false, $fn=32);
        cylinder(d=knuckle_inner_dia, h=knuckle_length, center=false, $fn=32);
    }
}

// Module: Countersunk hole (M3)
module countersunk_hole() {
    // Countersink: 6mm dia (top), 3.2mm dia (bottom), 1mm deep with taper
    translate([0, 0, -0.5]) {
        cylinder(d1=6, d2=3.2, h=1, center=false, $fn=16);
        cylinder(d=3.2, h=leaf_thickness+1, center=false, $fn=16);
    }
}

// Module: Left leaf with knuckles and countersunk holes
module left_leaf_assembly() {
    difference() {
        union() {
            // Base plate (extends in negative X direction)
            translate([-(leaf_width), 0, 0])
                cube([leaf_width, leaf_length, leaf_thickness]);
            
            // Knuckles at Y = 0, 12, 24 mm (positions 0, 2, 4 of 5 divisions)
            for (i = [0, 2, 4]) {
                y_pos = i * knuckle_length;
                translate([-knuckle_outer_dia/2, y_pos, -knuckle_length])
                    knuckle();
            }
        }
        
        // Countersunk holes at Y = 2, 10, 18 mm (8mm spacing)
        for (y_pos = [2, 10, 18]) {
            translate([-(leaf_width/2), y_pos, leaf_thickness])
                countersunk_hole();
        }
    }
}

// Module: Right leaf with knuckles and countersunk holes
module right_leaf_assembly() {
    difference() {
        union() {
            // Base plate (extends in positive X direction)
            cube([leaf_width, leaf_length, leaf_thickness]);
            
            // Knuckles at Y = 6, 18 mm (positions 1, 3 of 5 divisions)
            for (i = [1, 3]) {
                y_pos = i * knuckle_length;
                translate([knuckle_outer_dia/2, y_pos, -knuckle_length])
                    knuckle();
            }
        }
        
        // Countersunk holes at Y = 2, 10, 18 mm (8mm spacing)
        for (y_pos = [2, 10, 18]) {
            translate([leaf_width/2, y_pos, leaf_thickness])
                countersunk_hole();
        }
    }
}

// Module: Pin shaft
module pin_shaft() {
    cylinder(d=pin_diameter, h=pin_length, center=false, $fn=32);
}

// Assembly - 180° open state
// Pin shaft: centered at X=0, Y=0 to 30mm, Z=-1 to 31mm
translate([0, 0, -1])
    pin_shaft();

// Left leaf: extends in negative X, base at Z=0
translate([0, 0, 0])
    left_leaf_assembly();

// Right leaf: extends in positive X, base at Z=0 (180° open, same plane)
translate([0, 0, 0])
    right_leaf_assembly();