vibe-openscad

pdf-page/gpt-6-astra / tier-4-gp2y0a21yk

success tier 4

pdf-page (gpt 6 astra)

render
bare render of tier-4-gp2y0a21yk
loading STL…
success 62.2s · 3101/3769t · $0.2195
SCAD (292 lines)
/*
  Sharp GP2Y0A21YK0F — 外形モデル
  単位: mm / +Z: 光学面側 / +Y: 前方
  原点: レンズ突起・取付耳を除く本体ケースの外接箱中心

  * 寸法: レンズ中心位置
  ( )寸法: 参考値
  未指定寸法公差: ±0.3

  図の Connector / PWB は、指定に合わせて省略。
  中央延長部の切欠きとケーブルに置換している。
  レンズ曲率、窓の縁幅、ケーブル、切欠きは外観近似。
*/

$fn = 96;

eps = 0.02;

// ── 図面寸法 ────────────────────────────────────────
case_width       = 29.5;
case_height      = 13;
overall_depth    = 13.5;

lens_projection  = 2;
case_depth       = overall_depth - lens_projection;

front_height     = 8.4;
lens_window_h    = 7.2;
lens_to_step      = 6.3;
rear_case_depth  = overall_depth - lens_to_step;

mount_pitch      = 37;
mount_radius     = 3.75;
mount_hole_d     = 3.2;
mount_plate_t    = 1.5;

emitter_width    = 7.5;
window_gap       = 4.15;
receiver_width   = 16.3;

emitter_axis_x   = -case_width/2 + 4.5; // *4.5
receiver_axis_x  = emitter_axis_x + 20; // *20 ±0.1

emitter_left     = -mount_pitch/2 + 3.75;
receiver_left    = emitter_left + emitter_width + window_gap;

central_width   = 10.1;
reference_h     = 18.9;                // (18.9)

// ── 基準面 ──────────────────────────────────────────
z_back          = -case_depth/2;
z_step          = z_back + rear_case_depth;
z_face          = z_back + case_depth;
z_lens_top      = z_back + overall_depth;

// 中央延長部は、図のコネクタ投影領域を使った指定用の簡略形状。
extension_end_y = case_height/2 - reference_h;

// ── 外観近似パラメータ ──────────────────────────────
frame_border    = 0.55;
lens_cap_h      = 0.35;
emitter_lens_r  = 2.85;
receiver_lens_r = 2.85;

notch_width     = 4.2;
notch_depth     = 3.0;
cable_diameter  = 1.05;
cable_spacing  = 1.25;
cable_length   = 26;

case_color      = [0.055, 0.055, 0.060];
glass_color     = [0.115, 0.035, 0.045];
wire_colors     = [
    [0.88, 0.88, 0.84],
    [0.10, 0.10, 0.11],
    [0.72, 0.06, 0.05]
];

// ── 汎用形状 ────────────────────────────────────────
module block_between(x0, x1, y0, y1, z0, z1) {
    translate([x0, y0, z0])
        cube([x1-x0, y1-y0, z1-z0]);
}

module spherical_cap(radius, height) {
    sphere_radius = (radius*radius + height*height)/(2*height);

    intersection() {
        translate([0, 0, height-sphere_radius])
            sphere(r=sphere_radius);

        translate([-radius, -radius, 0])
            cube([2*radius, 2*radius, height+eps]);
    }
}

module rounded_wire(points, diameter) {
    for (i = [0 : len(points)-2]) {
        hull() {
            translate(points[i])
                sphere(d=diameter, $fn=24);
            translate(points[i+1])
                sphere(d=diameter, $fn=24);
        }
    }
}

// ── 取付バー・取付耳 ────────────────────────────────
module mounting_plate_outline() {
    union() {
        square([mount_pitch, 2*mount_radius], center=true);

        for (side = [-1, 1])
            translate([side*mount_pitch/2, 0])
                circle(r=mount_radius);

        // 下方へ伸びる中央の薄板状延長部。
        translate([-central_width/2, extension_end_y])
            square([
                central_width,
                -extension_end_y
            ]);
    }
}

module mounting_plate() {
    translate([0, 0, z_back])
        linear_extrude(height=mount_plate_t)
            mounting_plate_outline();
}

// 取付耳とケースの間の斜め補強部。厚みは外観近似。
module right_mount_gusset() {
    translate([0, 0, z_back])
        rotate([90, 0, 0])
            linear_extrude(height=2*mount_radius, center=true)
                polygon([
                    [case_width/2-eps, mount_plate_t-eps],
                    [mount_pitch/2,    mount_plate_t-eps],
                    [case_width/2-eps, 5.3]
                ]);
}

