Guest User

https://www.reddit.com/r/openscad/comments/1nb4bwm/aspects_that_appear_in_the_preview_dont_appear_in

a guest
Sep 8th, 2025
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | Source Code | 0 0
  1. // One of the hundred guesses of how the design could look.
  2.  
  3. $fn = 100;
  4.  
  5. // Main box
  6. height = 78; // in z-direction
  7. width = 55; // in x-direction
  8. depth = 20; // in y-direction
  9.  
  10. tube_diameter = 7;
  11. tube_wall_thickness = 0.5;
  12.  
  13. box_wall_thickness = 1;
  14. box_bottom_thickness = 1;
  15. corner_radius = 5;
  16.  
  17. hole_radius = tube_diameter/2 - tube_wall_thickness;
  18.  
  19. // Calculate the positions for the holes and tubes to be evenly spaced
  20. // The holes must be at least "clearance + hole_radius" from the wall.
  21. clearance = 1.5;
  22. min_x_pos = clearance + hole_radius;
  23. max_x_pos = width - clearance - hole_radius;
  24. min_y_pos = clearance + hole_radius;
  25. max_y_pos = depth - clearance - hole_radius;
  26.  
  27. hole_positions =
  28. [
  29. for (x = [0:3], y = [0:1])
  30. [
  31. min_x_pos + x * (max_x_pos - min_x_pos) / 3, // x
  32. min_y_pos + y * (max_y_pos - min_y_pos) / 1, // y
  33. 0 // z
  34. ]
  35. ];
  36.  
  37. // Remove the inside from the tubes.
  38. difference()
  39. {
  40. FullShapeSolidTubes();
  41.  
  42. // Remove inside of tubes.
  43. // Let it stick out the bottom and top by 1.
  44. for(hole=hole_positions)
  45. translate(hole)
  46. translate([0,0,-1])
  47. cylinder(h=height+2,r=hole_radius);
  48. }
  49.  
  50. // The full shape, but the tubes are still solid.
  51. module FullShapeSolidTubes()
  52. {
  53. // The bottom of the box
  54. linear_extrude(box_bottom_thickness)
  55. BoxBase2D();
  56.  
  57. // The walls of the box
  58. linear_extrude(height,convexity=3)
  59. difference()
  60. {
  61. BoxBase2D();
  62. offset(-box_wall_thickness)
  63. BoxBase2D();
  64. }
  65.  
  66. // The tubes, still solid here.
  67. for(hole=hole_positions)
  68. translate(hole)
  69. cylinder(h=height,d=tube_diameter);
  70. }
  71.  
  72. // The bottom outside shape of the box in 2D.
  73. module BoxBase2D()
  74. {
  75. Round2D(corner_radius)
  76. square([width,depth]);
  77. }
  78.  
  79. // Helper function to round inside and outside corners.
  80. module Round2D(radius=0)
  81. {
  82. offset(-radius)
  83. offset(2*radius)
  84. offset(delta=-radius)
  85. children();
  86. }
Tags: OpenSCAD
Advertisement
Add Comment
Please, Sign In to add comment