vibe-openscad

tier-3-butt-hinge / gemini-3-flash-preview

6 run / 累計 154.6s / 累計 $0.0190

gemini flash 3 preview bare

bare (provider default effort)

run detail →
render
bare render of tier-3-butt-hinge
loading STL…
success 23.2s · 515/956t · $0.0025
SCAD (83 lines)
$fn = 64;

// --- パラメータ設定 ---
leaf_w = 25;           // 板の幅
leaf_h = 30;           // 板の高さ(縦)
leaf_t = 2;            // 板の厚み
pin_d = 4;             // ピン直径
pin_l = 32;            // ピン長さ
knuckle_od = 8;        // ナックル外径
knuckle_id = 4.6;      // ナックル内径 (4mm + 0.3mm clearance x 2)
knuckle_segments = 5;  // 分割数
seg_h = leaf_h / knuckle_segments; // 1区画の長さ(6mm)

screw_d = 3.2;         // M3貫通穴径
screw_head_d = 6;      // 皿穴表面径
screw_head_t = 1;      // 皿穴テーパ深さ
hole_pitch = 8;        // 穴の間隔
hole_x_pos = 18;       // ピン中心からの穴のX位置

// --- モジュール: 皿穴 ---
module screw_hole() {
    // 貫通穴
    translate([0, 0, -leaf_t - 0.5])
        cylinder(d = screw_d, h = leaf_t + 1);
    // 皿取りテーパ部
    translate([0, 0, -screw_head_t])
        cylinder(d1 = screw_d, d2 = screw_head_d, h = screw_head_t + 0.01);
}

// --- モジュール: ナックル(単体) ---
module knuckle_part(y_offset) {
    translate([0, y_offset, 0])
    rotate([-90, 0, 0])
    difference() {
        cylinder(d = knuckle_od, h = seg_h);
        translate([0, 0, -0.5])
            cylinder(d = knuckle_id, h = seg_h + 1);
    }
}

// --- 1. 左板 (Left Leaf) ---
color("silver")
difference() {
    union() {
        // 板部分 (X < 0)
        translate([-leaf_w - knuckle_od/2, 0, -leaf_t])
            cube([leaf_w, leaf_h, leaf_t]);
        // ナックル部分 (1, 3, 5番目)
        for (i = [0, 2, 4]) {
            knuckle_part(i * seg_h);
        }
    }
    // ネジ穴 (3個)
    for (i = [0:2]) {
        translate([-hole_x_pos, (leaf_h - (2 * hole_pitch))/2 + i * hole_pitch, 0])
            screw_hole();
    }
}

// --- 2. 右板 (Right Leaf) ---
color("lightgray")
difference() {
    union() {
        // 板部分 (X > 0)
        translate([knuckle_od/2, 0, -leaf_t])
            cube([leaf_w, leaf_h, leaf_t]);
        // ナックル部分 (2, 4番目)
        for (i = [1, 3]) {
            knuckle_part(i * seg_h);
        }
    }
    // ネジ穴 (3個)
    for (i = [0:2]) {
        translate([hole_x_pos, (leaf_h - (2 * hole_pitch))/2 + i * hole_pitch, 0])
            screw_hole();
    }
}

// --- 3. ピン軸 (Pin) ---
color("gray")
translate([0, (leaf_h - pin_l)/2, 0]) // Y方向に中心合わせ (-1mmから31mm)
rotate([-90, 0, 0])
cylinder(d = pin_d, h = pin_l);
パラメータ (13)
スライダを動かすと 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 success
off
5.5s · 515/768t · $0.0021
SCAD (81 lines)
// 家具用小型バット蝶番 (Butt Hinge)
$fn = 64;

// パラメータ
leaf_w = 25;      // 板の幅
leaf_h = 30;      // 板の高さ
leaf_t = 2;       // 板の厚み
knuckle_od = 8;   // ナックル外径
pin_d = 4;        // ピン直径
clearance = 0.3;  // ピン穴のクリアランス
knuckle_h = leaf_h / 5; // ナックル1個の高さ (6mm)

pin_len = 32;     // ピンの長さ

// ピン軸
module pin() {
    color("Silver")
    translate([0, -1, 0])
    rotate([-90, 0, 0])
    cylinder(d = pin_d, h = pin_len);
}

// 皿穴 (M3用)
module screw_hole() {
    // 貫通穴
    cylinder(d = 3.2, h = leaf_t * 3, center = true);
    // 皿部分 (表面 Z=leaf_t/2 から下へ)
    translate([0, 0, leaf_t/2 - 1])
    cylinder(d1 = 3.2, d2 = 6, h = 1.01);
}

// 板とナックルの基本形状
module leaf_part(is_left = true) {
    knuckle_indices = is_left ? [0, 2, 4] : [1, 3];
    
    difference() {
        union() {
            // 板部分
            if (is_left) {
                translate([-leaf_w, 0, -leaf_t/2])
                cube([leaf_w, leaf_h, leaf_t]);
            } else {
                translate([0, 0, -leaf_t/2])
                cube([leaf_w, leaf_h, leaf_t]);
            }
            
            // ナックル部分
            for (i = knuckle_indices) {
                translate([0, i * knuckle_h, 0])
                rotate([-90, 0, 0])
                cylinder(d = knuckle_od, h = knuckle_h);
            }
        }
        
        // ピン穴
        rotate([-90, 0, 0])
        translate([0, 0, -1])
        cylinder(d = pin_d + clearance, h = leaf_h + 2);
        
        // 皿穴の配置 (ナックルから離れた側)
        hole_x = is_left ? -leaf_w + 6 : leaf_w - 6;
        for (y_offset = [-8, 0, 8]) {
            translate([hole_x, leaf_h/2 + y_offset, 0])
            screw_hole();
        }
    }
}

// 組み立て
union() {
    // 左板
    color("LightGrey")
    leaf_part(is_left = true);
    
    // 右板
    color("DarkGray")
    leaf_part(is_left = false);
    
    // ピン
    pin();
}
adaptivenot run
dynamic (default) success
dynamic
23.2s · 515/956t · $0.0025
SCAD (83 lines)
$fn = 64;

// --- パラメータ設定 ---
leaf_w = 25;           // 板の幅
leaf_h = 30;           // 板の高さ(縦)
leaf_t = 2;            // 板の厚み
pin_d = 4;             // ピン直径
pin_l = 32;            // ピン長さ
knuckle_od = 8;        // ナックル外径
knuckle_id = 4.6;      // ナックル内径 (4mm + 0.3mm clearance x 2)
knuckle_segments = 5;  // 分割数
seg_h = leaf_h / knuckle_segments; // 1区画の長さ(6mm)

screw_d = 3.2;         // M3貫通穴径
screw_head_d = 6;      // 皿穴表面径
screw_head_t = 1;      // 皿穴テーパ深さ
hole_pitch = 8;        // 穴の間隔
hole_x_pos = 18;       // ピン中心からの穴のX位置

// --- モジュール: 皿穴 ---
module screw_hole() {
    // 貫通穴
    translate([0, 0, -leaf_t - 0.5])
        cylinder(d = screw_d, h = leaf_t + 1);
    // 皿取りテーパ部
    translate([0, 0, -screw_head_t])
        cylinder(d1 = screw_d, d2 = screw_head_d, h = screw_head_t + 0.01);
}

// --- モジュール: ナックル(単体) ---
module knuckle_part(y_offset) {
    translate([0, y_offset, 0])
    rotate([-90, 0, 0])
    difference() {
        cylinder(d = knuckle_od, h = seg_h);
        translate([0, 0, -0.5])
            cylinder(d = knuckle_id, h = seg_h + 1);
    }
}

// --- 1. 左板 (Left Leaf) ---
color("silver")
difference() {
    union() {
        // 板部分 (X < 0)
        translate([-leaf_w - knuckle_od/2, 0, -leaf_t])
            cube([leaf_w, leaf_h, leaf_t]);
        // ナックル部分 (1, 3, 5番目)
        for (i = [0, 2, 4]) {
            knuckle_part(i * seg_h);
        }
    }
    // ネジ穴 (3個)
    for (i = [0:2]) {
        translate([-hole_x_pos, (leaf_h - (2 * hole_pitch))/2 + i * hole_pitch, 0])
            screw_hole();
    }
}

// --- 2. 右板 (Right Leaf) ---
color("lightgray")
difference() {
    union() {
        // 板部分 (X > 0)
        translate([knuckle_od/2, 0, -leaf_t])
            cube([leaf_w, leaf_h, leaf_t]);
        // ナックル部分 (2, 4番目)
        for (i = [1, 3]) {
            knuckle_part(i * seg_h);
        }
    }
    // ネジ穴 (3個)
    for (i = [0:2]) {
        translate([hole_x_pos, (leaf_h - (2 * hole_pitch))/2 + i * hole_pitch, 0])
            screw_hole();
    }
}

// --- 3. ピン軸 (Pin) ---
color("gray")
translate([0, (leaf_h - pin_l)/2, 0]) // Y方向に中心合わせ (-1mmから31mm)
rotate([-90, 0, 0])
cylinder(d = pin_d, h = pin_l);

iteration: iter-png

i1 success
iter 1
23.9s · 2603/1265t · $0.0039
diff vs bare: +60/-43
- $fn = 64;
+ /*
+   家具用小型バット蝶番 (Butt Hinge)
+   - 板サイズ: 30mm(H) x 25mm(W) x 2mm(T)
+   - ピン: φ4mm x 32mm
+   - ナックル: 外径8mm, 5分割
+ */
  
- // --- パラメータ設定 ---
- leaf_w = 25;           // 板の幅
- leaf_h = 30;           // 板の高さ(縦)
- leaf_t = 2;            // 板の厚み
- pin_d = 4;             // ピン直径
- pin_l = 32;            // ピン長さ
- knuckle_od = 8;        // ナックル外径
- knuckle_id = 4.6;      // ナックル内径 (4mm + 0.3mm clearance x 2)
- knuckle_segments = 5;  // 分割数
- seg_h = leaf_h / knuckle_segments; // 1区画の長さ(6mm)
+ $fn = 100;
  
- screw_d = 3.2;         // M3貫通穴径
- screw_head_d = 6;      // 皿穴表面径
- screw_head_t = 1;      // 皿穴テーパ深さ
- hole_pitch = 8;        // 穴の間隔
- hole_x_pos = 18;       // ピン中心からの穴のX位置
+ // --- パラメータ ---
+ leaf_h = 30;          // 縦
+ leaf_w = 25;          // 横幅
+ leaf_t = 2;           // 厚み
+ pin_d = 4;            // ピン径
+ pin_l = 32;           // ピン長さ
+ knuckle_od = 8;       // ナックル外径
+ knuckle_id = 4.6;     // ナックル内径(クリアランス込)
+ segments = 5;         // ナックル分割数
+ seg_h = leaf_h / segments; // 6mm
  
- // --- モジュール: 皿穴 ---
- module screw_hole() {
+ screw_d = 3.2;        // M3貫通穴
+ screw_head_d = 6;     // 皿穴径
+ screw_head_t = 1;     // 皿穴深さ
+ hole_pitch = 8;       // 穴ピッチ
+ hole_x_offset = 17;   // ピン中心から穴までの距離
+ 
+ // --- 皿穴モジュール ---
+ module countersink_hole() {
      // 貫通穴
-     translate([0, 0, -leaf_t - 0.5])
-         cylinder(d = screw_d, h = leaf_t + 1);
-     // 皿取りテーパ部
+     translate([0, 0, -leaf_t - 1])
+         cylinder(d = screw_d, h = leaf_t + 2);
+     // 皿取り部 (表面Z=0から下へ)
      translate([0, 0, -screw_head_t])
          cylinder(d1 = screw_d, d2 = screw_head_d, h = screw_head_t + 0.01);
  }
  
- // --- モジュール: ナックル(単体) ---
- module knuckle_part(y_offset) {
-     translate([0, y_offset, 0])
+ // --- ナックル単体モジュール ---
+ module knuckle_seg(y_pos) {
+     translate([0, y_pos, 0])
      rotate([-90, 0, 0])
      difference() {
          cylinder(d = knuckle_od, h = seg_h);
          translate([0, 0, -0.5])
              cylinder(d = knuckle_id, h = seg_h + 1);
      }
  }
  
- // --- 1. 左板 (Left Leaf) ---
+ // --- 左板 (Left Leaf: 3ナックル) ---
  color("silver")
  difference() {
      union() {
-         // 板部分 (X < 0)
-         translate([-leaf_w - knuckle_od/2, 0, -leaf_t])
+         // 板本体: X=0(中心)から左へ25mm。厚み方向は上面をZ=0に
+         translate([-leaf_w, 0, -leaf_t])
              cube([leaf_w, leaf_h, leaf_t]);
-         // ナックル部分 (1, 3, 5番目)
+         // ナックル (1, 3, 5番目)
          for (i = [0, 2, 4]) {
-             knuckle_part(i * seg_h);
+             knuckle_seg(i * seg_h);
          }
      }
-     // ネジ穴 (3個)
+     // ピン穴の逃げ(念のため中央を再カット)
+     rotate([-90, 0, 0]) translate([0, 0, -1])
+         cylinder(d = knuckle_id, h = leaf_h + 2);
+     
+     // 皿穴 3つ
      for (i = [0:2]) {
-         translate([-hole_x_pos, (leaf_h - (2 * hole_pitch))/2 + i * hole_pitch, 0])
-             screw_hole();
+         y = (leaf_h - (2 * hole_pitch)) / 2 + i * hole_pitch;
+         translate([-hole_x_offset, y, 0])
+             countersink_hole();
      }
  }
  
- // --- 2. 右板 (Right Leaf) ---
+ // --- 右板 (Right Leaf: 2ナックル) ---
  color("lightgray")
  difference() {
      union() {
-         // 板部分 (X > 0)
-         translate([knuckle_od/2, 0, -leaf_t])
+         // 板本体: X=0から右へ25mm
+         translate([0, 0, -leaf_t])
              cube([leaf_w, leaf_h, leaf_t]);
-         // ナックル部分 (2, 4番目)
+         // ナックル (2, 4番目)
          for (i = [1, 3]) {
-             knuckle_part(i * seg_h);
+             knuckle_seg(i * seg_h);
          }
      }
-     // ネジ穴 (3個)
+     // ピン穴の逃げ
+     rotate([-90, 0, 0]) translate([0, 0, -1])
+         cylinder(d = knuckle_id, h = leaf_h + 2);
+ 
+     // 皿穴 3つ
      for (i = [0:2]) {
-         translate([hole_x_pos, (leaf_h - (2 * hole_pitch))/2 + i * hole_pitch, 0])
-             screw_hole();
+         y = (leaf_h - (2 * hole_pitch)) / 2 + i * hole_pitch;
+         translate([hole_x_offset, y, 0])
+             countersink_hole();
      }
  }
  
- // --- 3. ピン軸 (Pin) ---
- color("gray")
- translate([0, (leaf_h - pin_l)/2, 0]) // Y方向に中心合わせ (-1mmから31mm)
+ // --- ピン軸 (Pin) ---
+ color("dimgray")
+ translate([0, (leaf_h - pin_l) / 2, 0]) // 30mm高に対して32mm長を中央配置
  rotate([-90, 0, 0])
  cylinder(d = pin_d, h = pin_l);
SCAD (100 lines)
/*
  家具用小型バット蝶番 (Butt Hinge)
  - 板サイズ: 30mm(H) x 25mm(W) x 2mm(T)
  - ピン: φ4mm x 32mm
  - ナックル: 外径8mm, 5分割
*/

$fn = 100;

// --- パラメータ ---
leaf_h = 30;          // 縦
leaf_w = 25;          // 横幅
leaf_t = 2;           // 厚み
pin_d = 4;            // ピン径
pin_l = 32;           // ピン長さ
knuckle_od = 8;       // ナックル外径
knuckle_id = 4.6;     // ナックル内径(クリアランス込)
segments = 5;         // ナックル分割数
seg_h = leaf_h / segments; // 6mm

screw_d = 3.2;        // M3貫通穴
screw_head_d = 6;     // 皿穴径
screw_head_t = 1;     // 皿穴深さ
hole_pitch = 8;       // 穴ピッチ
hole_x_offset = 17;   // ピン中心から穴までの距離

// --- 皿穴モジュール ---
module countersink_hole() {
    // 貫通穴
    translate([0, 0, -leaf_t - 1])
        cylinder(d = screw_d, h = leaf_t + 2);
    // 皿取り部 (表面Z=0から下へ)
    translate([0, 0, -screw_head_t])
        cylinder(d1 = screw_d, d2 = screw_head_d, h = screw_head_t + 0.01);
}

// --- ナックル単体モジュール ---
module knuckle_seg(y_pos) {
    translate([0, y_pos, 0])
    rotate([-90, 0, 0])
    difference() {
        cylinder(d = knuckle_od, h = seg_h);
        translate([0, 0, -0.5])
            cylinder(d = knuckle_id, h = seg_h + 1);
    }
}

// --- 左板 (Left Leaf: 3ナックル) ---
color("silver")
difference() {
    union() {
        // 板本体: X=0(中心)から左へ25mm。厚み方向は上面をZ=0に
        translate([-leaf_w, 0, -leaf_t])
            cube([leaf_w, leaf_h, leaf_t]);
        // ナックル (1, 3, 5番目)
        for (i = [0, 2, 4]) {
            knuckle_seg(i * seg_h);
        }
    }
    // ピン穴の逃げ(念のため中央を再カット)
    rotate([-90, 0, 0]) translate([0, 0, -1])
        cylinder(d = knuckle_id, h = leaf_h + 2);
    
    // 皿穴 3つ
    for (i = [0:2]) {
        y = (leaf_h - (2 * hole_pitch)) / 2 + i * hole_pitch;
        translate([-hole_x_offset, y, 0])
            countersink_hole();
    }
}

// --- 右板 (Right Leaf: 2ナックル) ---
color("lightgray")
difference() {
    union() {
        // 板本体: X=0から右へ25mm
        translate([0, 0, -leaf_t])
            cube([leaf_w, leaf_h, leaf_t]);
        // ナックル (2, 4番目)
        for (i = [1, 3]) {
            knuckle_seg(i * seg_h);
        }
    }
    // ピン穴の逃げ
    rotate([-90, 0, 0]) translate([0, 0, -1])
        cylinder(d = knuckle_id, h = leaf_h + 2);

    // 皿穴 3つ
    for (i = [0:2]) {
        y = (leaf_h - (2 * hole_pitch)) / 2 + i * hole_pitch;
        translate([hole_x_offset, y, 0])
            countersink_hole();
    }
}

// --- ピン軸 (Pin) ---
color("dimgray")
translate([0, (leaf_h - pin_l) / 2, 0]) // 30mm高に対して32mm長を中央配置
rotate([-90, 0, 0])
cylinder(d = pin_d, h = pin_l);
i2 success
iter 2
42.1s · 2791/1257t · $0.0040
diff vs i1: +58/-73
  /*
-   家具用小型バット蝶番 (Butt Hinge)
-   - 板サイズ: 30mm(H) x 25mm(W) x 2mm(T)
-   - ピン: φ4mm x 32mm
-   - ナックル: 外径8mm, 5分割
+   家具用小型バット蝶番 (Butt Hinge) - 完成版
+   寸法: 板 30x25x2mm, ピン φ4x32mm, ナックル φ8mm (5分割)
  */
  
  $fn = 100;
  
- // --- パラメータ ---
- leaf_h = 30;          // 縦
- leaf_w = 25;          // 横幅
- leaf_t = 2;           // 厚み
- pin_d = 4;            // ピン径
- pin_l = 32;           // ピン長さ
- knuckle_od = 8;       // ナックル外径
- knuckle_id = 4.6;     // ナックル内径(クリアランス込)
- segments = 5;         // ナックル分割数
- seg_h = leaf_h / segments; // 6mm
+ // --- パラメータ設定 ---
+ leaf_h = 30;          // 縦(ヒンジ軸方向)
+ leaf_w = 25;          // 横(展開方向)
+ leaf_t = 2;           // 板厚
+ pin_d = 4;            // ピンの直径
+ pin_l = 32;           // ピンの全長
+ knuckle_od = 8;       // ナックルの外径
+ knuckle_id = 4.6;     // ナックルの内径(ピン4mm + クリアランス0.3mmx2)
+ segments = 5;         // ナックルの分割数
+ seg_h = leaf_h / segments; // 1区画あたりの高さ (6mm)
  
- screw_d = 3.2;        // M3貫通穴
+ screw_d = 3.2;        // M3貫通穴径
  screw_head_d = 6;     // 皿穴径
  screw_head_t = 1;     // 皿穴深さ
- hole_pitch = 8;       // 穴ピッチ
- hole_x_offset = 17;   // ピン中心から穴までの距離
+ hole_pitch = 8;       // 穴の間隔
+ hole_x_offset = 17;   // ピン中心から穴中心までの距離
  
- // --- 皿穴モジュール ---
+ // --- モジュール: 皿穴 (表面Z=0から削り取る) ---
  module countersink_hole() {
      // 貫通穴
      translate([0, 0, -leaf_t - 1])
          cylinder(d = screw_d, h = leaf_t + 2);
-     // 皿取り部 (表面Z=0から下へ)
+     // 皿取りテーパー部
      translate([0, 0, -screw_head_t])
-         cylinder(d1 = screw_d, d2 = screw_head_d, h = screw_head_t + 0.01);
+         cylinder(d1 = screw_d, d2 = screw_head_d, h = screw_head_t + 0.001);
  }
  
- // --- ナックル単体モジュール ---
- module knuckle_seg(y_pos) {
-     translate([0, y_pos, 0])
-     rotate([-90, 0, 0])
+ // --- モジュール: 蝶番の板 (左右共通の基盤) ---
+ module leaf_base(side="left") {
      difference() {
-         cylinder(d = knuckle_od, h = seg_h);
-         translate([0, 0, -0.5])
-             cylinder(d = knuckle_id, h = seg_h + 1);
-     }
- }
- 
- // --- 左板 (Left Leaf: 3ナックル) ---
- color("silver")
- difference() {
-     union() {
-         // 板本体: X=0(中心)から左へ25mm。厚み方向は上面をZ=0に
-         translate([-leaf_w, 0, -leaf_t])
-             cube([leaf_w, leaf_h, leaf_t]);
-         // ナックル (1, 3, 5番目)
-         for (i = [0, 2, 4]) {
-             knuckle_seg(i * seg_h);
+         union() {
+             // 板本体
+             if (side == "left") {
+                 translate([-leaf_w, 0, -leaf_t]) cube([leaf_w, leaf_h, leaf_t]);
+             } else {
+                 translate([0, 0, -leaf_t]) cube([leaf_w, leaf_h, leaf_t]);
+             }
+             
+             // ナックル部分(指定された位置に配置)
+             for (i = [0 : segments - 1]) {
+                 // 左板は 0, 2, 4番目 / 右板は 1, 3番目
+                 assign_left = (i % 2 == 0);
+                 if ((side == "left" && assign_left) || (side == "right" && !assign_left)) {
+                     translate([0, i * seg_h, 0])
+                     rotate([-90, 0, 0])
+                     cylinder(d = knuckle_od, h = seg_h);
+                 }
+             }
          }
-     }
-     // ピン穴の逃げ(念のため中央を再カット)
-     rotate([-90, 0, 0]) translate([0, 0, -1])
+         
+         // ピンを通す中心穴(一括で中空にする)
+         rotate([-90, 0, 0])
+         translate([0, 0, -1])
          cylinder(d = knuckle_id, h = leaf_h + 2);
-     
-     // 皿穴 3つ
-     for (i = [0:2]) {
-         y = (leaf_h - (2 * hole_pitch)) / 2 + i * hole_pitch;
-         translate([-hole_x_offset, y, 0])
-             countersink_hole();
+         
+         // 皿穴 3個の配置
+         for (i = [0:2]) {
+             y_pos = (leaf_h - (2 * hole_pitch)) / 2 + i * hole_pitch;
+             x_pos = (side == "left") ? -hole_x_offset : hole_x_offset;
+             translate([x_pos, y_pos, 0])
+                 countersink_hole();
+         }
      }
  }
  
- // --- 右板 (Right Leaf: 2ナックル) ---
+ // --- 配置: 左板 (Left Leaf) ---
+ color("silver")
+ leaf_base(side="left");
+ 
+ // --- 配置: 右板 (Right Leaf) ---
  color("lightgray")
- difference() {
-     union() {
-         // 板本体: X=0から右へ25mm
-         translate([0, 0, -leaf_t])
-             cube([leaf_w, leaf_h, leaf_t]);
-         // ナックル (2, 4番目)
-         for (i = [1, 3]) {
-             knuckle_seg(i * seg_h);
-         }
-     }
-     // ピン穴の逃げ
-     rotate([-90, 0, 0]) translate([0, 0, -1])
-         cylinder(d = knuckle_id, h = leaf_h + 2);
+ leaf_base(side="right");
  
-     // 皿穴 3つ
-     for (i = [0:2]) {
-         y = (leaf_h - (2 * hole_pitch)) / 2 + i * hole_pitch;
-         translate([hole_x_offset, y, 0])
-             countersink_hole();
-     }
- }
- 
- // --- ピン軸 (Pin) ---
+ // --- 配置: ピン軸 (Pin) ---
  color("dimgray")
- translate([0, (leaf_h - pin_l) / 2, 0]) // 30mm高に対して32mm長を中央配置
+ translate([0, (leaf_h - pin_l) / 2, 0]) // 30mm高に対して32mmを中央寄せ
  rotate([-90, 0, 0])
  cylinder(d = pin_d, h = pin_l);
SCAD (85 lines)
/*
  家具用小型バット蝶番 (Butt Hinge) - 完成版
  寸法: 板 30x25x2mm, ピン φ4x32mm, ナックル φ8mm (5分割)
*/

$fn = 100;

// --- パラメータ設定 ---
leaf_h = 30;          // 縦(ヒンジ軸方向)
leaf_w = 25;          // 横(展開方向)
leaf_t = 2;           // 板厚
pin_d = 4;            // ピンの直径
pin_l = 32;           // ピンの全長
knuckle_od = 8;       // ナックルの外径
knuckle_id = 4.6;     // ナックルの内径(ピン4mm + クリアランス0.3mmx2)
segments = 5;         // ナックルの分割数
seg_h = leaf_h / segments; // 1区画あたりの高さ (6mm)

screw_d = 3.2;        // M3貫通穴径
screw_head_d = 6;     // 皿穴径
screw_head_t = 1;     // 皿穴深さ
hole_pitch = 8;       // 穴の間隔
hole_x_offset = 17;   // ピン中心から穴中心までの距離

// --- モジュール: 皿穴 (表面Z=0から削り取る) ---
module countersink_hole() {
    // 貫通穴
    translate([0, 0, -leaf_t - 1])
        cylinder(d = screw_d, h = leaf_t + 2);
    // 皿取りテーパー部
    translate([0, 0, -screw_head_t])
        cylinder(d1 = screw_d, d2 = screw_head_d, h = screw_head_t + 0.001);
}

// --- モジュール: 蝶番の板 (左右共通の基盤) ---
module leaf_base(side="left") {
    difference() {
        union() {
            // 板本体
            if (side == "left") {
                translate([-leaf_w, 0, -leaf_t]) cube([leaf_w, leaf_h, leaf_t]);
            } else {
                translate([0, 0, -leaf_t]) cube([leaf_w, leaf_h, leaf_t]);
            }
            
            // ナックル部分(指定された位置に配置)
            for (i = [0 : segments - 1]) {
                // 左板は 0, 2, 4番目 / 右板は 1, 3番目
                assign_left = (i % 2 == 0);
                if ((side == "left" && assign_left) || (side == "right" && !assign_left)) {
                    translate([0, i * seg_h, 0])
                    rotate([-90, 0, 0])
                    cylinder(d = knuckle_od, h = seg_h);
                }
            }
        }
        
        // ピンを通す中心穴(一括で中空にする)
        rotate([-90, 0, 0])
        translate([0, 0, -1])
        cylinder(d = knuckle_id, h = leaf_h + 2);
        
        // 皿穴 3個の配置
        for (i = [0:2]) {
            y_pos = (leaf_h - (2 * hole_pitch)) / 2 + i * hole_pitch;
            x_pos = (side == "left") ? -hole_x_offset : hole_x_offset;
            translate([x_pos, y_pos, 0])
                countersink_hole();
        }
    }
}

// --- 配置: 左板 (Left Leaf) ---
color("silver")
leaf_base(side="left");

// --- 配置: 右板 (Right Leaf) ---
color("lightgray")
leaf_base(side="right");

// --- 配置: ピン軸 (Pin) ---
color("dimgray")
translate([0, (leaf_h - pin_l) / 2, 0]) // 30mm高に対して32mmを中央寄せ
rotate([-90, 0, 0])
cylinder(d = pin_d, h = pin_l);
i3 success
iter 3
36.6s · 2677/1244t · $0.0039
diff vs i2: +0/-0
  /*
    家具用小型バット蝶番 (Butt Hinge) - 完成版
    寸法: 板 30x25x2mm, ピン φ4x32mm, ナックル φ8mm (5分割)
  */
  
  $fn = 100;
  
  // --- パラメータ設定 ---
  leaf_h = 30;          // 縦(ヒンジ軸方向)
  leaf_w = 25;          // 横(展開方向)
  leaf_t = 2;           // 板厚
  pin_d = 4;            // ピンの直径
  pin_l = 32;           // ピンの全長
  knuckle_od = 8;       // ナックルの外径
  knuckle_id = 4.6;     // ナックルの内径(ピン4mm + クリアランス0.3mmx2)
  segments = 5;         // ナックルの分割数
  seg_h = leaf_h / segments; // 1区画あたりの高さ (6mm)
  
  screw_d = 3.2;        // M3貫通穴径
  screw_head_d = 6;     // 皿穴径
  screw_head_t = 1;     // 皿穴深さ
  hole_pitch = 8;       // 穴の間隔
  hole_x_offset = 17;   // ピン中心から穴中心までの距離
  
  // --- モジュール: 皿穴 (表面Z=0から削り取る) ---
  module countersink_hole() {
      // 貫通穴
      translate([0, 0, -leaf_t - 1])
          cylinder(d = screw_d, h = leaf_t + 2);
      // 皿取りテーパー部
      translate([0, 0, -screw_head_t])
          cylinder(d1 = screw_d, d2 = screw_head_d, h = screw_head_t + 0.001);
  }
  
  // --- モジュール: 蝶番の板 (左右共通の基盤) ---
  module leaf_base(side="left") {
      difference() {
          union() {
              // 板本体
              if (side == "left") {
                  translate([-leaf_w, 0, -leaf_t]) cube([leaf_w, leaf_h, leaf_t]);
              } else {
                  translate([0, 0, -leaf_t]) cube([leaf_w, leaf_h, leaf_t]);
              }
              
              // ナックル部分(指定された位置に配置)
              for (i = [0 : segments - 1]) {
                  // 左板は 0, 2, 4番目 / 右板は 1, 3番目
                  assign_left = (i % 2 == 0);
                  if ((side == "left" && assign_left) || (side == "right" && !assign_left)) {
                      translate([0, i * seg_h, 0])
                      rotate([-90, 0, 0])
                      cylinder(d = knuckle_od, h = seg_h);
                  }
              }
          }
          
          // ピンを通す中心穴(一括で中空にする)
          rotate([-90, 0, 0])
          translate([0, 0, -1])
          cylinder(d = knuckle_id, h = leaf_h + 2);
          
          // 皿穴 3個の配置
          for (i = [0:2]) {
              y_pos = (leaf_h - (2 * hole_pitch)) / 2 + i * hole_pitch;
              x_pos = (side == "left") ? -hole_x_offset : hole_x_offset;
              translate([x_pos, y_pos, 0])
                  countersink_hole();
          }
      }
  }
  
  // --- 配置: 左板 (Left Leaf) ---
  color("silver")
  leaf_base(side="left");
  
  // --- 配置: 右板 (Right Leaf) ---
  color("lightgray")
  leaf_base(side="right");
  
  // --- 配置: ピン軸 (Pin) ---
  color("dimgray")
  translate([0, (leaf_h - pin_l) / 2, 0]) // 30mm高に対して32mmを中央寄せ
  rotate([-90, 0, 0])
  cylinder(d = pin_d, h = pin_l);
SCAD (85 lines)
/*
  家具用小型バット蝶番 (Butt Hinge) - 完成版
  寸法: 板 30x25x2mm, ピン φ4x32mm, ナックル φ8mm (5分割)
*/

$fn = 100;

// --- パラメータ設定 ---
leaf_h = 30;          // 縦(ヒンジ軸方向)
leaf_w = 25;          // 横(展開方向)
leaf_t = 2;           // 板厚
pin_d = 4;            // ピンの直径
pin_l = 32;           // ピンの全長
knuckle_od = 8;       // ナックルの外径
knuckle_id = 4.6;     // ナックルの内径(ピン4mm + クリアランス0.3mmx2)
segments = 5;         // ナックルの分割数
seg_h = leaf_h / segments; // 1区画あたりの高さ (6mm)

screw_d = 3.2;        // M3貫通穴径
screw_head_d = 6;     // 皿穴径
screw_head_t = 1;     // 皿穴深さ
hole_pitch = 8;       // 穴の間隔
hole_x_offset = 17;   // ピン中心から穴中心までの距離

// --- モジュール: 皿穴 (表面Z=0から削り取る) ---
module countersink_hole() {
    // 貫通穴
    translate([0, 0, -leaf_t - 1])
        cylinder(d = screw_d, h = leaf_t + 2);
    // 皿取りテーパー部
    translate([0, 0, -screw_head_t])
        cylinder(d1 = screw_d, d2 = screw_head_d, h = screw_head_t + 0.001);
}

// --- モジュール: 蝶番の板 (左右共通の基盤) ---
module leaf_base(side="left") {
    difference() {
        union() {
            // 板本体
            if (side == "left") {
                translate([-leaf_w, 0, -leaf_t]) cube([leaf_w, leaf_h, leaf_t]);
            } else {
                translate([0, 0, -leaf_t]) cube([leaf_w, leaf_h, leaf_t]);
            }
            
            // ナックル部分(指定された位置に配置)
            for (i = [0 : segments - 1]) {
                // 左板は 0, 2, 4番目 / 右板は 1, 3番目
                assign_left = (i % 2 == 0);
                if ((side == "left" && assign_left) || (side == "right" && !assign_left)) {
                    translate([0, i * seg_h, 0])
                    rotate([-90, 0, 0])
                    cylinder(d = knuckle_od, h = seg_h);
                }
            }
        }
        
        // ピンを通す中心穴(一括で中空にする)
        rotate([-90, 0, 0])
        translate([0, 0, -1])
        cylinder(d = knuckle_id, h = leaf_h + 2);
        
        // 皿穴 3個の配置
        for (i = [0:2]) {
            y_pos = (leaf_h - (2 * hole_pitch)) / 2 + i * hole_pitch;
            x_pos = (side == "left") ? -hole_x_offset : hole_x_offset;
            translate([x_pos, y_pos, 0])
                countersink_hole();
        }
    }
}

// --- 配置: 左板 (Left Leaf) ---
color("silver")
leaf_base(side="left");

// --- 配置: 右板 (Right Leaf) ---
color("lightgray")
leaf_base(side="right");

// --- 配置: ピン軸 (Pin) ---
color("dimgray")
translate([0, (leaf_h - pin_l) / 2, 0]) // 30mm高に対して32mmを中央寄せ
rotate([-90, 0, 0])
cylinder(d = pin_d, h = pin_l);