// ── ケース ──────────────────────────────────────────
module housing() {
    color(case_color)
        difference() {
            union() {
                // 背面側の幅広ケース。
                block_between(
                    -case_width/2, case_width/2,
                    -case_height/2, case_height/2,
                    z_back, z_step
                );

                // 光学面側は高さ8.4の段付き形状。
                block_between(
                    -case_width/2, case_width/2,
                    -front_height/2, front_height/2,
                    z_step-eps, z_face
                );

                mounting_plate();

                right_mount_gusset();
                mirror([1, 0, 0])
                    right_mount_gusset();
            }

            // 取付穴: φ3.2、中心間37。
            for (side = [-1, 1])
                translate([
                    side*mount_pitch/2,
                    0,
                    z_back-1
                ])
                    cylinder(
                        d=mount_hole_d,
                        h=overall_depth+2
                    );

            // ケーブル取り出し用の開放切欠き。
            block_between(
                -notch_width/2, notch_width/2,
                extension_end_y-eps,
                extension_end_y+notch_depth,
                z_back-eps,
                z_back+mount_plate_t+eps
            );
        }
}

// ── 発光側レンズ ────────────────────────────────────
module emitter() {
    lens_seat_z = z_lens_top-lens_cap_h;

    color(case_color)
        difference() {
            block_between(
                emitter_left,
                emitter_left+emitter_width,
                -lens_window_h/2,
                lens_window_h/2,
                z_face-eps,
                lens_seat_z
            );

            translate([emitter_axis_x, 0, z_face])
                cylinder(
                    r=emitter_lens_r,
                    h=lens_projection+eps
                );
        }

    color(glass_color) {
        translate([emitter_axis_x, 0, z_face-eps])
            cylinder(
                r=emitter_lens_r,
                h=lens_seat_z-z_face+2*eps
            );

        translate([emitter_axis_x, 0, lens_seat_z])
            spherical_cap(emitter_lens_r, lens_cap_h);
    }
}

// ── 受光側レンズ ────────────────────────────────────
module receiver() {
    lens_seat_z = z_lens_top-lens_cap_h;

    color(case_color)
        difference() {
            block_between(
                receiver_left,
                receiver_left+receiver_width,
                -lens_window_h/2,
                lens_window_h/2,
                z_face-eps,
                lens_seat_z
            );

            block_between(
                receiver_left+frame_border,
                receiver_left+receiver_width-frame_border,
                -lens_window_h/2+frame_border,
                lens_window_h/2-frame_border,
                z_face,
                z_lens_top+eps
            );
        }

    color(glass_color) {
        // 矩形の赤外線透過窓。
        block_between(
            receiver_left+frame_border-eps,
            receiver_left+receiver_width-frame_border+eps,
            -lens_window_h/2+frame_border-eps,
            lens_window_h/2-frame_border+eps,
            z_face-eps,
            lens_seat_z
        );

        // *寸法で指定された受光レンズ中心。
        translate([receiver_axis_x, 0, lens_seat_z])
            spherical_cap(receiver_lens_r, lens_cap_h);
    }
}

// ── ケーブル: コネクタを省いた3本の丸棒表現 ─────────
module cables() {
    wire_z = z_back + mount_plate_t/2;
    root_y = extension_end_y + notch_depth + 0.8;

    for (i = [0:2]) {
        x = (i-1)*cable_spacing;

        color(wire_colors[i])
            rounded_wire([
                [x, root_y, wire_z],
                [x, extension_end_y-2, wire_z],
                [x, extension_end_y-8, wire_z-0.7],
                [x+1.0, extension_end_y-16, wire_z-1.5],
                [x+2.5, extension_end_y-cable_length, wire_z-1.5]
            ], cable_diameter);
    }
}

// ── 完成モデル ──────────────────────────────────────
housing();
emitter();
receiver();
cables();
パラメータ (26) —
スライダを動かすと openscad-wasm で再レンダリング

meta

runIdpdf-page_gpt-6-astra-374936f12cf5-2026-09-05T10-15-10-674Z
matrixIdpdf-page/gpt-6-astra
signature374936f12cf5a845…
provideropenai
modelgpt-6-astra
harnesspdf-page
statussuccess
duration62.22s (wallclock: load + prompt eval + generation + network)
tokens3101 in / 3769 out
wallclock tok/s60.6 tok/s (end-to-end)
cost$0.2195
createdAt2026-09-05T10:15:10.674Z
gitCommitd69c2b8ad709
openscadOpenSCAD version 2026.04.27

prompt

添付画像は Sharp 製測距センサ GP2Y0A21YK0F のデータシートのページです。
OpenSCAD でモデリングしてください。

座標系: 単位 mm、本体の中心を原点とし、取付面(PWB / コネクタ側)を -Z に向ける。

完成したコード全体を ```openscad ... ``` のフェンスで囲んで出力してください。