pdf-page/gpt-5.4 / tier-4-gp2y0a21yk
success tier 4
pdf-page (gpt 5.4)
render
$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 で再レンダリング
prompt
添付画像は Sharp 製測距センサ GP2Y0A21YK0F のデータシートのページです。 OpenSCAD でモデリングしてください。 座標系: 単位 mm、本体の中心を原点とし、取付面(PWB / コネクタ側)を -Z に向ける。 完成したコード全体を ```openscad ... ``` のフェンスで囲んで出力してください。