vibe-openscad

tier-3-butt-hinge / claude-opus-5

7 run / 累計 777.6s / 累計 $1.61

claude opus 5 bare

bare (provider default effort)

run detail →
render
bare render of tier-3-butt-hinge
loading STL…
success 71.8s · 743/5885t · $0.1508
SCAD (111 lines)
// =====================================================
//  家具用 小型バット蝶番 (butt hinge)  -- 180°開いた状態
//  ・左板 (x<0) / 右板 (x>0) / ピン軸 (Y軸上)
// =====================================================

$fn = 96;

// ---------------- パラメータ ----------------
leaf_w   = 25;              // 板の横幅(開く方向)
leaf_l   = 30;              // 板の縦(ヒンジ軸方向)
leaf_t   = 2;               // 板厚

pin_d    = 4;               // ピン軸径
pin_len  = 32;              // ピン軸長(両端 1mm ずつ突出)

knu_od   = 8;               // knuckle 外径
pin_clr  = 0.3;             // ピンとのクリアランス
knu_id   = pin_d + pin_clr; // 4.6mm 穴

seg      = leaf_l / 5;      // 6mm × 5 等分
ax_gap   = 0.1;             // knuckle 軸方向クリアランス(片側)
rad_clr  = 0.2;             // 相手 knuckle 逃げの半径クリアランス

left_segs  = [0, 2, 4];     // 左板: 外側2個 + 中央1個
right_segs = [1, 3];        // 右板: 中間2個

screw_pitch = 8;            // ネジ穴ピッチ(Y方向)
screw_d     = 3.2;          // 貫通穴径
cs_d        = 6;            // 皿穴径
cs_depth    = 1;            // 皿深さ
screw_x     = 17;           // ピン軸からのネジ穴距離

eps = 0.01;

// ---------------- ヘルパ ----------------
// Y 軸方向の円柱(y0 -> y1)
module ycyl(d, y0, y1) {
    translate([0, y0, 0])
        rotate([-90, 0, 0])
            cylinder(d = d, h = y1 - y0);
}

function seg_y0(i) = -leaf_l/2 + i * seg;
function seg_y1(i) = -leaf_l/2 + (i + 1) * seg;

// M3 皿穴(+Z 面が表)
module countersunk_hole() {
    // 貫通穴
    translate([0, 0, -leaf_t/2 - 1])
        cylinder(d = screw_d, h = leaf_t + 2);
    // テーパ(表面 φ6 → 深さ1で φ3.2)
    translate([0, 0, leaf_t/2 - cs_depth])
        cylinder(d1 = screw_d, d2 = cs_d, h = cs_depth + eps);
    // 表面より上の逃げ
    translate([0, 0, leaf_t/2 - eps])
        cylinder(d = cs_d, h = 1);
}

// ---------------- 板本体(-X 方向に伸びる基本形) ----------------
module hinge_leaf(my_segs, other_segs) {
    difference() {
        union() {
            // 平板
            translate([-leaf_w, -leaf_l/2, -leaf_t/2])
                cube([leaf_w, leaf_l, leaf_t]);
            // 自分の knuckle
            for (i = my_segs)
                ycyl(knu_od, seg_y0(i), seg_y1(i));
        }

        // 相手 knuckle の逃げ(軸方向・半径方向クリアランス込み)
        for (i = other_segs)
            ycyl(knu_od + 2 * rad_clr,
                 seg_y0(i) - ax_gap,
                 seg_y1(i) + ax_gap);

        // ピン穴(全長貫通)
        ycyl(knu_id, -leaf_l, leaf_l);

        // M3 皿穴 ×3
        for (k = [-1, 0, 1])
            translate([-screw_x, k * screw_pitch, 0])
                countersunk_hole();
    }
}

// ---------------- 各パーツ ----------------
module left_leaf() {
    color("Silver")
        hinge_leaf(left_segs, right_segs);
}

module right_leaf() {
    color("LightSteelBlue")
        mirror([1, 0, 0])
            hinge_leaf(right_segs, left_segs);
}

module hinge_pin() {
    color("DimGray")
        ycyl(pin_d, -pin_len/2, pin_len/2);
}

// ---------------- 組み立て(180° 開) ----------------
module butt_hinge() {
    left_leaf();
    right_leaf();
    hinge_pin();
}

