Add gift box

This commit is contained in:
Kaan Barmore-Genç 2023-12-22 00:23:56 -06:00
parent 0e13f6c544
commit bd77df8183
Signed by: kaan
GPG Key ID: B2E280771CD62FCF
6 changed files with 55 additions and 36 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.gcode
*.json

BIN
Gift Box/gift-box-bottom.stl (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Gift Box/gift-box-lid.stl (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Gift Box/gift-box-screw-basic.stl (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -3,21 +3,25 @@
# Parameters
*/
$box_inner_width = 15;
$box_inner_depth = 6;
$box_inner_height = 15;
$box_inner_width = 88;
$box_inner_depth = 56;
$box_inner_height = 56;
$box_wall_thickness = 6;
// [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;
$overlap_fraction = 0.45;
// [0, 1] The thickness of the overlap as a fraction of the wall thickness.
$overlap_thickness_fraction = 0.5;
// [1, *] Bottom scale. Scale the bottom up by settings this to a small amount like 1.05 to increase the gap between lid and bottom. Raise this number if the lid is too tight and won't go in, lower it if the lid is too loose.
$bottom_scale = 1.05;
// In mm, the gap between the lid and bottom in the overlap area. Increase this number if the lid is too tight, lower it if the lid is too loose.
$overlap_gap = 0.25;
// [0, 1] Screw scale. Lower this number if the screw is too tight and won't go through the hole.
$lid_screw_scale = 0.94;
$lid = true;
$bottom = true;
$screw = true;
/**
# Code
@ -37,27 +41,33 @@ $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;
scale([$lid_screw_scale, $lid_screw_scale, $lid_screw_scale])
translate([0, 0, 5])
rotate([90, 0, 0])
screw();
difference() {
scale([$bottom_scale, $bottom_scale, 1])
bottom();
thread();
/* ==== Screw ==== */
if ($screw) {
scale([$lid_screw_scale, $lid_screw_scale, $lid_screw_scale])
translate([0, 0, 5])
rotate([90, 0, 0])
screw();
};
/* ==== Lid ==== */
if ($lid) {
difference() {
bottom(overlap_gap=$overlap_gap * -1);
thread();
};
};
translate([-10, 0, $bottom_height + $top_height + 2 * $box_wall_thickness])
rotate([0, 180, 0])
difference() {
color("blue")
translate([$box_outer_width, 0, $bottom_height + $top_height + 2 * $box_wall_thickness])
rotate([0, 180, 0])
top();
thread();
};
/* ==== Box ==== */
if ($bottom) {
translate([-10, 0, $bottom_height + $top_height + 2 * $box_wall_thickness])
rotate([0, 180, 0])
difference() {
color("blue")
translate([$box_outer_width, 0, $bottom_height + $top_height + 2 * $box_wall_thickness])
rotate([0, 180, 0])
top();
thread();
};
};
module top() {
difference() {
box_half($box_inner_width, $box_inner_depth, $top_height, $box_wall_thickness);
@ -70,13 +80,15 @@ module top() {
};
}
module bottom() {
module bottom(overlap_gap=0) {
union() {
box_half($box_inner_width, $box_inner_depth, $bottom_height, $box_wall_thickness);
color("#FF0")
box_half(
$box_inner_width + $box_wall_thickness,
$box_inner_depth + $box_wall_thickness, $overlap_height + $box_wall_thickness,
$overlap_thickness
$box_inner_width + $box_wall_thickness - overlap_gap * 2,
$box_inner_depth + $box_wall_thickness - overlap_gap * 2,
$overlap_height + $box_wall_thickness,
$overlap_thickness + overlap_gap
);
};
};
@ -93,12 +105,12 @@ module box_half($width, $depth, $height, $wall_thickness) {
};
};
$thread_z_offset = $bottom_height + $overlap_height / 2 + 7;
$thread_z_offset = $bottom_height + $overlap_height / 2 + 2;
$screw_scale = 0.33;
$screw_scale = 0.5;
module thread(length=$box_wall_thickness * (1/$screw_scale)) {
color("pink")
translate([$box_outer_width / 2, $box_wall_thickness + 0.1, $thread_z_offset])
translate([$box_outer_width / 2, $box_wall_thickness + 1.1, $thread_z_offset])
rotate([90, 0, 0])
scale([$screw_scale, $screw_scale, $screw_scale])
trapezoidThread(length=length);
@ -108,7 +120,7 @@ module screw() {
color("orange")
translate([$box_outer_width / 2, 0, $thread_z_offset])
rotate([90, 0, 0])
cylinder(h=5, d=15, $fn=6);
cylinder(h=5, d=18, $fn=6);
color("red")
translate([0, 0, 0])
thread(length=$box_wall_thickness * (1/$screw_scale));

BIN
gift-box.stl (Stored with Git LFS)

Binary file not shown.