My self-made 3D-printable designs, mainly in OpenSCAD
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rounded.scad 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. module rounded_cube(x, y, z, rx=fillet, ry=fillet, rz=fillet, noback=true, nobottom=false, notop=false) {
  2. $fs = 0.15;
  3. union() {
  4. if (rx == ry && ry == rz) {
  5. minkowski() {
  6. translate([rx, rx, rx])cube([x-rx*2, y-rx*2, z-rx*2]);
  7. sphere(r = rx);
  8. }
  9. } else {
  10. minkowski() {
  11. translate([rz+ry, rz+rx, rz+ry])cube([x-rz*2-ry*2, y-rz*2-rx*2, z-rx*2-ry*2]);
  12. cylinder(r = rz, h = 0.01);
  13. rotate ([0, 90, 0]) cylinder(r = rx, h = 0.01);
  14. rotate ([90, 0, 0]) cylinder(r = ry, h = 0.01);
  15. }
  16. }
  17. if (noback) {
  18. minkowski() {
  19. translate([ry, y/2, ry])cube([x-ry*2, y/2, z-ry*2]);
  20. rotate ([90, 0, 0]) cylinder(r = ry, h = 0.01);
  21. }
  22. }
  23. if (nobottom) {
  24. minkowski() {
  25. translate([rz, rz, 0])cube([x-rz*2, y-rz*2, z/2]);
  26. rotate ([0, 0, 0]) cylinder(r = rz, h = 0.01);
  27. }
  28. }
  29. if (notop) {
  30. minkowski() {
  31. translate([rz, rz, z/2])cube([x-rz*2, y-rz*2, z/2]);
  32. rotate ([0, 0, 0]) cylinder(r = rz, h = 0.01);
  33. }
  34. }
  35. }
  36. }
  37. module rounded_cylinder(r, h, rrnd = fillet, rtop = true, rbottom = false, center=false) {
  38. $fs = 0.15;
  39. htr = center ? -h/2 : 0;
  40. translate([0, 0, htr]) union() {
  41. minkowski() {
  42. translate([0,0,rrnd]) cylinder(r=r-rrnd, h=h-rrnd*2);
  43. sphere(rrnd);
  44. }
  45. if (!rbottom)
  46. translate([0,0,h/2]) cylinder(r=r, h=h/2);
  47. if (!rtop)
  48. translate([0,0,0]) cylinder(r=r, h=h/2);
  49. }
  50. }