Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // One of the hundred guesses of how the design could look.
- $fn = 100;
- // Main box
- height = 78; // in z-direction
- width = 55; // in x-direction
- depth = 20; // in y-direction
- tube_diameter = 7;
- tube_wall_thickness = 0.5;
- box_wall_thickness = 1;
- box_bottom_thickness = 1;
- corner_radius = 5;
- hole_radius = tube_diameter/2 - tube_wall_thickness;
- // Calculate the positions for the holes and tubes to be evenly spaced
- // The holes must be at least "clearance + hole_radius" from the wall.
- clearance = 1.5;
- min_x_pos = clearance + hole_radius;
- max_x_pos = width - clearance - hole_radius;
- min_y_pos = clearance + hole_radius;
- max_y_pos = depth - clearance - hole_radius;
- hole_positions =
- [
- for (x = [0:3], y = [0:1])
- [
- min_x_pos + x * (max_x_pos - min_x_pos) / 3, // x
- min_y_pos + y * (max_y_pos - min_y_pos) / 1, // y
- 0 // z
- ]
- ];
- // Remove the inside from the tubes.
- difference()
- {
- FullShapeSolidTubes();
- // Remove inside of tubes.
- // Let it stick out the bottom and top by 1.
- for(hole=hole_positions)
- translate(hole)
- translate([0,0,-1])
- cylinder(h=height+2,r=hole_radius);
- }
- // The full shape, but the tubes are still solid.
- module FullShapeSolidTubes()
- {
- // The bottom of the box
- linear_extrude(box_bottom_thickness)
- BoxBase2D();
- // The walls of the box
- linear_extrude(height,convexity=3)
- difference()
- {
- BoxBase2D();
- offset(-box_wall_thickness)
- BoxBase2D();
- }
- // The tubes, still solid here.
- for(hole=hole_positions)
- translate(hole)
- cylinder(h=height,d=tube_diameter);
- }
- // The bottom outside shape of the box in 2D.
- module BoxBase2D()
- {
- Round2D(corner_radius)
- square([width,depth]);
- }
- // Helper function to round inside and outside corners.
- module Round2D(radius=0)
- {
- offset(-radius)
- offset(2*radius)
- offset(delta=-radius)
- children();
- }
Advertisement
Add Comment
Please, Sign In to add comment