vibe-openscad

tier-3-butt-hinge / gpt-6.1-sol

6 run / 累計 719.4s / 累計 $0.2858

openai gpt 6.1 sol bare

bare (provider default effort)

run detail →
render
bare render of tier-3-butt-hinge
loading STL…
success 44.0s · 592/1641t · $0.0176
SCAD (122 lines)
$fn = 96;

// 単位: mm
leaf_length    = 30;
leaf_width     = 25;
leaf_thickness = 2;

pin_diameter = 4;
pin_length   = 32;

knuckle_od     = 8;
knuckle_id     = 4.6;
knuckle_count  = 5;
knuckle_length = leaf_length / knuckle_count;

screw_diameter = 3.2;
countersink_d  = 6;
countersink_h  = 1;
screw_pitch    = 8;

eps = 0.01;

// 板本体は筒部の外側から25mm伸ばす。
// 両板とも下面 Z=-2、上面 Z=0。
leaf_root_x = knuckle_od / 2;
hole_x      = leaf_root_x + leaf_width - 7;

// Z方向の円柱を、中心線がY軸になるように配置。
module y_cylinder(y_start, length, diameter) {
    translate([0, y_start, 0])
        rotate([-90, 0, 0])
            cylinder(h = length, d = diameter);
}

module screw_hole(x, y) {
    // 貫通穴
    translate([x, y, -leaf_thickness - eps])
        cylinder(
            h = leaf_thickness + 2 * eps,
            d = screw_diameter
        );

    // 上面から深さ1mmの皿穴。
    // Z=0での直径を正確に6mmに保ち、上方へ微小延長する。
    translate([x, y, -countersink_h])
        cylinder(
            h  = countersink_h + eps,
            d1 = screw_diameter,
            d2 = countersink_d
                 + (countersink_d - screw_diameter)
                   * eps / countersink_h
        );
}

// +X側の板を生成。
// parity=0: Y=0..6, 12..18, 24..30 の3筒。
// parity=1: Y=6..12, 18..24 の2筒。
module positive_leaf(parity) {
    difference() {
        union() {
            translate([leaf_root_x, 0, -leaf_thickness])
                cube([leaf_width, leaf_length, leaf_thickness]);

            for (i = [0 : knuckle_count - 1]) {
                if (i % 2 == parity) {
                    y_cylinder(
                        i * knuckle_length,
                        knuckle_length,
                        knuckle_od
                    );

                    // 板と筒を体積的に接続する部分。
                    // 内径に侵入する部分は下の軸穴で除去。
                    translate([
                        knuckle_id / 2 - 0.5,
                        i * knuckle_length,
                        -leaf_thickness
                    ])
                        cube([
                            leaf_root_x - knuckle_id / 2 + 0.5 + eps,
                            knuckle_length,
                            leaf_thickness
                        ]);
                }
            }
        }

        y_cylinder(-eps, leaf_length + 2 * eps, knuckle_id);

        for (offset = [-screw_pitch, 0, screw_pitch])
            screw_hole(hole_x, leaf_length / 2 + offset);
    }
}

module left_leaf() {
    mirror([1, 0, 0])
        positive_leaf(0);
}

module right_leaf() {
    positive_leaf(1);
}

module hinge_pin() {
    y_cylinder(
        -(pin_length - leaf_length) / 2,
        pin_length,
        pin_diameter
    );
}

// 180°開いた完成品。
// 3部品を結合せず、独立したソリッドとして配置。
// 各筒は指定どおり長さ6mmで、隣接端面は接触する。
color([0.65, 0.68, 0.72])
    left_leaf();

color([0.72, 0.75, 0.79])
    right_leaf();

color([0.42, 0.45, 0.49])
    hinge_pin();