butt_hinge();
パラメータ (15) —
スライダを動かすと 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
24.6s · 743/1915t · $0.0516
SCAD (118 lines)
// =====================================================
// 家具用 小型バット蝶番 (butt hinge)  — 180° 開いた状態
//   ・左板 (x<0) : knuckle 3個 (外側2 + 中央1)
//   ・右板 (x>0) : knuckle 2個 (中間2)
//   ・ピン軸     : φ4 x 32mm  (Y軸に一致)
// =====================================================

$fn = 64;

// ---------- パラメータ ----------
LEAF_LEN    = 30;    // ヒンジ軸方向(Y)の長さ
LEAF_WID    = 25;    // 開く方向(X)の幅
LEAF_TH     = 2;     // 板厚

PIN_D       = 4;     // ピン軸径
PIN_LEN     = 32;    // ピン軸長
CLR         = 0.3;   // クリアランス

KN_OD       = 8;             // knuckle 外径
KN_ID       = PIN_D + CLR;   // knuckle 内径 = 4.6
KN_SEG      = LEAF_LEN / 5;  // 6mm
KN_GAP      = 0.2;           // knuckle 同士の Y 方向すきま

SCREW_D     = 3.2;   // 貫通穴
CS_D        = 6;     // 皿穴径
CS_DEPTH    = 1;     // 皿テーパ深さ
HOLE_PITCH  = 8;     // 穴ピッチ(Y方向)
HOLE_X      = 18;    // knuckle 中心からのねじ穴位置(板中心寄り外側)

EPS         = 0.01;

// Y 方向 5 分割の各セグメント中心
function seg_y(i) = -LEAF_LEN/2 + KN_SEG/2 + i*KN_SEG;   // i = 0..4

// ---------- モジュール ----------

// knuckle 1個 (Y方向に長さ len、中心 yc)
module knuckle(yc, len) {
    translate([0, yc - len/2, 0])
        rotate([-90, 0, 0])
            difference() {
                cylinder(h = len, d = KN_OD);
                translate([0, 0, -EPS])
                    cylinder(h = len + 2*EPS, d = KN_ID);
            }
}

// 皿穴 (板の上面 z = +LEAF_TH/2 から見て)
module countersunk_hole() {
    // 貫通穴
    translate([0, 0, -LEAF_TH])
        cylinder(h = LEAF_TH*2, d = SCREW_D);
    // テーパ部(上面から深さ CS_DEPTH)
    translate([0, 0, LEAF_TH/2 - CS_DEPTH])
        cylinder(h = CS_DEPTH, d1 = SCREW_D, d2 = CS_D);
    // 上面より上は逃がし
    translate([0, 0, LEAF_TH/2 - EPS])
        cylinder(h = 2, d = CS_D);
}

// 板 1枚 (+X 方向に伸びる形で作り、必要なら mirror して使う)
//   knuckle_idx : この板が持つ knuckle のセグメント番号リスト
module leaf(knuckle_idx) {
    difference() {
        union() {
            // 平板:X = KN_OD/2 - 1 あたりから外へ伸ばし、
            // knuckle と滑らかに繋げる(接続部を少し重ねる)
            translate([0, -LEAF_LEN/2, -LEAF_TH/2])
                cube([LEAF_WID, LEAF_LEN, LEAF_TH]);

            // knuckle 本体
            for (i = knuckle_idx)
                knuckle(seg_y(i), KN_SEG - KN_GAP);

            // knuckle と板のつなぎ(ウェブ)
            for (i = knuckle_idx)
                translate([0, seg_y(i) - (KN_SEG - KN_GAP)/2, -LEAF_TH/2])
                    cube([KN_OD/2, KN_SEG - KN_GAP, LEAF_TH]);
        }
        // ピン穴(板と重なる部分も貫通させる)
        translate([0, -PIN_LEN, 0])
            rotate([-90, 0, 0])
                cylinder(h = PIN_LEN*2, d = KN_ID);

        // ねじ穴 3個
        for (k = [-1, 0, 1])
            translate([HOLE_X, k * HOLE_PITCH, 0])
                countersunk_hole();
    }
}

