做一个盒子,寬150毫米,高70毫米,长80毫米,壁厚3毫米,盖子和盒子用可活动的铰链连接,要求可以3d打印一体成型,给我openscad代码,代码不要出现中文
- User
做一个盒子,寬150毫米,高70毫米,长80毫米,壁厚3毫米,盖子和盒子用可活动的铰链连接,要求可以3d打印一体成型,给我openscad代码,代码不要出现中文
Assistant
我来帮你设计这个带铰链的盒子。这个设计会将盒子分为底部和盖子两部分,用一体成型的铰链连接。以下是OpenSCAD代码:
// Box parameters length = 80; // Length width = 150; // Width height = 70; // Height thickness = 3; // Wall thickness gap = 0.3; // Gap for hinge movement // Hinge parameters hinge_r = 2; // Hinge pin radius hinge_count = 5; // Number of hinge segments module box_bottom() { difference() { cube([width, length, height/2]); translate([thickness, thickness, thickness]) cube([width-2*thickness, length-2*thickness, height/2]); } } module box_top() { translate([0, 0, height/2 + gap]) difference() { cube([width, length, height/2]); translate([thickness, thickness, thickness]) cube([width-2*thickness, length-2*thickness, height/2]); } } module hinge_segment(is_odd) { if(is_odd) { cylinder(r=hinge_r, h=10, $fn=20); } else { translate([0, 0, -5]) cylinder(r=hinge_r, h=10, $fn=20); } } module hinge() { spacing = 10; total_width = spacing * (hinge_count); translate([width/2 - total_width/2, 0, height/2]) rotate([-90, 0, 0]) for(i = [0:hinge_count-1]) { translate([i * spacing, 0, 0]) hinge_segment(i % 2 == 0); } } // Combine all parts union() { box_bottom(); box_top(); hinge(); }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.