vibe-openscad

pdf-page/gpt-5.4 / tier-4-gp2y0a21yk

success tier 4

pdf-page (gpt 5.4)

render
bare render of tier-4-gp2y0a21yk
loading STL…
success 24.4s · 3101/1611t · $0.0320
SCAD (183 lines)
$fn = 64;

// GP2Y0A21YK0F simplified external model
// Coordinate system:
//   origin = center of body
//   +Z = up
//   +Y = front
//   unit = mm

// -----------------------------
// Main dimensions read from datasheet
// -----------------------------
body_w = 37.0;          // overall width incl. ears
body_d = 8.4;           // depth
body_h = 13.5;          // total height incl. lower connector portion / excluding cable

center_block_w = 29.5;  // rectangular lens block width
center_block_h = 8.4;

ear_hole_d = 3.2;
ear_r = 3.75;           // end ear outside radius
hole_pitch = 37 - 2*ear_r; // center-to-center between mounting holes = 29.5
hole_x = hole_pitch/2;  // ±14.75

lens_center_pitch = 20.0;
lens_x = lens_center_pitch/2; // ±10
lens_center_z = 0.0;

// front profile partition heights from bottom
foot_t = 1.0;
lower_h = 2.1;
mid_h = 7.2;
upper_h = 13.5;

// side depths
lower_depth = 3.3;
mid_depth = 7.2;
top_extra = 6.3;     // from front face to rear top end
rear_step = 2.0;     // rear upper lip thickness

// connector / cable opening area
cable_open_w = 10.1;
cable_open_h = 4.0;
cable_open_z0 = -body_h/2 + 1.0;
cable_notch_w = 14.75;
cable_notch_h = 2.4;

// lens protrusions (simplified external features)
lens_outer_d = 7.2;
lens_outer_h = 2.2;
detector_window_w = 8.0;
detector_window_h = 5.8;
detector_window_d = 1.2;

// cable
cable_d = 3.0;
cable_len = 24.0;

// -----------------------------
module rounded_ear_2d()
{
    hull() {
        translate([-center_block_w/2,0]) square([center_block_w, center_block_h], center=true);
        translate([ hole_x,0]) circle(r=ear_r);
        translate([-hole_x,0]) circle(r=ear_r);
    }
}

module front_silhouette_2d()
{
    difference() {
        rounded_ear_2d();
        translate([ hole_x,0]) circle(d=ear_hole_d);
        translate([-hole_x,0]) circle(d=ear_hole_d);
    }
}

module body_core()
{
    // Build from front silhouette, extruded in Y with stepped depth
    union() {
        // mid section
        translate([0, -mid_depth/2, 0])
            rotate([90,0,0])
                linear_extrude(height=mid_depth)
                    front_silhouette_2d();

        // lower connector/board hanging part
        translate([0, -lower_depth/2, -body_h/2 + lower_h/2])
            cube([14.75, lower_depth, lower_h], center=true);

        // top lens case cap
        translate([0, -(top_extra)/2, body_h/2 - (body_h - mid_h)/2])
            cube([center_block_w, top_extra, body_h - mid_h], center=true);

        // rear upper lip
        translate([0, -(top_extra - rear_step/2), body_h/2 - 1.0])
            cube([center_block_w, rear_step, 2.0], center=true);

        // lower front slab under lens face
        translate([0, -(mid_depth-1.2)/2, -body_h/2 + lower_h + (mid_h-lower_h)/2])
            cube([center_block_w, mid_depth-1.2, mid_h-lower_h], center=true);

        // small bottom feet under each lens block (seen in top figure)
        for (x=[-7.5, 7.5])
            translate([x, 0, -body_h/2 - 0.1 + 1.0/2])
                cube([4.5, 3.3, 1.0], center=true);
    }
}

module lens_features()
{
    // Emitter: circular lens barrel
    translate([-lens_x, body_d/2 + lens_outer_h/2 - 0.2, 1.0])
        cylinder(d=lens_outer_d, h=lens_outer_h, center=true);

    // Detector: rounded rectangular / cylindrical protrusion approximation
    translate([ lens_x, body_d/2 + detector_window_d/2 - 0.2, 1.0])
        linear_extrude(height=detector_window_d, center=true)
            offset(r=1.0)
                square([detector_window_w-2.0, detector_window_h-2.0], center=true);