// ピン軸
module pin() {
    translate([0, -PIN_LEN/2, 0])
        rotate([-90, 0, 0])
            union() {
                cylinder(h = PIN_LEN, d = PIN_D);
                // 端部の面取り風ヘッド
                cylinder(h = 0.6, d = PIN_D + 0.8);
                translate([0, 0, PIN_LEN - 0.6])
                    cylinder(h = 0.6, d = PIN_D + 0.8);
            }
}

// ---------- アセンブリ(180° 開) ----------

// 左板:knuckle は 外側2個(0,4) + 中央1個(2)
color("Silver")
    mirror([1, 0, 0])
        leaf([0, 2, 4]);

// 右板:knuckle は 中間2個(1,3)
color("LightSteelBlue")
    leaf([1, 3]);

// ピン軸
color("DimGray")
    pin();
mediumnot run
—
high (default) success →
high
20.3s · 743/1832t · $0.0495
SCAD (138 lines)
// ============================================================
//  Small furniture butt hinge (180 deg open)
//  - Left leaf  : x < 0  (3 knuckles: outer 2 + center 1)
//  - Right leaf : x > 0  (2 knuckles: intermediate)
//  - Pin        : along +Y axis, centered on Y axis
// ============================================================

$fn = 96;

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

pin_dia     = 4;
pin_len     = 32;    // 1 mm proud at each end

knuckle_od  = 8;
pin_clear   = 0.3;
knuckle_id  = pin_dia + pin_clear;   // 4.6

seg         = leaf_len / 5;          // 6 mm per segment
gap         = 0.15;                  // small running clearance between knuckles

// countersunk screw holes (M3)
cs_top_dia  = 6;
cs_depth    = 1;
hole_dia    = 3.2;
hole_pitch  = 8;
hole_inset  = 6;     // distance from outer edge of leaf to hole centers

eps         = 0.01;

// Segment centers along Y : -12, -6, 0, 6, 12
function seg_y(i) = -leaf_len/2 + seg/2 + i*seg;   // i = 0..4

// ============================================================
//  Modules
// ============================================================

// One knuckle (tube) segment centred on Y = yc
module knuckle(yc, h) {
    translate([0, yc, 0])
        rotate([-90, 0, 0])
            difference() {
                cylinder(h = h, d = knuckle_od, center = true);
                cylinder(h = h + 1, d = knuckle_id, center = true);
            }
}

// Countersunk hole, drilled from +Z down through the plate
module cs_hole() {
    union() {
        // through hole
        translate([0, 0, -leaf_thk/2 - eps])
            cylinder(h = leaf_thk + 2*eps, d = hole_dia);
        // conical countersink at top face
        translate([0, 0, leaf_thk/2 - cs_depth])
            cylinder(h = cs_depth + eps, d1 = hole_dia, d2 = cs_top_dia);
    }
}

// Plate body extending in +X from the knuckle axis, blended into knuckle OD
module leaf_plate() {
    // main flat plate from x = knuckle_od/2 ... leaf_wid
    translate([knuckle_od/2 - 0.5, -leaf_len/2, -leaf_thk/2])
        cube([leaf_wid - knuckle_od/2 + 0.5, leaf_len, leaf_thk]);
}

// Web that ties the plate to its own knuckle segments
module leaf_web(yc, h) {
    translate([0, yc - h/2, -leaf_thk/2])
        cube([knuckle_od/2, h, leaf_thk]);
}

// Screw hole pattern for one leaf (in local +X leaf coordinates)
module leaf_holes() {
    for (k = [-1, 0, 1])
        translate([leaf_wid - hole_inset, k * hole_pitch, 0])
            cs_hole();
}

// ---- Right leaf : plate in +X, knuckles at segments 1 and 3 ----
module right_leaf() {
    color("Silver")
    difference() {
        union() {
            leaf_plate();
            for (i = [1, 3]) {
                knuckle(seg_y(i), seg - gap);
                leaf_web(seg_y(i), seg - gap);
            }
        }
        leaf_holes();
        // clear the pin bore through everything
        rotate([-90, 0, 0])
            cylinder(h = leaf_len + 20, d = knuckle_id, center = true);
    }
}

