Skip to content

Commit

Permalink
more snap fit improvements, update example image
Browse files Browse the repository at this point in the history
  • Loading branch information
lijon committed Feb 14, 2024
1 parent ca7b00d commit 3f2ed94
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
28 changes: 16 additions & 12 deletions examples/snap_fit_test.scad
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,29 @@ include <jl_scad/parts.scad>
include <jl_scad/utils.scad>

$slop = 0.1;
$fn = $preview?16:24;
$fn = $preview?16:48;

sz = [20,20,15];
sz = [30,30,10];

//cut_inspect(BACK,color="green",ofs=0)
box_make(explode=10.01,hide_box=false)
cut_inspect(BACK,color="black",ofs=0,s=200)
box_make(explode=10.1,hide_box=false)
{
// snap fits
box_shell_base_lid(sz,wall_sides=2,wall_top=1.2,rbot_inside=1,rtop_inside=1,rsides=8,rim_height=5,k=0.6)
xcopies(sz.x+10,2)
box_shell_base_lid(sz,wall_sides=2,wall_top=1.2,rbot_inside=1,rtop_inside=1,rsides=15,rim_height=3,k=0.5)
{
up($box_rim_height) {
box_part([BACK,FRONT])
box_snap_fit([5,2],spring_len=5,spring_dir=FRONT,thru_hole=true);
if($idx == 0)
up($box_rim_height) {
box_part([LEFT,RIGHT])
box_snap_fit([5,2],spring_len=4,spring_dir=FRONT,thru_hole=false,depth=0.6,spring_slot2=5);

box_part([LEFT,RIGHT])
box_snap_fit([3,2]);
}
}
else
up($box_rim_height/2)
box_part([LEFT,RIGHT])
box_snap_fit([5,1],spring_len=0,depth=0.2,spring_dir=LEFT,anchor=BOT);
}

// rim snap
right(sz.x+10) box_shell_base_lid(sz,wall_sides=2,wall_top=1.2,rbot_inside=1,rtop_inside=1,rsides=8,rim_height=3,k=0.6,rim_snap=true,rim_snap_gap=0);
right(sz.x*1.5+15) box_shell_base_lid(sz,wall_sides=2,wall_top=1.2,rbot_inside=1,rtop_inside=1,rsides=15,rim_height=3,k=0.5,rim_snap=true);
}
Binary file modified images/snap_fit_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 10 additions & 7 deletions parts.scad
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,12 @@ module box_wall(dir=BACK,height,length,gap=0,width=1,fillet=1.5,anchor=BOTTOM,sp
cuboid([width,l,height],rounding=-fillet,edges=edges,anchor=anchor,spin=spin,orient=orient);
}

module box_snap_fit(size=[3,2],depth=0.5,thickness,thru_hole=false,spring_len=3,spring_dir=LEFT,spring_slot=0.5,anchor=BOT+BACK,spin=0,orient=DOWN) {
module box_snap_fit(size=[3,2],depth=0.5,thickness,thru_hole=false,spring_len=3,spring_dir=FRONT,spring_slot=0.5,spring_slot2,gap=0.1,anchor=BOT+BACK,spin=0,orient=DOWN) {
checks = assert(depth<=size.y/2);

thickness = is_def(thickness) ? thickness : is_def($box_wall) ? $box_wall/2 : 1;
s = (spring_dir.y != 0 ? size : [size.y, size.x]) + [0,spring_len];
spring_slot2 = default(spring_slot2, spring_slot);

module snap_shape(slop=0,thru=false) {
sz = size + [slop,slop];
Expand All @@ -155,12 +158,12 @@ module box_snap_fit(size=[3,2],depth=0.5,thickness,thru_hole=false,spring_len=3,
box_half(BOT) {
tag(BOX_KEEP_TAG) snap_shape()
if(spring_len) box_cut() {
position(FRONT) back(0.001) cuboid([s.x+spring_slot*2,s.y+spring_slot,thickness+1],rounding=spring_slot/2,edges="Z",anchor=FRONT);
position(FRONT) back(0.001) cuboid([s.x+spring_slot*2,s.y+spring_slot2,thickness+1],rounding=spring_slot/2,edges="Z",anchor=FRONT);
}
}

box_half(TOP)
box_cut() down(0.001) snap_shape(spring_len /*&& !thru_hole*/ ? 0 : get_slop(), thru=thru_hole);
box_cut() down(0.001) fwd(gap) snap_shape(spring_len /*&& !thru_hole*/ ? 0 : get_slop(), thru=thru_hole);

children();
}
Expand Down Expand Up @@ -288,10 +291,10 @@ module box_shell_base_lid(
rbot_inside,
rtop_inside,
rim_snap=false, // do a snap ridge around the rim
rim_snap_ofs=0.8, // offset along rim Z
rim_snap_depth=0.3, // how much the snap ridge should protrude
rim_snap_gap=0, // offset the snap rim in base and lid so they match before the lid is fully closed
rim_snap_height=0.2,
rim_snap_ofs=1, // offset along rim Z
rim_snap_depth=0.2, // how much the snap ridge should protrude
rim_snap_gap=0.1, // offset the snap rim in base and lid so they match before the lid is fully closed
rim_snap_height=0.2, // extra snap height
){
size = scalar_vec3(size);
wall_top = default(wall_top, wall_sides);
Expand Down

0 comments on commit 3f2ed94

Please sign in to comment.