vibe-openscad

bare-low/gpt-5-mini / tier-3-butt-hinge

render_error tier 3
error
openscad stl render failed (exit 1): ERROR: Parser error: syntax error in file ../../../../../tmp/render-Hoc1yL/input.scad, line 96
Can't parse file '/tmp/render-Hoc1yL/input.scad'!

bare (gpt 5 mini)

render
no render
render_error 60.5s · 592/3500t · $0.0071
openscad stl render failed (exit 1): ERROR: Parser error: syntax error in file ../../../../../tmp/render-Hoc1yL/input.scad, line 96
Can't parse file '/tmp/render-Hoc1yL/input.scad'!

SCAD (174 lines)
// OpenSCAD: Butt hinge (小型バット蝶番) — 3 部品を 180° 開いた状態で配置
// Units: mm

// Parameters
plate_len = 30;      // Y direction (hinge axis)
plate_w = 25;        // X direction (extends outward from hinge axis)
plate_th = 2;        // Z thickness

pin_diam = 4;
pin_r = pin_diam/2;
pin_len = 32;        // includes 1mm protrusion at each end beyond knuckles

knuckle_count_total = 5;
knuckle_spacing = plate_len / (knuckle_count_total-1); // 6 mm
knuckle_positions = [-12, -6, 0, 6, 12]; // centers along Y

knuckle_od = 8;
knuckle_id = pin_diam + 0.3; // 4.6 mm
knuckle_rad_od = knuckle_od/2;
knuckle_rad_id = knuckle_id/2;

knuckle_offset_x = 4; // left knuckles center at x = -knuckle_offset_x, right at +knuckle_offset_x
knuckle_z = plate_th; // knuckle thickness in Z equals plate thickness

// Countersink (M3) parameters
csink_top_diam = 6;
csink_top_r = csink_top_diam/2;
csink_depth = 1;
csink_hole_diam = 3.2;
csink_hole_r = csink_hole_diam/2;
csink_taper_bottom_r = csink_hole_r;

// Hole layout on each plate
hole_count = 3;
hole_pitch = 8; // along Y
// place holes centered around Y=0: [-8, 0, 8]
hole_positions_y = [-hole_pitch, 0, hole_pitch];
// holes located toward the far edge of each plate (away from hinge): x = +/- plate_w/2
hole_offset_x = plate_w/2 -  (plate_w/2); // we'll compute absolute position per side

$fn = 60; // resolution

module plate_with_knuckles(side = "left") {
    // side: "left" => occupies x from -plate_w to 0 (extends to negative X)
    //       "right" => occupies x from 0 to +plate_w
    side_sign = side == "left" ? -1 : 1;
    plate_x = side_sign * plate_w;
    // Plate body: positioned so inner edge is at x=0
    translate([side_sign * plate_w/2, 0, 0]) // center plate in X and Y=0, Z=plate_th/2
        difference() {
            // main plate slab
            translate([-plate_w/2, -plate_len/2, 0])
                cube([plate_w, plate_len, plate_th], center=false);
            // subtract knuckle inner holes where knuckles belong to this plate (nothing to subtract from slab)
            // subtract countersink + through-holes
            for (py = hole_positions_y) {
                hx = side_sign * (plate_w/2 -  (plate_w*0.2)); // place holes somewhat inset from edge (20% of width)
                hy = py;
                // move coordinate to plate slab coordinate
                translate([hx, hy, 0])
                    difference() {
                        // countersink tapered frustum: from csink_top_r at top surface (z=plate_th) down to csink_taper_bottom_r at z=plate_th - csink_depth
                        translate([0,0,0])
                            union() {
                                // remove tapered frustum (carve into plate)
                                translate([0,0,0])
                                    rotate([0,0,0])
                                        translate([0,0,0])
                                            // create tapered cone by subtracting cylinder from cone-like shape
                                            // simpler: use cylinder with top radius csink_top_r and bottom radius csink_taper_bottom_r via hull of two cylinders
                                            difference() {
                                                // Make a hull between two circles to get frustum
                                                translate([0,0,plate_th])
                                                    cylinder(h=0.001, r=csink_top_r, center=false);
                                                translate([0,0,plate_th - csink_depth])
                                                    cylinder(h=0.001, r=csink_taper_bottom_r, center=false);
                                            }
                                    ;
                                // through-hole (will actually subtract below)
                            }
                        // now subtract both the frustum and the through cylinder
                        // To perform subtraction we need to place the subtracting shapes in global coordinates; we'll instead perform subtraction in parent difference by replicating here:
                    }
            }
        }
    ;
    // The above approach attempted to subtract holes inside the plate but simpler: build plate then subtract holes/knuckles via separate operations in caller.
}