// ---- Left leaf : mirrored, knuckles at segments 0, 2 and 4 ----
module left_leaf() {
    color("Silver")
    mirror([1, 0, 0])
    difference() {
        union() {
            leaf_plate();
            for (i = [0, 2, 4]) {
                knuckle(seg_y(i), seg - gap);
                leaf_web(seg_y(i), seg - gap);
            }
        }
        leaf_holes();
        rotate([-90, 0, 0])
            cylinder(h = leaf_len + 20, d = knuckle_id, center = true);
    }
}

// ---- Pin ----
module pin() {
    color("DimGray")
    rotate([-90, 0, 0])
        union() {
            cylinder(h = pin_len, d = pin_dia, center = true);
            // small chamfered heads at both ends
            translate([0, 0,  pin_len/2 - 0.4])
                cylinder(h = 0.4, d1 = pin_dia, d2 = pin_dia - 0.8);
            translate([0, 0, -pin_len/2])
                cylinder(h = 0.4, d1 = pin_dia - 0.8, d2 = pin_dia);
        }
}

// ============================================================
//  Assembly : 180 deg open
// ============================================================
left_leaf();
right_leaf();
pin();
max success →
max
259.8s · 743/20941t · $0.5272
SCAD (116 lines)
// ============================================================
//  家具用 小型バット蝶番 (Butt Hinge) --- 180°オープン状態
//  Parts : 左板(left leaf) / 右板(right leaf) / ピン軸(pin)
//
//  座標系:
//    ピン軸の中心線 = Y 軸 (+Y 方向), 板の平面は Z 軸に直交
//    左板 = x<0 側, 右板 = x>0 側 (180°開)
//    z = 0 の面 = 相手板との合わせ面(ピン軸を含む平面)
//    板本体は z = -leaf_t 〜 0 に配置 → 両板の平面は同一平面
//    (この配置により 0°まで畳むと2枚が面接触する実物どおりの構造)
// ============================================================

$fn = 96;

/* ------------------- パラメータ ------------------- */
leaf_len    = 30;                 // 板 縦 (Y = ヒンジ軸方向)
leaf_w      = 25;                 // 板 横 (X = 開く方向 / 軸中心から先端まで)
leaf_t      = 2;                  // 板厚

knuckle_d   = 8;                  // knuckle 外径
n_seg       = 5;                  // 縦30mmの分割数
seg_len     = leaf_len / n_seg;   // = 6mm (1区画)
knuckle_gap = 0.2;                // 隣接knuckleのY逃げ(0にすると各6mmぴったり)

pin_d       = 4;                  // ピン軸 直径
pin_len     = 32;                 // ピン軸 長さ(両端約1mm突出)
pin_clr     = 0.3;                // 片側クリアランス
pin_hole_d  = pin_d + 2*pin_clr;  // = 4.6mm 穴

barrel_clr  = 0.2;                // 相手knuckle外周に対する板側の逃げ

screw_d     = 3.2;                // M3 貫通穴
cs_d        = 6.0;                // 皿穴 大径
cs_h        = 1.0;                // 皿(テーパ)深さ
screw_x     = 18;                 // ねじ穴 X 位置(knuckleから離れた側)
screw_pitch = 8;                  // ねじ穴 Y ピッチ
screw_n     = 3;                  // ねじ穴 個数

left_segs   = [0, 2, 4];          // 左板のknuckle : 外側2個 + 中央1個
right_segs  = [1, 3];             // 右板のknuckle : 中間2個

eps  = 0.01;
over = 0.2;

// 区画 i (0..4) の中心 Y 座標 : -12, -6, 0, 6, 12
function seg_cy(i) = -leaf_len/2 + seg_len*(i + 0.5);

/* ------------------- ヘルパ ------------------- */
// Y 軸方向の円柱
module y_cyl(y0, len, d) {
    translate([0, y0, 0]) rotate([-90, 0, 0]) cylinder(h = len, d = d);
}

// 皿穴(z=0 の面から見て φ6×深さ1のテーパ + φ3.2 貫通)
module cs_hole() {
    translate([0, 0, -leaf_t - 1]) cylinder(h = leaf_t + 2, d = screw_d);
    translate([0, 0, -cs_h])
        cylinder(h = cs_h + over, d1 = screw_d,
                 d2 = cs_d + over*(cs_d - screw_d)/cs_h);
}

