Recently I have been working on a project to build 3D printable lugs for a custom bike frame. I am using OpenSCAD to build this because I find the software to align very well to how I enjoy building things. As a software developer it is quite intuitive for building customizable 3D objects.
In this post I want to walk through my process of building the lower head tube lug using OpenSCAD. I do assume that you have an understanding of OpenSCAD, this is more of a guide than a beginner tutorial.
Here is the final result. I will walk through how it came to be. There is a cup at the bottom to hold bearings, two pipes that join at a given angle and some nice rounded fillets to make the part look nice.
The first thing to go over is the project setup.
I import/use a few different scad files.
utils holds a few helper methods that help make the modeling process easier. The ones I use are the
arrange modules that make it easy to align things to vectors using linear algebra. Span takes an object, rotates it to the vector and scales it to the vectors length. Arrange takes an object and only rotates it along the vector.
tubes_variables holds all of the bike frame geometry that I use later on.
In order to make this process easier I have written a few more helper modules.
to_frame_coords takes a model that is in global coordinates and puts it into the correct position on the bike frame.
to_lug_coords does the opposite, it takes a piece of the bike and moves it to global coordinates.
A note for those reading the code. My naming convention for variables is that constants are all uppercase (
LIKE_THIS). Three dimensional vectors start with a
v_like_this). Any modules or functions are simply lower snake case (
The first thing to build is the cup that will hold the bearing at the bottom of the head tube. The process for building parts like this is to start with a 2D version of it and then stretching it out into 3D in some way.
The cup is first modelled as a cross section that will be extruded in a circle to make a cylinder. Using the
polyRound module from Round-Everything and setting up points, the section ends up looking like this. You see it does not look like a bearing holder yet but if you picture cutting a thin slice out of a bagel, this is kind of the same process in reverse.
rotate_extrude the cross section is turned into a cylinder by rotating it around an axis. The slice fills out and creates the rest of the bagel. Creating the final bearing cup as seen below.
Now moving on to the top of the lug. This is purely for looks and will give the ends of the lug some nice smooth edges rather than sharp 90 degree ones. This follows exactly the same 2D to 3D procedure.
Start with the outline of a cross section. This time its just a rectangle with a single rounded corner.
rotate_extrude to produce the shape. Note how the rounded corner ends up flowing around the entire edge.
Finally we get to the interesting part, the join between both tubes. Unlike the first two sections this one is hard to build using the 2D to 3D method from before, so we are going to start directly in 3D.
Start by setting up the intersection. Create both tubes using cylinders. Move the two cylinder to the same location and angles of the tubes so that they join up where the tubes are connected. This creates the basic form but looks quite sharp where the two cylinders are connecting.
To smooth out the connection we are going to use a new tool. With the
unionRoundMask tool of Round-Everything we can specify a cube as the rounding mask and have it create a nice fillet around the join. The mask lets us specify a 3D area where rounding should occur and then the tool will round all of the edges between the cylinders within that area.
Next we need to put all of our parts together into a single solid block. This will be the final 3D outline of our lug but without the holes inside for the tubes to slide into.
Using the helpers from the start, we move all of the modules into their correct position in global coordinates. This creates the final solid part. Now its starting to look like the lug that we are building.
Then finally we need to cut the space that each tube will slide into. Using some more helpers we move it on top of the frame and use the
difference module to hollow out the part where the tubes will go. This cuts out everything where the lug and frame overlap and leaves perfectly sized holes within the final part.
Now after rendering everything the head tube lug is finished.
This pretty much covers my process for making parts. As much as possible start with a 2D cutout of what you are building. Afterwards, extrude the cutout into a 3D object. Then apply various modifiers to the 3D object until it is the size that you are looking for.
I want to say a huge thank you to the Round-Everything library creators and maintainers because without them this piece would probably look a lot different. If you are trying to create nice looking functional parts in OpenSCAD I highly recommend using this library.