    // Front bezel around optical windows
    for (x=[-lens_x, lens_x])
        translate([x, body_d/2 - 0.6, 1.0])
            cube([9.5, 1.2, 8.2], center=true);
}

module front_optical_recesses()
{
    union() {
        // emitter circular recess
        translate([-lens_x, body_d/2 - 0.8, 1.0])
            cylinder(d=5.2, h=3.0, center=true);

        // detector rectangular recess
        translate([ lens_x, body_d/2 - 0.8, 1.0])
            linear_extrude(height=3.0, center=true)
                offset(r=0.7)
                    square([6.6, 4.8], center=true);
    }
}

module cable_exit_cut()
{
    union() {
        // central lower opening
        translate([0, body_d/2 - 1.3, -body_h/2 + cable_open_h/2 + 0.6])
            cube([cable_open_w, 3.5, cable_open_h], center=true);

        // wider notch at very bottom front
        translate([0, body_d/2 - 0.8, -body_h/2 + cable_notch_h/2 - 0.2])
            cube([cable_notch_w, 2.5, cable_notch_h], center=true);

        // small three pin reliefs
        for (x=[-2.6,0,2.6])
            translate([x, body_d/2 - 1.2, -body_h/2 + 2.8])
                cube([0.9, 2.8, 2.2], center=true);
    }
}

module cable()
{
    // simple round cable from central opening downward
    translate([0, body_d/2 - 0.8, -body_h/2 - cable_len/2 + 0.5])
        rotate([90,0,0])
            cylinder(d=cable_d, h=cable_len, center=true);
}

module sensor()
{
    difference() {
        union() {
            body_core();
            lens_features();
        }
        front_optical_recesses();
        cable_exit_cut();
    }
    cable();
}

sensor();
パラメータ (28)
スライダを動かすと openscad-wasm で再レンダリング

meta

runIdpdf-page_gpt-5.4-9e7202399380-2026-04-29T04-25-25-879Z
matrixIdpdf-page/gpt-5.4
signature9e7202399380d056…
provideropenai
modelgpt-5.4-2026-03-05
harnesspdf-page
statussuccess
duration24.44s (wallclock: load + prompt eval + generation + network)
tokens3101 in / 1611 out
wallclock tok/s65.9 tok/s (end-to-end)
cost$0.0320
createdAt2026-04-29T04:25:25.879Z
gitCommit3b7cc156e487
openscadOpenSCAD version 2026.04.27

prompt

添付の Sharp 製測距センサ GP2Y0A21YK0F のデータシート 2 ページ目には
本体の外形寸法図(External dimensions)が描かれています。図を読み取り、
OpenSCAD でセンサの外形をモデリングしてください。

※ 同じ Sharp の GP2Y0D413K0F とは別モデルです:
- レンジ: 10〜80cm(アナログ電圧出力)
- パッケージ:
  - 本体は横長(乗っているレンズ部 + 連結バー部分の2塊で構成)
  - 連結部にケーブル取り出し穴 + 取付穴2個
  - 受光・発光のレンズが本体上部から飛び出している
- コネクタはケーブル(JST PHR-3)で出る、本体下部に直付けではない

含めるべき部位:
- レンズ部本体ケース(直方体に近い、上部にレンズ突起)
- 発光側レンズと受光側レンズ(上面に並ぶ円形 / 矩形の窓)
- 連結バー(レンズ部の下方向に伸びる薄い板状の延長部)
- 連結バーにある取付穴 2 つ + ケーブル取り出しの切欠き
- ケーブル(PCB / コネクタの代わりに丸棒で簡易表現で可)

寸法:
- 図中のミリメートル数値に従ってください
- "*" 印が付いた寸法はレンズ中心位置を示す参照寸法です
- 括弧 `( )` で囲まれた値は参考寸法
- 未指定許容差 ±0.3 mm

座標系:
- 本体の中心が原点。+Z は上方向(レンズが上面)、+Y は前方
- 単位は mm

内部の IC や回路素子はモデリング不要、外形だけで十分です。
完成したコード全体を ```openscad ... ``` のフェンスで囲んで出力してください。
コードのみで、追加の説明は不要です。