OpenSCAD实现圆角矩形,可以参考如下代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
// 圆角矩形模块代码 module roundedcube(xx, yy, height, radius) { difference() { cube([xx, yy, height]); difference() { translate([-.5, -.5, -.2]) cube([radius + .5, radius + .5, height + .5]); translate([radius, radius, height / 2]) cylinder(height, radius, radius, true); } translate([xx, 0, 0]) rotate(90) difference() { translate([-.5, -.5, -.2]) cube([radius + .5, radius + .5, height + .5]); translate([radius, radius, height / 2]) cylinder(height, radius, radius, true); } translate([xx, yy, 0]) rotate(180) difference() { translate([-.5, -.5, -.2]) cube([radius + .5, radius + .5, height + .5]); translate([radius, radius, height / 2]) cylinder(height, radius, radius, true); } translate([0, yy, 0]) rotate(270) difference() { translate([-.5, -.5, -.2]) cube([radius + .5, radius + .5, height + .5]); translate([radius, radius, height / 2]) cylinder(height, radius, radius, true); } } } |