/* ------------------- 板(+X 側で生成) ------------------- */
module leaf_half(my_segs, other_segs) {
    difference() {
        union() {
            // 板 30 x 25 x t
            translate([0, -leaf_len/2, -leaf_t]) cube([leaf_w, leaf_len, leaf_t]);
            // 自分の knuckle
            for (i = my_segs)
                y_cyl(seg_cy(i) - (seg_len - knuckle_gap)/2,
                      seg_len - knuckle_gap, knuckle_d);
        }
        // ピン穴(全長)
        y_cyl(-leaf_len/2 - 1, leaf_len + 2, pin_hole_d);

        // 相手 knuckle の逃げ(その区画は板をバレル外周まで削る)
        for (i = other_segs)
            y_cyl(seg_cy(i) - seg_len/2 - eps, seg_len + 2*eps,
                  knuckle_d + 2*barrel_clr);

        // M3 皿穴 3個
        for (k = [0 : screw_n - 1])
            translate([screw_x,
                       -screw_pitch*(screw_n - 1)/2 + screw_pitch*k, 0])
                cs_hole();
    }
}

/* ------------------- 各パーツ ------------------- */
module right_leaf() { leaf_half(right_segs, left_segs); }
module left_leaf()  { mirror([1, 0, 0]) leaf_half(left_segs, right_segs); }

module hinge_pin() {
    ch = 0.4;   // 端面の面取り
    translate([0, -pin_len/2, 0]) rotate([-90, 0, 0])
        union() {
            cylinder(h = ch, d1 = pin_d - 2*ch, d2 = pin_d);
            translate([0, 0, ch])            cylinder(h = pin_len - 2*ch, d = pin_d);
            translate([0, 0, pin_len - ch])  cylinder(h = ch, d1 = pin_d, d2 = pin_d - 2*ch);
        }
}

/* ------------------- 組立(180°開) ------------------- */
module hinge_assembly() {
    color("Silver")         left_leaf();
    color("LightSteelBlue") right_leaf();
    color("DimGray")        hinge_pin();
}

/* ------------------- 出力 ------------------- */
part = "assembly";   // "assembly" / "left" / "right" / "pin"

if      (part == "assembly") hinge_assembly();
else if (part == "left")     left_leaf();
else if (part == "right")    right_leaf();
else if (part == "pin")      hinge_pin();
xhigh success →
xhigh
120.9s · 743/9870t · $0.2505
SCAD (104 lines)
// =====================================================================
//  家具用 小型バット蝶番 (Butt Hinge)  -- 180° 開いた状態で組立表示
//    ・左板 (x<0) / 右板 (x>0) / ピン軸 (Y軸上)
//    ・ピン軸中心線 = Y 軸、板の平面は Z 軸に直交 (z = 0 .. 2)
// =====================================================================

$fn = 96;

// ---------------- パラメータ ----------------
leaf_len   = 30;      // 板の縦(ピン軸方向 = Y)
leaf_wid   = 25;      // 板の横(開く方向 = X, 軸中心から)
leaf_thk   = 2;       // 板厚(Z)

pin_dia    = 4;       // ピン軸 直径
pin_len    = 32;      // ピン軸 長さ(両端 1mm ずつ突出)

kn_od      = 8;       // knuckle 外径
kn_id      = 4.6;     // knuckle 内径(ピン軸 + 片側 0.3 クリアランス)
seg        = 6;       // knuckle 1個の長さ (30 / 5)
nseg       = 5;       // 分割数
ax_gap     = 0.15;    // knuckle 同士の軸方向すきま(片側)
rad_gap    = 0.3;     // 相手 knuckle との半径方向逃げ

scr_dia    = 3.2;     // M3 貫通穴
cs_dia     = 6;       // 皿(座ぐり)直径
cs_depth   = 1;       // 皿深さ
scr_pitch  = 8;       // 穴ピッチ(Y方向)
scr_x      = 17.5;    // 皿穴の X 位置(knuckle から離れた側)

left_segs  = [0, 2, 4];   // 左板: 外側2個 + 中央1個
right_segs = [1, 3];      // 右板: 中間2個

// ---------------- ユーティリティ ----------------
function seg_y0(i) = -leaf_len/2 + seg * i;

