3D part design with OpenSCAD#112: Adding a box lid snap ring.

3 min read
By Bob
3D part design with OpenSCAD#112: Adding a box lid snap ring.

After taking a look at the box maker in the last post I decided I wanted to add some features to it just for fun and one thing that crossed my mind was a way to snap the lid on the box so I wouldn't need screw holes.

A few posts back I made a way to make an outline of an existing stl file and also a way to use minkowski and a sphere to make a flat line round:

3D part design with Inkscape and OpenSCAD #105: A handy use for minkowski()
I was experimenting with a way to turn a flat 2D line into a round 3D line and minkowski works great for this, here is the basic code: Path_to_SVG_File =”″; Sphere_size=2;//[.1:.01:20] width=.001;//[.001:.01:20] Rotate_x=0;//[0:.01:360] Rotate_
3D part design with OpenSCAD #103: grabbing an outline from an stl file with offset()
After making the last post I was experimenting with a way to grab an outline from any area of an stl file to use for a fillet or chamfer, it’s pretty easy to do this using the offset command and making a frame around a design so you can fill

Since I already had the code written I just made a few modifications so I can put a round ring around the top of a box:

//
 
/*[Box lid snap ring]*/
Path_to_STL_File="";
Snap_ring_width=1;//[0:.01:2]
Snap_ring_diameter=1;//[0:.01:2]
Move_snap_ring=1;//[0:.01:20]

module Offset(){
difference(){
offset(delta=Snap_ring_width/2)
projection(cut=true)
import(Path_to_STL_File);
projection(cut=true)
import(Path_to_STL_File);
}}
translate([0,0,Move_snap_ring])
minkowski(){
linear_extrude(.01)
Offset();
sphere(Snap_ring_diameter,$fn=40);
}

import(Path_to_STL_File);

Now I can save the lid from the box maker code to stl, import it into the new code and put a ring around it to use as a snap ring to hold the cover in place.

What's cool about this is I can make a box any shape with Inkscape and make the cover a snap on cover and even add extra rings for extra hold:

Once the cover has the ring around it I can export it as an stl, then import it and the box and use difference() to make the groove in the box:

And after A quick test print I can confirm that the cover snaps in and stays on really well: