70 lines
2 KiB
OpenSCAD
70 lines
2 KiB
OpenSCAD
|
/**
|
||
|
|
||
|
# Parameters
|
||
|
|
||
|
*/
|
||
|
$box_inner_width = 10;
|
||
|
$box_inner_depth = 20;
|
||
|
$box_inner_height = 15;
|
||
|
$box_wall_thickness = 4;
|
||
|
// [0, 1] Higher the ratio, the bigger the bottom will be.
|
||
|
$box_bottom_top_height_fraction = 0.2;
|
||
|
// [0, 1] The amount the bottom and top will overlap.
|
||
|
$overlap_fraction = 0.8;
|
||
|
// [0, 1] The thickness of the overlap as a fraction of the wall thickness.
|
||
|
$overlap_thickness_fraction = 0.5;
|
||
|
|
||
|
/**
|
||
|
|
||
|
# Code
|
||
|
|
||
|
*/
|
||
|
include <Thread_Library.scad>;
|
||
|
|
||
|
$box_outer_width = $box_inner_width + $box_wall_thickness * 2;
|
||
|
$box_outer_depth = $box_inner_depth + $box_wall_thickness * 2;
|
||
|
$box_outer_height = $box_inner_height + $box_wall_thickness * 2;
|
||
|
|
||
|
$bottom_height = $box_inner_height * $box_bottom_top_height_fraction;
|
||
|
$top_height = $box_inner_height * (1 - $box_bottom_top_height_fraction);
|
||
|
|
||
|
$overlap_height = $box_inner_height * $overlap_fraction;
|
||
|
$overlap_thickness = $box_wall_thickness * $overlap_thickness_fraction;
|
||
|
|
||
|
|
||
|
bottom();
|
||
|
top();
|
||
|
|
||
|
module top() {
|
||
|
translate([-1 * $box_inner_width - $box_wall_thickness * 2 - 10, 0, 0])
|
||
|
difference() {
|
||
|
box_half($box_inner_width, $box_inner_depth, $top_height, $box_wall_thickness);
|
||
|
translate([-0.002, -0.002, 0])
|
||
|
scale([1.001, 1.001, 1.001])
|
||
|
translate([0, 0, $top_height + $bottom_height + $box_wall_thickness * 2])
|
||
|
color("red")
|
||
|
mirror([0, 0, 1])
|
||
|
bottom();
|
||
|
};
|
||
|
}
|
||
|
|
||
|
module bottom() {
|
||
|
union() {
|
||
|
box_half($box_inner_width, $box_inner_depth, $bottom_height, $box_wall_thickness);
|
||
|
box_half($box_inner_width + $box_wall_thickness, $box_inner_depth + $box_wall_thickness, $overlap_height + $box_wall_thickness, $overlap_thickness);
|
||
|
};
|
||
|
};
|
||
|
|
||
|
module box_half($width, $depth, $height, $wall_thickness) {
|
||
|
difference() {
|
||
|
cube([
|
||
|
$width + $wall_thickness * 2,
|
||
|
$depth + $wall_thickness * 2,
|
||
|
$height + $wall_thickness
|
||
|
]);
|
||
|
translate([$wall_thickness, $wall_thickness, $wall_thickness])
|
||
|
cube([$width, $depth, $height + 0.1]);
|
||
|
};
|
||
|
};
|
||
|
|