// i 番目の区画に置く円筒(knuckle 本体 / 逃げ用)
module knuckle(i, r, extra = 0) {
    translate([0, seg_y0(i) - extra, 0])
        rotate([-90, 0, 0])
            cylinder(h = seg + 2*extra, r = r);
}

// M3 皿穴(上面 z = leaf_thk 側から皿加工)
module screw_hole() {
    translate([0, 0, -1])
        cylinder(h = leaf_thk + 2, d = scr_dia);                 // 貫通穴
    translate([0, 0, leaf_thk - cs_depth])
        cylinder(h = cs_depth, d1 = scr_dia, d2 = cs_dia);       // テーパ
    translate([0, 0, leaf_thk - 0.01])
        cylinder(h = 1, d = cs_dia);                             // 上面逃げ
}

// ---------------- 板(右向き基本形)----------------
//   my_segs    : 自分の knuckle 区画
//   other_segs : 相手の knuckle 区画(逃げを差し引く)
module leaf(my_segs, other_segs) {
    difference() {
        union() {
            // 板本体 (30 x 25 x t)
            translate([0, -leaf_len/2, 0])
                cube([leaf_wid, leaf_len, leaf_thk]);
            // 自分の knuckle
            for (i = my_segs) knuckle(i, kn_od/2);
        }
        // ピン軸用の穴(全長貫通)
        translate([0, -leaf_len, 0])
            rotate([-90, 0, 0])
                cylinder(h = 2*leaf_len, d = kn_id);
        // 相手 knuckle の逃げ(回転クリアランス)
        for (i = other_segs) knuckle(i, kn_od/2 + rad_gap, ax_gap);
        // M3 皿穴 x3
        for (k = [-1, 0, 1])
            translate([scr_x, k*scr_pitch, 0]) screw_hole();
    }
}

// ---------------- ピン軸 ----------------
module pin() {
    rotate([-90, 0, 0])
        union() {
            cylinder(h = 0.6, d1 = pin_dia - 0.8, d2 = pin_dia);
            translate([0, 0, 0.6])
                cylinder(h = pin_len - 1.2, d = pin_dia);
            translate([0, 0, pin_len - 0.6])
                cylinder(h = 0.6, d1 = pin_dia, d2 = pin_dia - 0.8);
        }
}

// ---------------- 組立(180° 開)----------------
module hinge_assembly() {
    // 左板 (x < 0)
    color("Silver")
        mirror([1, 0, 0]) leaf(left_segs, right_segs);

    // 右板 (x > 0)
    color("LightSteelBlue")
        leaf(right_segs, left_segs);

    // ピン軸 (Y軸上・両端 1mm 突出)
    color("Gold")
        translate([0, -pin_len/2, 0]) pin();
}

hinge_assembly();

variant: thinking

off success →
off
20.3s · 743/1832t · $0.0495
SCAD (138 lines)
// ============================================================
//  Small furniture butt hinge (180 deg open)
//  - Left leaf  : x < 0  (3 knuckles: outer 2 + center 1)
//  - Right leaf : x > 0  (2 knuckles: intermediate)
//  - Pin        : along +Y axis, centered on Y axis
// ============================================================

$fn = 96;

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

pin_dia     = 4;
pin_len     = 32;    // 1 mm proud at each end

knuckle_od  = 8;
pin_clear   = 0.3;
knuckle_id  = pin_dia + pin_clear;   // 4.6

seg         = leaf_len / 5;          // 6 mm per segment
gap         = 0.15;                  // small running clearance between knuckles

// countersunk screw holes (M3)
cs_top_dia  = 6;
cs_depth    = 1;
hole_dia    = 3.2;
hole_pitch  = 8;
hole_inset  = 6;     // distance from outer edge of leaf to hole centers

eps         = 0.01;

// Segment centers along Y : -12, -6, 0, 6, 12
function seg_y(i) = -leaf_len/2 + seg/2 + i*seg;   // i = 0..4

// ============================================================
//  Modules
// ============================================================

// One knuckle (tube) segment centred on Y = yc
module knuckle(yc, h) {
    translate([0, yc, 0])
        rotate([-90, 0, 0])
            difference() {
                cylinder(h = h, d = knuckle_od, center = true);
                cylinder(h = h + 1, d = knuckle_id, center = true);
            }
}