// Instead we'll construct plates as unions and then subtract holes and knuckle inner bores with overall difference for each plate.

module single_plate(side = "left") {
    side_sign = side == "left" ? -1 : 1;
    // Plate slab
    plate = translate([side_sign * plate_w/2, 0, plate_th/2])
                cube([plate_w, plate_len, plate_th], center=false);
    // Knuckles (outer solid tubes) attached to slab: only on inner edge
    knuckle_centers = side == "left" ? [-12, 0, 12] : [-6, 6];
    knuckles = union();
    for (py = knuckle_centers) {
        // knuckle center at x = side_sign * (-knuckle_offset_x)? For left we want center at x = -knuckle_offset_x
        kx = side == "left" ? -knuckle_offset_x : knuckle_offset_x;
        knuckles = knuckles
            union() {
                translate([kx, py, 0])
                    // create tube by subtracting inner cylinder from outer cylinder, thickness in Z = plate_th
                    difference() {
                        // outer cylinder (make as short box then hull to cylinders to keep Z thickness)
                        translate([-knuckle_rad_od, -knuckle_rad_od, 0])
                            // center the cylinder properly: we'll create cylinder along Z
                            translate([0,0,plate_th/2])
                                cylinder(h=plate_th, r=knuckle_rad_od, center=true);
                        // subtract inner bore
                        translate([0,0,plate_th/2])
                            translate([0,0,0]) // placeholder
                                translate([0,0,0])
                                    cylinder(h=plate_th + 0.2, r=knuckle_rad_id, center=true);
                    }
            };
    }
    // countersunk holes (subtract)
    cs_subtracts = union();
    for (py = hole_positions_y) {
        hx = side_sign * (plate_w/2 - plate_w*0.15); // placed inset 15% from outer edge
        hy = py;
        // position: hole axis along Z, top at z=plate_th
        // create through cylinder for hole and tapered frustum for countersink
        // frustum: hull between two small discs
        frustum = hull() {
            translate([hx, hy, plate_th]) cylinder(h=0.001, r=csink_top_r);
            translate([hx, hy, plate_th - csink_depth]) cylinder(h=0.001, r=csink_taper_bottom_r);
        }
        cs_subtracts = cs_subtracts
            union() {
                frustum;
                translate([hx, hy, -1]) cylinder(h=plate_th+2, r=csink_hole_r, center=false);
            };
    }

    // assemble plate with knuckles, then subtract countersinks and also subtract knuckle bores that pass through to allow pin clearance
    difference() {
        union() {
            plate;
            knuckles;
        }
        // subtract countersinks and through holes
        cs_subtracts;
        // subtract inner bores through knuckles (long cylinders)
        for (py = (side=="left" ? [-12,0,12] : [-6,6])) {
            kx = side == "left" ? -knuckle_offset_x : knuckle_offset_x;
            translate([kx, py, -1]) cylinder(h=plate_th + 2, r=knuckle_rad_id, center=false);
        }
    }
}

// Pin (shaft)
module pin() {
    // centerline along Y, centered at Y=0, X=0. Extend in Y by pin_len with center at 0 -> from -pin_len/2 to +pin_len/2
    translate([0, 0, plate_th/2]) // align pin centered in Z through knuckles
        rotate([90,0,0]) // rotate so cylinder axis along Y (cylinder default along Z)
            cylinder(h=pin_len, r=pin_r, center=true);
}

// Build final assembly: left plate at x negative, right at x positive, pin at center
// Ensure plates are placed so their flat faces (Z faces) coincide in same plane (both lie in XY plane at z=0..2mm)
union() {
    // left plate
    single_plate("left");
    // right plate
    single_plate("right");
    // pin (placed through knuckles). Ensure it extends 1mm beyond knuckle ends (knuckles span 30mm along Y; pin length 32mm)
    // The pin is already centered at Y=0 with length 32mm (=> extends 1mm beyond each end).
    pin();
}

meta

runIdbare-low_gpt-5-mini-d3d21b625e3f-2026-04-28T17-24-28-566Z
matrixIdbare-low/gpt-5-mini
signatured3d21b625e3f1629…
provideropenai
modelgpt-5-mini-2025-08-07
harnessbare
statusrender_error
duration60.51s (wallclock: load + prompt eval + generation + network)
tokens592 in / 3500 out
wallclock tok/s57.8 tok/s (end-to-end)
cost$0.0071
createdAt2026-04-28T17:24:28.566Z
gitCommitbe87c9f2adaf
openscadOpenSCAD version 2026.04.27

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 ... ``` のフェンスで囲んで出力してください。
コードのみで、追加の説明は不要です。