パラメータ (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: effort

low success →
low
31.0s · 592/1283t · $0.0140
SCAD (135 lines)
// 単位: mm
// ピン中心線: Y軸、蝶番は180°開いた状態
$fn = 96;

leaf_length = 30;
leaf_width = 25;
leaf_thickness = 2;

pin_diameter = 4;
pin_length = 32;

knuckle_outer_diameter = 8;
knuckle_inner_diameter = 4.6;
knuckle_length = 6;

leaf_inner_x = knuckle_outer_diameter / 2;
leaf_bottom_z = -leaf_thickness;

screw_diameter = 3.2;
countersink_diameter = 6;
countersink_depth = 1;
screw_x = leaf_inner_x + leaf_width - 6;
screw_y_positions = [7, 15, 23];

epsilon = 0.02;

// +Y方向の円柱
module cylinder_y(d, h) {
    rotate([-90, 0, 0])
        cylinder(d = d, h = h);
}

// 筒部。各区間は正確に6mm。
// 隣接する筒部の端面は接するが、体積は重ならない。
module knuckle(index) {
    translate([0, index * knuckle_length, 0])
        difference() {
            cylinder_y(
                d = knuckle_outer_diameter,
                h = knuckle_length
            );

            translate([0, -epsilon, 0])
                cylinder_y(
                    d = knuckle_inner_diameter,
                    h = knuckle_length + 2 * epsilon
                );
        }
}

// 上面Z=0から加工する皿穴
module countersunk_hole(x, y) {
    translate([x, y, leaf_bottom_z - epsilon])
        cylinder(
            d = screw_diameter,
            h = leaf_thickness + 2 * epsilon
        );

    translate([x, y, -countersink_depth])
        cylinder(
            d1 = screw_diameter,
            d2 = countersink_diameter,
            h = countersink_depth
        );

    translate([x, y, 0])
        cylinder(
            d = countersink_diameter,
            h = epsilon
        );
}

// +X側の板を基準として作る。
// 板本体を筒の外径より外側に置き、
// 自分の筒部の区間だけ接続タブを設けて相手側との干渉を避ける。
module leaf_positive_x(knuckle_indices) {
    difference() {
        union() {
            translate([leaf_inner_x, 0, leaf_bottom_z])
                cube([
                    leaf_width,
                    leaf_length,
                    leaf_thickness
                ]);

            for (index = knuckle_indices) {
                knuckle(index);

                translate([
                    2.5,
                    index * knuckle_length,
                    leaf_bottom_z
                ])
                    cube([
                        leaf_inner_x - 2.5 + 0.2,
                        knuckle_length,
                        leaf_thickness
                    ]);
            }
        }

        for (y = screw_y_positions)
            countersunk_hole(screw_x, y);
    }
}

// 左板: 外側2区間と中央区間
module left_leaf() {
    mirror([1, 0, 0])
        leaf_positive_x([0, 2, 4]);
}

// 右板: 中間2区間
module right_leaf() {
    leaf_positive_x([1, 3]);
}

// 両端が筒部から各1mm突出する独立したピン
module hinge_pin() {
    translate([0, -1, 0])
        cylinder_y(
            d = pin_diameter,
            h = pin_length
        );
}

// 完成品: 独立した3パーツ
color([0.65, 0.68, 0.72])
    left_leaf();

color([0.72, 0.75, 0.79])
    right_leaf();

color([0.40, 0.43, 0.47])
    hinge_pin();
medium (default) success →
medium
44.0s · 592/1641t · $0.0176
SCAD (122 lines)
$fn = 96;

// 単位: mm
leaf_length    = 30;
leaf_width     = 25;
leaf_thickness = 2;

pin_diameter = 4;
pin_length   = 32;

knuckle_od     = 8;
knuckle_id     = 4.6;
knuckle_count  = 5;
knuckle_length = leaf_length / knuckle_count;

screw_diameter = 3.2;
countersink_d  = 6;
countersink_h  = 1;
screw_pitch    = 8;

eps = 0.01;

// 板本体は筒部の外側から25mm伸ばす。
// 両板とも下面 Z=-2、上面 Z=0。
leaf_root_x = knuckle_od / 2;
hole_x      = leaf_root_x + leaf_width - 7;

// Z方向の円柱を、中心線がY軸になるように配置。
module y_cylinder(y_start, length, diameter) {
    translate([0, y_start, 0])
        rotate([-90, 0, 0])
            cylinder(h = length, d = diameter);
}

module screw_hole(x, y) {
    // 貫通穴
    translate([x, y, -leaf_thickness - eps])
        cylinder(
            h = leaf_thickness + 2 * eps,
            d = screw_diameter
        );

    // 上面から深さ1mmの皿穴。
    // Z=0での直径を正確に6mmに保ち、上方へ微小延長する。
    translate([x, y, -countersink_h])
        cylinder(
            h  = countersink_h + eps,
            d1 = screw_diameter,
            d2 = countersink_d
                 + (countersink_d - screw_diameter)
                   * eps / countersink_h
        );
}

// +X側の板を生成。
// parity=0: Y=0..6, 12..18, 24..30 の3筒。
// parity=1: Y=6..12, 18..24 の2筒。
module positive_leaf(parity) {
    difference() {
        union() {
            translate([leaf_root_x, 0, -leaf_thickness])
                cube([leaf_width, leaf_length, leaf_thickness]);

            for (i = [0 : knuckle_count - 1]) {
                if (i % 2 == parity) {
                    y_cylinder(
                        i * knuckle_length,
                        knuckle_length,
                        knuckle_od
                    );

                    // 板と筒を体積的に接続する部分。
                    // 内径に侵入する部分は下の軸穴で除去。
                    translate([
                        knuckle_id / 2 - 0.5,
                        i * knuckle_length,
                        -leaf_thickness
                    ])
                        cube([
                            leaf_root_x - knuckle_id / 2 + 0.5 + eps,
                            knuckle_length,
                            leaf_thickness
                        ]);
                }
            }
        }

        y_cylinder(-eps, leaf_length + 2 * eps, knuckle_id);

        for (offset = [-screw_pitch, 0, screw_pitch])
            screw_hole(hole_x, leaf_length / 2 + offset);
    }
}

module left_leaf() {
    mirror([1, 0, 0])
        positive_leaf(0);
}

module right_leaf() {
    positive_leaf(1);
}

module hinge_pin() {
    y_cylinder(
        -(pin_length - leaf_length) / 2,
        pin_length,
        pin_diameter
    );
}

// 180°開いた完成品。
// 3部品を結合せず、独立したソリッドとして配置。
// 各筒は指定どおり長さ6mmで、隣接端面は接触する。
color([0.65, 0.68, 0.72])
    left_leaf();

color([0.72, 0.75, 0.79])
    right_leaf();

color([0.42, 0.45, 0.49])
    hinge_pin();
high success →
high
71.8s · 592/3074t · $0.0319
SCAD (148 lines)
// 家具用バット蝶番:180° 開いた組立状態
// 軸方向:+Y、左板:X<0、右板:X>0
$fn = 96;

leaf_length    = 30;
leaf_width     = 25;
leaf_thickness = 2;

pin_diameter = 4;
pin_length   = 32;

knuckle_outer_diameter = 8;
radial_clearance       = 0.3;
knuckle_inner_diameter = pin_diameter + 2 * radial_clearance;
knuckle_length         = leaf_length / 5;

screw_hole_diameter  = 3.2;
countersink_diameter = 6;
countersink_depth    = 1;
screw_pitch          = 8;
screw_edge_distance  = 5;

outer_radius = knuckle_outer_diameter / 2;

// 両板の下面を Z=-4、上面を Z=-2 に揃える。
// 板本体は筒部の外側から伸ばし、相手側の筒部と干渉させない。
leaf_bottom = -outer_radius;
leaf_top    = leaf_bottom + leaf_thickness;

eps = 0.01;
web_overlap = 0.25;

// Z 軸向きの円柱を +Y 軸向きにする。
module cylinder_y(y_start, length, diameter) {
    translate([0, y_start, 0])
        rotate([-90, 0, 0])
            cylinder(h = length, d = diameter);
}

// 筒部と板をつなぐ部分。各板が所有する区間だけに配置する。
module connection_web(side, y_start) {
    web_inner_x = outer_radius / 2;
    web_outer_x = outer_radius + web_overlap;

    translate([
        side < 0 ? -web_outer_x : web_inner_x,
        y_start,
        leaf_bottom
    ])
        cube([
            web_outer_x - web_inner_x,
            knuckle_length,
            leaf_thickness
        ]);
}

// 上面からの皿穴:直径 6、深さ 1 のテーパと直径 3.2 の貫通穴。
module countersunk_hole(x, y) {
    translate([x, y, leaf_bottom - eps])
        cylinder(
            h = leaf_thickness + 2 * eps,
            d = screw_hole_diameter
        );

    // 上面を少し越えて切り抜き、上面位置で正確に直径 6 にする。
    translate([x, y, leaf_top - countersink_depth])
        cylinder(
            h  = countersink_depth + eps,
            d1 = screw_hole_diameter,
            d2 = countersink_diameter
               + (countersink_diameter - screw_hole_diameter)
               * eps / countersink_depth
        );
}

module hinge_leaf(side) {
    // 左:0〜6、12〜18、24〜30
    // 右:6〜12、18〜24
    knuckle_indices = side < 0 ? [0, 2, 4] : [1, 3];

    hole_x = side * (
        outer_radius + leaf_width - screw_edge_distance
    );

    difference() {
        union() {
            translate([
                side < 0
                    ? -(outer_radius + leaf_width)
                    : outer_radius,
                0,
                leaf_bottom
            ])
                cube([leaf_width, leaf_length, leaf_thickness]);

            for (i = knuckle_indices) {
                cylinder_y(
                    i * knuckle_length,
                    knuckle_length,
                    knuckle_outer_diameter
                );

                connection_web(side, i * knuckle_length);
            }
        }

        // 筒部の軸穴:直径 4.6 mm。
        cylinder_y(
            -eps,
            leaf_length + 2 * eps,
            knuckle_inner_diameter
        );

        // Y=7、15、23:縦方向ピッチ 8 mm。
        for (offset = [-1, 0, 1])
            countersunk_hole(
                hole_x,
                leaf_length / 2 + offset * screw_pitch
            );
    }
}

module left_leaf() {
    hinge_leaf(-1);
}

module right_leaf() {
    hinge_leaf(1);
}

module hinge_pin() {
    // Y=-1〜31:筒部の両端から各 1 mm 突出。
    cylinder_y(
        -(pin_length - leaf_length) / 2,
        pin_length,
        pin_diameter
    );
}

// 独立した 3 パーツを、共通の軸線上に組み立てて配置。
color([0.68, 0.70, 0.73])
    left_leaf();

color([0.75, 0.77, 0.80])
    right_leaf();

color([0.40, 0.43, 0.47])
    hinge_pin();
max success →
max
401.5s · 592/14447t · $0.1457
SCAD (124 lines)
// 単位: mm
$fn = 128;

leaf_length    = 30;
leaf_width     = 25;
leaf_thickness = 2;

pin_diameter = 4;
pin_length   = 32;

knuckle_outer_diameter = 8;
radial_clearance       = 0.3;
knuckle_inner_diameter = pin_diameter + 2 * radial_clearance; // 4.6
knuckle_length         = leaf_length / 5;                    // 6

through_hole_diameter = 3.2;
countersink_diameter  = 6;
countersink_depth     = 1;
hole_pitch           = 8;
hole_edge_margin     = 5;

opening_angle = 180;
eps = 0.02;

// 両板の表面を Z=0、裏面を Z=-2 に配置。
// 他方の筒部に板の内側縁が接触しないように離す。
leaf_inner_x = knuckle_outer_diameter / 2 + 0.2;
leaf_bottom_z = -leaf_thickness;
neck_inner_x = knuckle_inner_diameter / 2;

module cylinder_y(d, h) {
    rotate([-90, 0, 0])
        cylinder(d = d, h = h, center = false);
}

module countersunk_hole(x, y) {
    // 直径3.2 mmの貫通穴
    translate([x, y, leaf_bottom_z - eps])
        cylinder(
            d = through_hole_diameter,
            h = leaf_thickness + 2 * eps
        );

    // Z=0で直径6 mm、Z=-1で直径3.2 mmのテーパ。
    // 表面より上まで延長し、差分演算の同一面を避ける。
    translate([x, y, -countersink_depth])
        cylinder(
            h  = countersink_depth + eps,
            d1 = through_hole_diameter,
            d2 = countersink_diameter
                 + (countersink_diameter - through_hole_diameter)
                   * eps / countersink_depth
        );
}

// +X側を基準に作る、板・接続部・筒部からなる一体の部品。
module leaf(knuckle_indices) {
    difference() {
        union() {
            translate([leaf_inner_x, 0, leaf_bottom_z])
                cube([leaf_width, leaf_length, leaf_thickness]);

            for (i = knuckle_indices) {
                // 筒部: Y方向に正確に6 mmずつ配置
                translate([0, i * knuckle_length, 0])
                    cylinder_y(
                        d = knuckle_outer_diameter,
                        h = knuckle_length
                    );

                // 自分の筒部だけを板に接続するネック
                translate([
                    neck_inner_x,
                    i * knuckle_length,
                    leaf_bottom_z
                ])
                    cube([
                        leaf_inner_x - neck_inner_x + eps,
                        knuckle_length,
                        leaf_thickness
                    ]);
            }
        }

        // 接続部も含めて軸穴を確保
        translate([0, -eps, 0])
            cylinder_y(
                d = knuckle_inner_diameter,
                h = leaf_length + 2 * eps
            );

        for (i = [-1 : 1])
            countersunk_hole(
                x = leaf_inner_x + leaf_width - hole_edge_margin,
                y = leaf_length / 2 + i * hole_pitch
            );
    }
}

module left_leaf() {
    mirror([1, 0, 0])
        leaf([0, 2, 4]);
}

module right_leaf() {
    leaf([1, 3]);
}

module hinge_pin() {
    // 筒部のY範囲0~30に対し、ピンは-1~31。
    translate([0, -(pin_length - leaf_length) / 2, 0])
        cylinder_y(d = pin_diameter, h = pin_length);
}

// 3部品を共有するY軸上で組み立てる。
color([0.65, 0.68, 0.72])
    left_leaf();

color([0.75, 0.77, 0.80])
    rotate([0, opening_angle - 180, 0])
        right_leaf();

color([0.45, 0.48, 0.52])
    hinge_pin();
xhigh success →
xhigh
127.0s · 592/5781t · $0.0590
SCAD (152 lines)
// 単位: mm
// ヒンジ軸: X=0, Z=0 の Y 軸。
// 板の表面: Z=0、裏面: Z=-2。
// 開き角: 180°=全開、0°=閉じた状態。
$fn = 96;

opening_angle = 180;

leaf_length    = 30;
leaf_width     = 25;
leaf_thickness = 2;

pin_diameter = 4;
pin_length   = 32;

knuckle_diameter = 8;
knuckle_count    = 5;
knuckle_length   = leaf_length / knuckle_count;

// ピンに対して片側 0.3 mm、穴径は 4.6 mm。
pin_radial_clearance = 0.3;
bore_diameter = pin_diameter + 2 * pin_radial_clearance;

screw_hole_diameter = 3.2;
screw_pitch         = 8;
countersink_diameter = 6;
countersink_depth    = 1;
screw_outer_margin   = 5;

eps = 0.01;

// 相手側の筒に板が干渉しないよう、矩形板を外径の外側に配置。
// 自分側の筒だけを短い接続部で板につなぐ。
barrel_leaf_clearance = 0.2;
leaf_inner_x = knuckle_diameter / 2 + barrel_leaf_clearance;
leaf_outer_x = leaf_inner_x + leaf_width;

neck_inner_x = bore_diameter / 2 + 0.3;
neck_overlap = 0.5;
neck_width   = leaf_inner_x + neck_overlap - neck_inner_x;

screw_x = leaf_outer_x - screw_outer_margin;
screw_y_positions = [
    leaf_length / 2 - screw_pitch,
    leaf_length / 2,
    leaf_length / 2 + screw_pitch
];

// ローカル Z 方向の円柱を +Y 方向へ向ける。
module cylinder_y(diameter, length) {
    rotate([-90, 0, 0])
        cylinder(d = diameter, h = length);
}

// Z=0 の表面から、深さ 1 mm の皿穴。
module countersunk_hole(x, y) {
    translate([x, y, -leaf_thickness - eps])
        cylinder(
            d = screw_hole_diameter,
            h = leaf_thickness + 2 * eps
        );

    // Z=0 で正確に直径 6 mm となるよう、テーパを上方へ延長。
    translate([x, y, -countersink_depth])
        cylinder(
            h = countersink_depth + eps,
            d1 = screw_hole_diameter,
            d2 = countersink_diameter
                 + (countersink_diameter - screw_hole_diameter)
                 * eps / countersink_depth
        );
}

// side=-1: 左板、side=+1: 右板。
// 各筒は正確に 6 mm。隣接端面は接触するが体積は重ならない。
module leaf_part(side) {
    indices = side < 0 ? [0, 2, 4] : [1, 3];

    difference() {
        union() {
            // 30 × 25 × 2 mm の矩形板。
            translate([
                side < 0 ? -leaf_outer_x : leaf_inner_x,
                0,
                -leaf_thickness
            ])
                cube([leaf_width, leaf_length, leaf_thickness]);

            for (i = indices) {
                // 筒部。
                translate([0, i * knuckle_length, 0])
                    cylinder_y(
                        knuckle_diameter,
                        knuckle_length
                    );

                // 板と自分側の筒を一体化する接続部。
                translate([
                    side < 0
                        ? -leaf_inner_x - neck_overlap
                        : neck_inner_x,
                    i * knuckle_length,
                    -leaf_thickness
                ])
                    cube([
                        neck_width,
                        knuckle_length,
                        leaf_thickness
                    ]);
            }
        }

        // すべての自分側の筒を同軸でくり抜く。
        translate([0, -eps, 0])
            cylinder_y(
                bore_diameter,
                leaf_length + 2 * eps
            );

        for (y = screw_y_positions)
            countersunk_hole(side * screw_x, y);
    }
}

module left_leaf() {
    leaf_part(-1);
}

module right_leaf() {
    leaf_part(1);
}

module hinge_pin() {
    // 筒全体は Y=0~30、ピンは Y=-1~31。
    translate([0, (leaf_length - pin_length) / 2, 0])
        cylinder_y(pin_diameter, pin_length);
}

module butt_hinge(angle = 180) {
    color([0.58, 0.60, 0.62])
        left_leaf();

    // Y 軸まわりに回転。180°では左右の表面がともに Z=0。
    color([0.64, 0.66, 0.68])
        rotate([0, angle - 180, 0])
            right_leaf();

    color([0.76, 0.78, 0.80])
        hinge_pin();
}

butt_hinge(opening_angle);