// Countersunk hole, drilled from +Z down through the plate
module cs_hole() {
    union() {
        // through hole
        translate([0, 0, -leaf_thk/2 - eps])
            cylinder(h = leaf_thk + 2*eps, d = hole_dia);
        // conical countersink at top face
        translate([0, 0, leaf_thk/2 - cs_depth])
            cylinder(h = cs_depth + eps, d1 = hole_dia, d2 = cs_top_dia);
    }
}

// Plate body extending in +X from the knuckle axis, blended into knuckle OD
module leaf_plate() {
    // main flat plate from x = knuckle_od/2 ... leaf_wid
    translate([knuckle_od/2 - 0.5, -leaf_len/2, -leaf_thk/2])
        cube([leaf_wid - knuckle_od/2 + 0.5, leaf_len, leaf_thk]);
}

// Web that ties the plate to its own knuckle segments
module leaf_web(yc, h) {
    translate([0, yc - h/2, -leaf_thk/2])
        cube([knuckle_od/2, h, leaf_thk]);
}

// Screw hole pattern for one leaf (in local +X leaf coordinates)
module leaf_holes() {
    for (k = [-1, 0, 1])
        translate([leaf_wid - hole_inset, k * hole_pitch, 0])
            cs_hole();
}

// ---- Right leaf : plate in +X, knuckles at segments 1 and 3 ----
module right_leaf() {
    color("Silver")
    difference() {
        union() {
            leaf_plate();
            for (i = [1, 3]) {
                knuckle(seg_y(i), seg - gap);
                leaf_web(seg_y(i), seg - gap);
            }
        }
        leaf_holes();
        // clear the pin bore through everything
        rotate([-90, 0, 0])
            cylinder(h = leaf_len + 20, d = knuckle_id, center = true);
    }
}

// ---- Left leaf : mirrored, knuckles at segments 0, 2 and 4 ----
module left_leaf() {
    color("Silver")
    mirror([1, 0, 0])
    difference() {
        union() {
            leaf_plate();
            for (i = [0, 2, 4]) {
                knuckle(seg_y(i), seg - gap);
                leaf_web(seg_y(i), seg - gap);
            }
        }
        leaf_holes();
        rotate([-90, 0, 0])
            cylinder(h = leaf_len + 20, d = knuckle_id, center = true);
    }
}

// ---- Pin ----
module pin() {
    color("DimGray")
    rotate([-90, 0, 0])
        union() {
            cylinder(h = pin_len, d = pin_dia, center = true);
            // small chamfered heads at both ends
            translate([0, 0,  pin_len/2 - 0.4])
                cylinder(h = 0.4, d1 = pin_dia, d2 = pin_dia - 0.8);
            translate([0, 0, -pin_len/2])
                cylinder(h = 0.4, d1 = pin_dia - 0.8, d2 = pin_dia);
        }
}

// ============================================================
//  Assembly : 180 deg open
// ============================================================
left_leaf();
right_leaf();
pin();
adaptive (default) success →
adaptive
259.8s · 743/20941t · $0.5272
SCAD (116 lines)
// ============================================================
//  家具用 小型バット蝶番 (Butt Hinge) --- 180°オープン状態
//  Parts : 左板(left leaf) / 右板(right leaf) / ピン軸(pin)
//
//  座標系:
//    ピン軸の中心線 = Y 軸 (+Y 方向), 板の平面は Z 軸に直交
//    左板 = x<0 側, 右板 = x>0 側 (180°開)
//    z = 0 の面 = 相手板との合わせ面(ピン軸を含む平面)
//    板本体は z = -leaf_t 〜 0 に配置 → 両板の平面は同一平面
//    (この配置により 0°まで畳むと2枚が面接触する実物どおりの構造)
// ============================================================

$fn = 96;

/* ------------------- パラメータ ------------------- */
leaf_len    = 30;                 // 板 縦 (Y = ヒンジ軸方向)
leaf_w      = 25;                 // 板 横 (X = 開く方向 / 軸中心から先端まで)
leaf_t      = 2;                  // 板厚

knuckle_d   = 8;                  // knuckle 外径
n_seg       = 5;                  // 縦30mmの分割数
seg_len     = leaf_len / n_seg;   // = 6mm (1区画)
knuckle_gap = 0.2;                // 隣接knuckleのY逃げ(0にすると各6mmぴったり)

pin_d       = 4;                  // ピン軸 直径
pin_len     = 32;                 // ピン軸 長さ(両端約1mm突出)
pin_clr     = 0.3;                // 片側クリアランス
pin_hole_d  = pin_d + 2*pin_clr;  // = 4.6mm 穴

barrel_clr  = 0.2;                // 相手knuckle外周に対する板側の逃げ

screw_d     = 3.2;                // M3 貫通穴
cs_d        = 6.0;                // 皿穴 大径
cs_h        = 1.0;                // 皿(テーパ)深さ
screw_x     = 18;                 // ねじ穴 X 位置(knuckleから離れた側)
screw_pitch = 8;                  // ねじ穴 Y ピッチ
screw_n     = 3;                  // ねじ穴 個数

left_segs   = [0, 2, 4];          // 左板のknuckle : 外側2個 + 中央1個
right_segs  = [1, 3];             // 右板のknuckle : 中間2個

eps  = 0.01;
over = 0.2;

// 区画 i (0..4) の中心 Y 座標 : -12, -6, 0, 6, 12
function seg_cy(i) = -leaf_len/2 + seg_len*(i + 0.5);

/* ------------------- ヘルパ ------------------- */
// Y 軸方向の円柱
module y_cyl(y0, len, d) {
    translate([0, y0, 0]) rotate([-90, 0, 0]) cylinder(h = len, d = d);
}

// 皿穴(z=0 の面から見て φ6×深さ1のテーパ + φ3.2 貫通)
module cs_hole() {
    translate([0, 0, -leaf_t - 1]) cylinder(h = leaf_t + 2, d = screw_d);
    translate([0, 0, -cs_h])
        cylinder(h = cs_h + over, d1 = screw_d,
                 d2 = cs_d + over*(cs_d - screw_d)/cs_h);
}

/* ------------------- 板(+X 側で生成) ------------------- */
module leaf_half(my_segs, other_segs) {
    difference() {
        union() {
            // 板 30 x 25 x t
            translate([0, -leaf_len/2, -leaf_t]) cube([leaf_w, leaf_len, leaf_t]);
            // 自分の knuckle
            for (i = my_segs)
                y_cyl(seg_cy(i) - (seg_len - knuckle_gap)/2,
                      seg_len - knuckle_gap, knuckle_d);
        }
        // ピン穴(全長)
        y_cyl(-leaf_len/2 - 1, leaf_len + 2, pin_hole_d);

        // 相手 knuckle の逃げ(その区画は板をバレル外周まで削る)
        for (i = other_segs)
            y_cyl(seg_cy(i) - seg_len/2 - eps, seg_len + 2*eps,
                  knuckle_d + 2*barrel_clr);

        // M3 皿穴 3個
        for (k = [0 : screw_n - 1])
            translate([screw_x,
                       -screw_pitch*(screw_n - 1)/2 + screw_pitch*k, 0])
                cs_hole();
    }
}

/* ------------------- 各パーツ ------------------- */
module right_leaf() { leaf_half(right_segs, left_segs); }
module left_leaf()  { mirror([1, 0, 0]) leaf_half(left_segs, right_segs); }

module hinge_pin() {
    ch = 0.4;   // 端面の面取り
    translate([0, -pin_len/2, 0]) rotate([-90, 0, 0])
        union() {
            cylinder(h = ch, d1 = pin_d - 2*ch, d2 = pin_d);
            translate([0, 0, ch])            cylinder(h = pin_len - 2*ch, d = pin_d);
            translate([0, 0, pin_len - ch])  cylinder(h = ch, d1 = pin_d, d2 = pin_d - 2*ch);
        }
}

/* ------------------- 組立(180°開) ------------------- */
module hinge_assembly() {
    color("Silver")         left_leaf();
    color("LightSteelBlue") right_leaf();
    color("DimGray")        hinge_pin();
}

/* ------------------- 出力 ------------------- */
part = "assembly";   // "assembly" / "left" / "right" / "pin"

if      (part == "assembly") hinge_assembly();
else if (part == "left")     left_leaf();
else if (part == "right")    right_leaf();
else if (part == "pin")      hinge_pin();
dynamicnot run
—